From fccfe24f517608e139de8620c2b0956a92b6d063 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 2 Aug 2023 13:46:38 +0100 Subject: [PATCH 01/20] added compileKotlin and compileTestKotlin tasks to gradle targeting Kotlin 1.8 --- build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build.gradle b/build.gradle index dc76b9b1a..b3d233807 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,10 @@ buildscript { } } +plugins { + id 'org.jetbrains.kotlin.jvm' version '1.8.0' +} + /** * If `android` is true, the project will be configured as an Android rather than a Java library. This isn't used * for building archives (such as an APK), but is useful for performing Android checks like lint. @@ -48,6 +52,15 @@ compileTestJava { options.compilerArgs << "-Xlint:deprecation" } +compileKotlin { + kotlinOptions.jvmTarget = '1.8' +} + +compileTestKotlin { + kotlinOptions.jvmTarget = '1.8' +} + + targetCompatibility = '1.8' sourceCompatibility = '1.8' From 0efd26d92209519d2bdfd5bd4fc4901d0d218f93 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 2 Aug 2023 14:04:53 +0100 Subject: [PATCH 02/20] THESE TWO FILES ARE TO TEST THE BUILD SCRIPTS. They are not part of the javarosa functionality, and can be removed once the capability to build kotlin from gradle and from maven is completed. Added a kotlin file to `src/test` and to `src/main` to ensure compilation finds appropriate kotlin files and builds them. --- .../java/org/javarosa/kotlintest/ThisOrThat.kt | 5 +++++ .../javarosa/kotlintest/KotlinGradleSetupTest.kt | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/main/java/org/javarosa/kotlintest/ThisOrThat.kt create mode 100644 src/test/java/org/javarosa/kotlintest/KotlinGradleSetupTest.kt diff --git a/src/main/java/org/javarosa/kotlintest/ThisOrThat.kt b/src/main/java/org/javarosa/kotlintest/ThisOrThat.kt new file mode 100644 index 000000000..fbcd84bfd --- /dev/null +++ b/src/main/java/org/javarosa/kotlintest/ThisOrThat.kt @@ -0,0 +1,5 @@ +package org.javarosa.kotlintest + +enum class ThisOrThat { + THIS(), THAT(), OTHER() +} \ No newline at end of file diff --git a/src/test/java/org/javarosa/kotlintest/KotlinGradleSetupTest.kt b/src/test/java/org/javarosa/kotlintest/KotlinGradleSetupTest.kt new file mode 100644 index 000000000..a8316bea5 --- /dev/null +++ b/src/test/java/org/javarosa/kotlintest/KotlinGradleSetupTest.kt @@ -0,0 +1,14 @@ +package org.javarosa.kotlintest + +import junit.framework.TestCase +import org.javarosa.kotlintest.ThisOrThat.THAT +import org.javarosa.kotlintest.ThisOrThat.THIS +import org.junit.Test + +class KotlinGradleSetupTest { + @Test + fun `can compile Kotlin in directory`() { + TestCase.assertNotSame(THIS, THAT) + TestCase.assertSame(THIS, THIS) + } +} From 6d860e24396ba5474c6df3dcbd1bb222ce5f1005 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 2 Aug 2023 14:36:12 +0100 Subject: [PATCH 03/20] Updated Maven's pom.xml to build the kotlin. Upgraded the pom to use kotlin version 1.8.22 --- pom.xml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index b514fcd46..6ca8e1ea8 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,8 @@ UTF-8 + 1.8 + 1.8.22 @@ -74,7 +76,7 @@ org.jetbrains.kotlin kotlin-stdlib - 1.6.10 + ${kotlin.version} org.slf4j @@ -106,9 +108,33 @@ maven-compiler-plugin 3.8.0 - 1.8 - 1.8 + ${java.version} + ${java.version} + + + default-compile + none + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + org.apache.maven.plugins @@ -204,7 +230,7 @@ org.jetbrains.kotlin kotlin-maven-plugin - 1.6.10 + ${kotlin.version} compile @@ -212,7 +238,28 @@ compile + + + + ${project.basedir}/src/main/java + + + + test-compile + compile + + test-compile + + + + + ${project.basedir}/src/test/java + + + From bb341d1f48600de737f6d299b9f1259f10e8cd67 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 2 Aug 2023 17:12:08 +0100 Subject: [PATCH 04/20] pushing to test build.gradle config with circleCI's androidLint setup; doesn't `like The 'java' plugin has been applied, but it is not compatible with the Android plugins.` --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b3d233807..aba6656ba 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ plugins { * for building archives (such as an APK), but is useful for performing Android checks like lint. */ if (!project.hasProperty("android")) { - apply plugin: 'java' +// apply plugin: 'java' apply plugin: 'checkstyle' apply plugin: 'jacoco' apply plugin: 'me.champeau.jmh' From bfbd2d1374eda014af04095e8689b12db3c99fea Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 13:30:57 +0100 Subject: [PATCH 05/20] upgrade gradle to 8.2; fix deprecated syntax to be current version. --- build.gradle | 10 +++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index aba6656ba..ee0a9b0dc 100644 --- a/build.gradle +++ b/build.gradle @@ -92,15 +92,15 @@ tasks.register('installLocal') { if (!project.hasProperty("android")) { jar { - baseName = 'javarosa' + archiveBaseName = 'javarosa' // Be sure to update version in pom.xml to match // snapshot release = x.x.x-SNAPSHOT // production release = x.x.x - version = '4.3.0-SNAPSHOT' - archiveName = baseName + '-' + version + '.jar' + archiveVersion = '4.3.0-SNAPSHOT' + archiveFileName = "${archiveBaseName}-${archiveVersion}.jar" manifest { - attributes 'Manifest-Version': "$jar.version" + attributes 'Manifest-Version': "$jar.archiveVersion" } } @@ -111,7 +111,7 @@ if (!project.hasProperty("android")) { jacocoTestReport { reports { - xml.enabled true + xml.required = true } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c684f..b93c46a5f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From e7e4920b30d8657b2110fde1423637d5597b99c3 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 13:49:47 +0100 Subject: [PATCH 06/20] re-set `build.gradle` to before kotlin-for-jvm, isolating upgrade of gradle --- build.gradle | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index ee0a9b0dc..44b11bb3c 100644 --- a/build.gradle +++ b/build.gradle @@ -13,16 +13,12 @@ buildscript { } } -plugins { - id 'org.jetbrains.kotlin.jvm' version '1.8.0' -} - /** * If `android` is true, the project will be configured as an Android rather than a Java library. This isn't used * for building archives (such as an APK), but is useful for performing Android checks like lint. */ if (!project.hasProperty("android")) { -// apply plugin: 'java' + apply plugin: 'java' apply plugin: 'checkstyle' apply plugin: 'jacoco' apply plugin: 'me.champeau.jmh' @@ -52,15 +48,6 @@ compileTestJava { options.compilerArgs << "-Xlint:deprecation" } -compileKotlin { - kotlinOptions.jvmTarget = '1.8' -} - -compileTestKotlin { - kotlinOptions.jvmTarget = '1.8' -} - - targetCompatibility = '1.8' sourceCompatibility = '1.8' @@ -187,4 +174,4 @@ dependencies { testImplementation 'junit:junit:4.13.2' testImplementation 'net.sf.kxml:kxml2:2.3.0' testImplementation 'org.hamcrest:hamcrest-all:1.3' -} +} \ No newline at end of file From d0084e41afa555b206a9741eca6081ed3073f6d4 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 14:26:44 +0100 Subject: [PATCH 07/20] upgrade version of `com.android.tools.build:gradle` from 7.2.1 to 8.1.0; update `TargetSdkVersion` from 30 to 31, as required by Google Play (minSDK still at 21) --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 44b11bb3c..3bdeb8b53 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.1.0' classpath "me.champeau.jmh:jmh-gradle-plugin:0.6.7" } } @@ -133,10 +133,10 @@ if (!project.hasProperty("android")) { android { namespace 'com.example' - compileSdkVersion 30 + compileSdkVersion 31 defaultConfig { minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From a5127df6a49fca769aa771289a8cac7de81ee69d Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 17:24:01 +0100 Subject: [PATCH 08/20] upgrading CircleCI docker android and jdk images to use Java17, as needed by android gradle plugin --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a3411de30..615aee5a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,13 +11,13 @@ references: android_config: &android_config working_directory: *workspace docker: - - image: cimg/android:2022.09.1 + - image: cimg/android:2023.08.1 jobs: build: working_directory: ~/work docker: - - image: circleci/openjdk:8-jdk + - image: circleci/openjdk:17-jdk steps: - checkout - restore_cache: From 16970d8c3570edef9be6ce749cad7848ed28284a Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 17:40:10 +0100 Subject: [PATCH 09/20] tweaking CircleCI docker jdk image to use Java17; --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 615aee5a4..56bfaa623 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: build: working_directory: ~/work docker: - - image: circleci/openjdk:17-jdk + - image: circleci/openjdk:17.0-jdk steps: - checkout - restore_cache: From e25ed0077cf35e73c2312bf75d115c80a7a7ce38 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 17:42:12 +0100 Subject: [PATCH 10/20] tweaking CircleCI docker jdk image to use Java17; --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 56bfaa623..f8008b929 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: build: working_directory: ~/work docker: - - image: circleci/openjdk:17.0-jdk + - image: cimg/openjdk:17.0-jdk steps: - checkout - restore_cache: From 3ac3968172364f8630e77c5ff758903909d2591c Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Mon, 7 Aug 2023 17:43:43 +0100 Subject: [PATCH 11/20] tweaking CircleCI docker jdk image to use Java17; --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f8008b929..0d3f18267 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: build: working_directory: ~/work docker: - - image: cimg/openjdk:17.0-jdk + - image: cimg/openjdk:17.0 steps: - checkout - restore_cache: From eb71dddf9676e2abc1f2d20863a758729f09195a Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 12:35:42 +0100 Subject: [PATCH 12/20] [TEMP-NOT FOR PROD] remove "android" build; temporarily create a task for CircleCI to call whilst setting up the replacement android lint task. Necessary because gradle does not support targeting kotlin at both android and the jvm in the same build, so to introduce `com.android.lint`, the `com.android.library` plugin must be removed. --- build.gradle | 134 ++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 76 deletions(-) diff --git a/build.gradle b/build.gradle index 3bdeb8b53..99f1e7807 100644 --- a/build.gradle +++ b/build.gradle @@ -17,14 +17,10 @@ buildscript { * If `android` is true, the project will be configured as an Android rather than a Java library. This isn't used * for building archives (such as an APK), but is useful for performing Android checks like lint. */ -if (!project.hasProperty("android")) { - apply plugin: 'java' - apply plugin: 'checkstyle' - apply plugin: 'jacoco' - apply plugin: 'me.champeau.jmh' -} else { - apply plugin: 'com.android.library' -} +apply plugin: 'java' +apply plugin: 'checkstyle' +apply plugin: 'jacoco' +apply plugin: 'me.champeau.jmh' repositories { google() @@ -77,81 +73,56 @@ tasks.register('installLocal') { } } -if (!project.hasProperty("android")) { - jar { - archiveBaseName = 'javarosa' - // Be sure to update version in pom.xml to match - // snapshot release = x.x.x-SNAPSHOT - // production release = x.x.x - archiveVersion = '4.3.0-SNAPSHOT' - archiveFileName = "${archiveBaseName}-${archiveVersion}.jar" - - manifest { - attributes 'Manifest-Version': "$jar.archiveVersion" - } - } +jar { + archiveBaseName = 'javarosa' + // Be sure to update version in pom.xml to match + // snapshot release = x.x.x-SNAPSHOT + // production release = x.x.x + archiveVersion = '4.3.0-SNAPSHOT' + archiveFileName = "${archiveBaseName}-${archiveVersion}.jar" - // TODO: does not build UML diagrams - javadoc { - failOnError = false + manifest { + attributes 'Manifest-Version': "$jar.archiveVersion" } +} - jacocoTestReport { - reports { - xml.required = true - } +// TODO: does not build UML diagrams +javadoc { + failOnError = false +} + +jacocoTestReport { + reports { + xml.required = true } +} // Required to use fileExtensions property in checkstyle file - checkstyle { - toolVersion = '7.6.1' - } +checkstyle { + toolVersion = '7.6.1' +} - jmhJar.doFirst { - new File("build/resources/test").mkdirs() - } +jmhJar.doFirst { + new File("build/resources/test").mkdirs() +} - jmh { - excludes = ["(BenchmarkTemplate)"] - threads = 1 - fork = 1 - warmup = '2s' - warmupIterations = 10 - warmupBatchSize = 1 - warmupForks = 1 - iterations = 20 - timeOnIteration = '2s' - timeUnit = 's' - benchmarkMode = ['avgt', 'ss'] - includeTests = true - resultFormat = 'CSV' - forceGC = true - - duplicateClassesStrategy = DuplicatesStrategy.WARN - } -} else { - android { - namespace 'com.example' - - compileSdkVersion 31 - defaultConfig { - minSdkVersion 21 - targetSdkVersion 31 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - coreLibraryDesugaringEnabled true - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - buildTypes { - release { - minifyEnabled false - } - } - } +jmh { + excludes = ["(BenchmarkTemplate)"] + threads = 1 + fork = 1 + warmup = '2s' + warmupIterations = 10 + warmupBatchSize = 1 + warmupForks = 1 + iterations = 20 + timeOnIteration = '2s' + timeUnit = 's' + benchmarkMode = ['avgt', 'ss'] + includeTests = true + resultFormat = 'CSV' + forceGC = true + + duplicateClassesStrategy = DuplicatesStrategy.WARN } dependencies { @@ -174,4 +145,15 @@ dependencies { testImplementation 'junit:junit:4.13.2' testImplementation 'net.sf.kxml:kxml2:2.3.0' testImplementation 'org.hamcrest:hamcrest-all:1.3' -} \ No newline at end of file +} + + +abstract class lintDebug extends DefaultTask { + @TaskAction + def analyseLint() { + println 'THIS IS NOT THE TASK YOU WANT. LOOK AT ../reports/lint-results.html' + } +} + +// Temporary target so as not to break the CircleCI build. This task will be superseded by the 'lint' task in the main build. +tasks.register('lintDebug', lintDebug) \ No newline at end of file From 5cc4ad70ff6bc0e149635f1be2a781ea89957e7e Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 13:08:06 +0100 Subject: [PATCH 13/20] Debug info for test only failing on circleCI --- .../org/javarosa/core/model/utils/test/LocalizerTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/javarosa/core/model/utils/test/LocalizerTest.java b/src/test/java/org/javarosa/core/model/utils/test/LocalizerTest.java index 43ad40185..e74e135a7 100644 --- a/src/test/java/org/javarosa/core/model/utils/test/LocalizerTest.java +++ b/src/test/java/org/javarosa/core/model/utils/test/LocalizerTest.java @@ -853,10 +853,11 @@ private void runAsync(Runnable test) { try { t.join(50); } catch (InterruptedException e) { - + System.out.println("t.getState() = " + t.getState()); } + //DEBUG on circleci if(t.isAlive()) { - throw new RuntimeException("Failed to return from recursive argument processing"); + throw new RuntimeException("Failed to return from recursive argument processing"+ "\nThreadState: "+t.getState()); } } From b8c2b4065df82a4a76154f5e791709bf9c19b113 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 13:52:58 +0100 Subject: [PATCH 14/20] Target `com.android.lint` for Android compatibility checking without running a separate build targeted at Android bytecode --- .circleci/config.yml | 2 +- build.gradle | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d3f18267..094394e79 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,7 +48,7 @@ jobs: name: Android Lint command: ./gradlew -Pandroid lintDebug --max-workers=1 - store_artifacts: - path: build/reports/lint-results-debug.html + path: build/reports/lint-results.html destination: lint-results.html package: working_directory: ~/work diff --git a/build.gradle b/build.gradle index 99f1e7807..8d8641176 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,7 @@ buildscript { + ext{ + kotlinVersion = "1.8.22" + } repositories { google() mavenCentral() @@ -8,19 +11,21 @@ buildscript { } dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22" classpath 'com.android.tools.build:gradle:8.1.0' classpath "me.champeau.jmh:jmh-gradle-plugin:0.6.7" } } -/** - * If `android` is true, the project will be configured as an Android rather than a Java library. This isn't used - * for building archives (such as an APK), but is useful for performing Android checks like lint. - */ +plugins { + id 'org.jetbrains.kotlin.jvm' version '1.8.22' +} + apply plugin: 'java' apply plugin: 'checkstyle' apply plugin: 'jacoco' apply plugin: 'me.champeau.jmh' +apply plugin: 'com.android.lint' repositories { google() @@ -33,19 +38,35 @@ sourceSets { test.java.srcDirs = ['src/test/java'] test.resources.srcDirs = ['src/test/resources'] } -compileJava.options.encoding = "UTF-8" -compileTestJava.options.encoding = "UTF-8" - +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} compileJava { options.compilerArgs << "-Xlint:deprecation" + options.encoding = 'UTF-8' } compileTestJava { options.compilerArgs << "-Xlint:deprecation" + options.encoding = 'UTF-8' } -targetCompatibility = '1.8' -sourceCompatibility = '1.8' +compileKotlin { + kotlinOptions.jvmTarget = '1.8' +} + +compileTestKotlin { + kotlinOptions.jvmTarget = '1.8' +} + +lint { + htmlReport = true + abortOnError = true + warningsAsErrors = false + checkDependencies = true +} tasks.register('installLocal') { def lines = [] @@ -137,7 +158,7 @@ dependencies { // Upgrade to version higher than 2.5 when Collect minSDK >= 26 implementation 'commons-io:commons-io:2.5' - implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10' + implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22' compileOnly 'net.sf.kxml:kxml2:2.3.0' @@ -151,7 +172,7 @@ dependencies { abstract class lintDebug extends DefaultTask { @TaskAction def analyseLint() { - println 'THIS IS NOT THE TASK YOU WANT. LOOK AT ../reports/lint-results.html' + println 'THIS IS NOT THE TASK YOU WANT. LOOK AT ../build/reports/lint-results.html' } } From 9aaccbd8118df5e7bcbe87db3a3e34bd557f89b3 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 15:09:10 +0100 Subject: [PATCH 15/20] updated jmh plugin; added jvm toolchain resolver in `settings.gradle` --- build.gradle | 6 ++++-- settings.gradle | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 8d8641176..e32f864e8 100644 --- a/build.gradle +++ b/build.gradle @@ -13,18 +13,18 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22" classpath 'com.android.tools.build:gradle:8.1.0' - classpath "me.champeau.jmh:jmh-gradle-plugin:0.6.7" + classpath "me.champeau.jmh:jmh-gradle-plugin:0.7.1" } } plugins { id 'org.jetbrains.kotlin.jvm' version '1.8.22' + id "me.champeau.jmh" version "0.7.1" } apply plugin: 'java' apply plugin: 'checkstyle' apply plugin: 'jacoco' -apply plugin: 'me.champeau.jmh' apply plugin: 'com.android.lint' repositories { @@ -38,6 +38,8 @@ sourceSets { test.java.srcDirs = ['src/test/java'] test.resources.srcDirs = ['src/test/resources'] } +sourceCompatibility = 1.8 +targetCompatibility = 1.8 java { toolchain { languageVersion = JavaLanguageVersion.of(8) diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..965a0615b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,3 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" +} \ No newline at end of file From ffbf6ddbe7c641ad9d57c8964d550898728255fa Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 16:25:44 +0100 Subject: [PATCH 16/20] remove `lintDebug` task from circleCI yaml file. Superseded by lint task in build --- .circleci/config.yml | 25 ------------------------- build.gradle | 15 ++------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 094394e79..c95ebbe2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,18 +1,5 @@ version: 2 -references: - accept_licenses : &accept_licenses - run: - name: Accept licenses - command: yes | sdkmanager --licenses || true - workspace: &workspace - ~/work - - android_config: &android_config - working_directory: *workspace - docker: - - image: cimg/android:2023.08.1 - jobs: build: working_directory: ~/work @@ -39,17 +26,6 @@ jobs: destination: libs - store_test_results: path: build/test-results - check-android-api-level: - <<: *android_config - steps: - - checkout - - *accept_licenses - - run: - name: Android Lint - command: ./gradlew -Pandroid lintDebug --max-workers=1 - - store_artifacts: - path: build/reports/lint-results.html - destination: lint-results.html package: working_directory: ~/work docker: @@ -76,5 +52,4 @@ workflows: build_and_package: jobs: - build - - check-android-api-level - package diff --git a/build.gradle b/build.gradle index e32f864e8..18ac3fc61 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ plugins { id "me.champeau.jmh" version "0.7.1" } -apply plugin: 'java' +apply plugin: 'java-library' apply plugin: 'checkstyle' apply plugin: 'jacoco' apply plugin: 'com.android.lint' @@ -105,7 +105,7 @@ jar { archiveFileName = "${archiveBaseName}-${archiveVersion}.jar" manifest { - attributes 'Manifest-Version': "$jar.archiveVersion" + attributes 'Manifest-Version': '$jar.archiveVersion' } } @@ -169,14 +169,3 @@ dependencies { testImplementation 'net.sf.kxml:kxml2:2.3.0' testImplementation 'org.hamcrest:hamcrest-all:1.3' } - - -abstract class lintDebug extends DefaultTask { - @TaskAction - def analyseLint() { - println 'THIS IS NOT THE TASK YOU WANT. LOOK AT ../build/reports/lint-results.html' - } -} - -// Temporary target so as not to break the CircleCI build. This task will be superseded by the 'lint' task in the main build. -tasks.register('lintDebug', lintDebug) \ No newline at end of file From db57299129d882a4c876b56c5fc5b1b8122e14c5 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 17:24:01 +0100 Subject: [PATCH 17/20] consistent formatting and use of quotation marks --- build.gradle | 14 ++++++++------ settings.gradle | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 18ac3fc61..486e1914a 100644 --- a/build.gradle +++ b/build.gradle @@ -18,13 +18,13 @@ buildscript { } plugins { + id 'java-library' id 'org.jetbrains.kotlin.jvm' version '1.8.22' - id "me.champeau.jmh" version "0.7.1" + id 'me.champeau.jmh' version '0.7.1' + id 'jacoco' + id 'checkstyle' } -apply plugin: 'java-library' -apply plugin: 'checkstyle' -apply plugin: 'jacoco' apply plugin: 'com.android.lint' repositories { @@ -38,13 +38,16 @@ sourceSets { test.java.srcDirs = ['src/test/java'] test.resources.srcDirs = ['src/test/resources'] } + sourceCompatibility = 1.8 targetCompatibility = 1.8 + java { toolchain { languageVersion = JavaLanguageVersion.of(8) } } + compileJava { options.compilerArgs << "-Xlint:deprecation" options.encoding = 'UTF-8' @@ -150,17 +153,16 @@ jmh { dependencies { // Be sure to update dependencies in pom.xml to match + implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22' implementation 'joda-time:joda-time:2.10.13' implementation 'org.slf4j:slf4j-api:1.7.33' implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.1' // Upgrade to version higher than 1.4 when Collect minSDK >= 26 implementation 'org.apache.commons:commons-csv:1.4' - // Upgrade to version higher than 2.5 when Collect minSDK >= 26 implementation 'commons-io:commons-io:2.5' - implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22' compileOnly 'net.sf.kxml:kxml2:2.3.0' diff --git a/settings.gradle b/settings.gradle index 965a0615b..7c02b9ffa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" + id 'org.gradle.toolchains.foojay-resolver-convention' version "0.6.0" } \ No newline at end of file From 68e50d3b6e422b893965d28fe7a8d16971d78ce4 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 18:31:17 +0100 Subject: [PATCH 18/20] update the `jar` task to fix name of artefact to `javarosa-4.3.0-SNAPSHOT.jar` and the attributes in the manifest. --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 486e1914a..c91ce3fe7 100644 --- a/build.gradle +++ b/build.gradle @@ -105,10 +105,9 @@ jar { // snapshot release = x.x.x-SNAPSHOT // production release = x.x.x archiveVersion = '4.3.0-SNAPSHOT' - archiveFileName = "${archiveBaseName}-${archiveVersion}.jar" manifest { - attributes 'Manifest-Version': '$jar.archiveVersion' + attributes 'Manifest-Version': archiveVersion } } From af68af036b9213bb94948108cf16d21811974443 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 19:00:41 +0100 Subject: [PATCH 19/20] Intentionally failing build to show that Lint checks do fail the build if they don't pass. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c91ce3fe7..5d37eccf2 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ compileTestKotlin { lint { htmlReport = true abortOnError = true - warningsAsErrors = false + warningsAsErrors = true checkDependencies = true } From 7064f6bb0e2f557990974a0cfb4b5be44305eeb4 Mon Sep 17 00:00:00 2001 From: Jack Bolles Date: Wed, 9 Aug 2023 19:02:07 +0100 Subject: [PATCH 20/20] Reverting intentional failure demonstration --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5d37eccf2..c91ce3fe7 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ compileTestKotlin { lint { htmlReport = true abortOnError = true - warningsAsErrors = true + warningsAsErrors = false checkDependencies = true }