altosdroid: Hack up build to 'work' for now
authorKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 18:15:20 +0000 (11:15 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 5 Aug 2019 03:30:20 +0000 (20:30 -0700)
Android apps are now build with gradle instead of ant; the ant bits
are stale and only work with old java. Use old java to run ant while
using the current java compiler to build things.

This requires a custom version of the google play API library.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/AndroidManifest.xml.in
altosdroid/Makefile.am
altosdroid/build.xml
altosdroid/default.properties
altosdroid/project.properties
configure.ac

index 3f17188..690f199 100644 (file)
@@ -22,7 +22,7 @@
           package="org.altusmetrum.AltosDroid"
           android:versionCode="@ANDROID_VERSION@"
           android:versionName="@VERSION@">
-    <uses-sdk android:targetSdkVersion="12" android:minSdkVersion="12"/>
+    <uses-sdk android:targetSdkVersion="21" android:minSdkVersion="21"/>
     <!-- Google Maps -->
     <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
 
index 686aeab..dd875ca 100644 (file)
@@ -34,7 +34,7 @@ SUPPORT_V4_JAR=android-support-v4.jar
 
 SUPPORT_V4=$(EXT_LIBDIR)/$(SUPPORT_V4_JAR)
 
-GOOGLE_PLAY_SERVICES_LIB_SRCDIR=$(SDK)/extras/google/google_play_services/libproject
+GOOGLE_PLAY_SERVICES_LIB_SRCDIR=$(SDK)/..
 GOOGLE_PLAY_SERVICES_LIB=google-play-services_lib
 
 JAVA_SRC=$(JAVA_SRC_DIR)/*.java $(JAVA_SRC_DIR)/BuildInfo.java
@@ -83,10 +83,10 @@ install-debug: bin/AltosDroid-debug.apk
        $(ADB) install -r bin/AltosDroid-debug.apk
 
 bin/AltosDroid-debug.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB)
-       ant debug
+       JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ant debug
 
 bin/AltosDroid-release-unsigned.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB)
-       ant release
+       JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ant release
 
 bin/AltosDroid-release.apk: bin/AltosDroid-release-unsigned.apk
        jarsigner -sigalg SHA1withDSA -digestalg SHA1 \
index 6a89edb..e9382c7 100644 (file)
     </target>
 -->
 
+    <property name="java.target" value="1.7" />
+    <property name="java.source" value="1.7" />
+
+    <!-- Compiles this project's .java files into .class files. -->
+    <target name="-compile" depends="-pre-build, -build-setup, -code-gen, -pre-compile">
+        <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
+            <!-- merge the project's own classpath and the tested project's classpath -->
+            <path id="project.javac.classpath">
+                <path refid="project.all.jars.path" />
+                <path refid="tested.project.classpath" />
+                <path path="${java.compiler.classpath}" />
+            </path>
+            <javac encoding="${java.encoding}"
+                    source="${java.source}" target="${java.target}"
+                    debug="true" extdirs="" includeantruntime="false"
+                    destdir="${out.classes.absolute.dir}"
+                    bootclasspathref="project.target.class.path"
+                    verbose="${verbose}"
+                    classpathref="project.javac.classpath"
+                    fork="${need.javac.fork}">
+                <src path="${source.absolute.dir}" />
+                <src path="${gen.absolute.dir}" />
+                <compilerarg line="${java.compilerargs}" />
+            </javac>
+
+            <!-- if the project is instrumented, intrument the classes -->
+            <if condition="${build.is.instrumented}">
+                <then>
+                    <echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...</echo>
+
+                    <!-- build the filter to remove R, Manifest, BuildConfig -->
+                    <getemmafilter
+                            appPackage="${project.app.package}"
+                            libraryPackagesRefId="project.library.packages"
+                            filterOut="emma.default.filter"/>
+
+                    <!-- define where the .em file is going. This may have been
+                         setup already if this is a library -->
+                    <property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />
+
+                    <!-- It only instruments class files, not any external libs -->
+                    <emma enabled="true">
+                        <instr verbosity="${verbosity}"
+                               mode="overwrite"
+                               instrpath="${out.absolute.dir}/classes"
+                               outdir="${out.absolute.dir}/classes"
+                               metadatafile="${emma.coverage.absolute.file}">
+                            <filter excludes="${emma.default.filter}" />
+                            <filter value="${emma.filter}" />
+                        </instr>
+                    </emma>
+                </then>
+            </if>
+
+            <!-- if the project is a library then we generate a jar file -->
+            <if condition="${project.is.library}">
+                <then>
+                    <echo level="info">Creating library output jar file...</echo>
+                    <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
+                    <if>
+                        <condition>
+                            <length string="${android.package.excludes}" trim="true" when="greater" length="0" />
+                        </condition>
+                        <then>
+                            <echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo>
+                        </then>
+                    </if>
+
+                    <propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" />
+
+                    <jar destfile="${out.library.jar.file}">
+                        <fileset dir="${out.classes.absolute.dir}"
+                                includes="**/*.class"
+                                excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/>
+                        <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
+                    </jar>
+                </then>
+            </if>
+
+        </do-only-if-manifest-hasCode>
+    </target>
+
     <!-- Import the actual build file.
 
          To customize existing targets, there are two options:
index 3ac2523..69baf6b 100644 (file)
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-12
+target=android-21
index d178f98..853d1b0 100644 (file)
@@ -8,5 +8,5 @@
 # project structure.
 
 # Project target.
-target=android-12
+target=android-21
 android.library.reference.1=google-play-services_lib/
index cc6a23d..56bd70c 100644 (file)
@@ -70,7 +70,7 @@ AC_ARG_WITH(jvm, AS_HELP_STRING([--with-jvm=PATH],
 
 if test "x$JVM" = "xauto"; then
        AC_MSG_CHECKING([JVM])
-       for jvm in default-java java-6-openjdk java-7-openjdk java-8-openjdk java-9-openjdk java-10-openjdk java-11-openjdk java-12-openjdk java-13-openjdk java-6-sun; do
+       for jvm in default-java java-6-openjdk java-7-openjdk java-8-openjdk java-9-openjdk java-10-openjdk java-11-openjdk java-12-openjdk java-13-openjdk java-6-sun java-8-openjdk-amd64; do
                if test "x$JVM" = "xauto"; then
                        INCLUDE="/usr/lib/jvm/$jvm/include"
                        if test -f "$INCLUDE"/jni.h; then