-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR build kotlin #725
base: master
Are you sure you want to change the base?
PR build kotlin #725
Changes from all commits
fccfe24
0efd26d
6d860e2
bb341d1
bfbd2d1
e7e4920
d0084e4
a5127df
16970d8
e25ed00
3ac3968
eb71ddd
5cc4ad7
b8c2b40
9aaccbd
ffbf6dd
db57299
68e50d3
af68af0
7064f6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
buildscript { | ||
ext{ | ||
kotlinVersion = "1.8.22" | ||
} | ||
repositories { | ||
google() | ||
mavenCentral() | ||
|
@@ -8,24 +11,22 @@ buildscript { | |
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:7.2.1' | ||
classpath "me.champeau.jmh:jmh-gradle-plugin:0.6.7" | ||
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.7.1" | ||
} | ||
} | ||
|
||
/** | ||
* 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' | ||
plugins { | ||
id 'java-library' | ||
id 'org.jetbrains.kotlin.jvm' version '1.8.22' | ||
id 'me.champeau.jmh' version '0.7.1' | ||
id 'jacoco' | ||
id 'checkstyle' | ||
} | ||
|
||
apply plugin: 'com.android.lint' | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
|
@@ -37,19 +38,40 @@ sourceSets { | |
test.java.srcDirs = ['src/test/java'] | ||
test.resources.srcDirs = ['src/test/resources'] | ||
} | ||
compileJava.options.encoding = "UTF-8" | ||
compileTestJava.options.encoding = "UTF-8" | ||
|
||
sourceCompatibility = 1.8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to confirm this for myself, but I think (and a bunch of the other Java 8 configs in this file) this can be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I defer to your Android knowledge. I erred on the side of caution. LMK what to set it to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you talking about increasing both the sourceCompatibility and the toolchain language version? That would allow for newer features of the language to be used in the code (sourceCompatibility without toolchain would mean use a newer jdk to build but abstain from using newer syntax in the library code) At least that's how I understand it all. I am not familiar with how ODK javarosa works TBH. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. The main client for JavaRosa (https://github.com/getodk/collect) already uses Java 17, so I think we're ok to make the bump. I think you're pointing out here that that would mean incompatibility with other projects that are using an older Java toolchain though - that's something we'd need to update in the
I'm pretty sure that |
||
targetCompatibility = 1.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' | ||
} | ||
|
||
compileKotlin { | ||
kotlinOptions.jvmTarget = '1.8' | ||
} | ||
|
||
compileTestKotlin { | ||
kotlinOptions.jvmTarget = '1.8' | ||
} | ||
|
||
targetCompatibility = '1.8' | ||
sourceCompatibility = '1.8' | ||
lint { | ||
htmlReport = true | ||
abortOnError = true | ||
warningsAsErrors = false | ||
checkDependencies = true | ||
} | ||
|
||
tasks.register('installLocal') { | ||
def lines = [] | ||
|
@@ -77,96 +99,69 @@ tasks.register('installLocal') { | |
} | ||
} | ||
|
||
if (!project.hasProperty("android")) { | ||
jar { | ||
baseName = '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' | ||
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' | ||
|
||
manifest { | ||
attributes 'Manifest-Version': "$jar.version" | ||
} | ||
manifest { | ||
attributes 'Manifest-Version': archiveVersion | ||
} | ||
} | ||
|
||
// TODO: does not build UML diagrams | ||
javadoc { | ||
failOnError = false | ||
} | ||
// TODO: does not build UML diagrams | ||
javadoc { | ||
failOnError = false | ||
} | ||
|
||
jacocoTestReport { | ||
reports { | ||
xml.enabled true | ||
} | ||
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 30 | ||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 30 | ||
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 { | ||
// 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.6.10' | ||
|
||
compileOnly 'net.sf.kxml:kxml2:2.3.0' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
id 'org.gradle.toolchains.foojay-resolver-convention' version "0.6.0" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.javarosa.kotlintest | ||
|
||
enum class ThisOrThat { | ||
THIS(), THAT(), OTHER() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this not just be in the
plugins
block above?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work if I do. Gradle complains with
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.lint'] was not found in any of the following sources: