Skip to content

Commit 9f03364

Browse files
authored
Update to Kotlin 1.5 (#210)
* Update to Kotlin 1.5 * Fix jacoco merge task
1 parent fea5956 commit 9f03364

File tree

8 files changed

+40
-83
lines changed

8 files changed

+40
-83
lines changed

build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: "com.github.ben-manes.versions"
33

44
buildscript {
55
ext {
6-
kotlinVersion = '1.4.32'
6+
kotlinVersion = '1.5.10'
77

88
versions = [:]
99
libraries = [:]
@@ -22,10 +22,9 @@ buildscript {
2222
}
2323

2424
dependencies {
25-
classpath 'com.android.tools.build:gradle:4.1.3'
25+
classpath 'com.android.tools.build:gradle:4.2.1'
2626
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2727
classpath "com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0"
28-
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
2928
classpath "com.github.ben-manes:gradle-versions-plugin:0.28.0"
3029
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.18"
3130
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18"

formula-android/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'com.github.dcendents.android-maven'
32
apply plugin: 'kotlin-android'
43
apply plugin: 'kotlin-kapt'
54
apply plugin: "com.github.ben-manes.versions"

gradle/merge-reports.gradle

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1+
subprojects { project ->
2+
if (!project.name.contains("formula")) {
3+
return
4+
}
5+
6+
project.plugins.withId("com.android.application") {
7+
disableHtmlTestReport(project)
8+
}
9+
10+
project.plugins.withId("com.android.library") {
11+
disableHtmlTestReport(project)
12+
}
13+
}
14+
115
// make sure this project depends on the evaluation of all sub projects so that
216
// it's evaluated last.
317
project.evaluationDependsOnChildren()
418

519
afterEvaluate {
20+
621
def testTasks = subprojects.findAll { it.name.contains("formula") }.collect { it.tasks.withType(Test) }.flatten()
722
if (testTasks.isEmpty()) {
823
throw IllegalStateException("misconfiguration: no test tasks found")
924
}
1025

1126
task mergeReports(type: Copy) {
12-
from { testTasks*.reports.junitXml.destination }
27+
from { testTasks*.reports.junitXml.destination } {
28+
exclude("**/binary/*")
29+
}
1330
into { file("$buildDir/reports/allTests") }
1431

1532
doLast {
@@ -18,20 +35,12 @@ afterEvaluate {
1835
}
1936
}
2037

21-
subprojects {
22-
if (!name.contains("formula")) {
23-
return
24-
}
25-
26-
afterEvaluate {
27-
if (plugins.hasPlugin("com.android.application") || plugins.hasPlugin("com.android.library")) {
28-
android {
29-
testOptions {
30-
unitTests.all {
31-
reports.html.enabled = false
32-
}
33-
}
38+
def disableHtmlTestReport(Project project) {
39+
project.android {
40+
testOptions {
41+
unitTests.all {
42+
reports.html.enabled = false
3443
}
3544
}
3645
}
37-
}
46+
}

gradle/wrapper/gradle-wrapper.jar

508 Bytes
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ esac
8282

8383
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
8484

85+
8586
# Determine the Java command to use to start the JVM.
8687
if [ -n "$JAVA_HOME" ] ; then
8788
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
129130
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
132134
JAVACMD=`cygpath --unix "$JAVACMD"`
133135

134136
# We build the pattern for arguments to be converted via cygpath

gradlew.bat

+7-18
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
3235
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
3336
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
3437

@@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
3740

3841
set JAVA_EXE=java.exe
3942
%JAVA_EXE% -version >NUL 2>&1
40-
if "%ERRORLEVEL%" == "0" goto init
43+
if "%ERRORLEVEL%" == "0" goto execute
4144

4245
echo.
4346
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +54,7 @@ goto fail
5154
set JAVA_HOME=%JAVA_HOME:"=%
5255
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5356

54-
if exist "%JAVA_EXE%" goto init
57+
if exist "%JAVA_EXE%" goto execute
5558

5659
echo.
5760
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,28 +64,14 @@ echo location of your Java installation.
6164

6265
goto fail
6366

64-
:init
65-
@rem Get command-line arguments, handling Windows variants
66-
67-
if not "%OS%" == "Windows_NT" goto win9xME_args
68-
69-
:win9xME_args
70-
@rem Slurp the command line arguments.
71-
set CMD_LINE_ARGS=
72-
set _SKIP=2
73-
74-
:win9xME_args_slurp
75-
if "x%~1" == "x" goto execute
76-
77-
set CMD_LINE_ARGS=%*
78-
7967
:execute
8068
@rem Setup the command line
8169

8270
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
8371

72+
8473
@rem Execute Gradle
85-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
8675

8776
:end
8877
@rem End local scope for the variables with windows NT shell

samples/stopwatch-compose/build.gradle

+4-45
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,6 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: "kotlin-parcelize"
44

5-
// Create a configuration which allows us to intercept the JARs, and add them to
6-
// Kotlin Compiler freeCompilerArgs. This is needed because we can't currently use the
7-
// built-in `compose` feature in AGP, since it depends on the old Compose Compiler artifacts.
8-
// TODO: Remove this once AGP uses the new Compose Compiler artifact name
9-
def compilerPluginConfig = project.configurations.create("kotlinCompilerPlugin")
10-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { compile ->
11-
kotlinOptions {
12-
// Treat all Kotlin warnings as errors
13-
allWarningsAsErrors = true
14-
15-
// Set JVM target to 1.8
16-
jvmTarget = "1.8"
17-
18-
// Allow use of @OptIn
19-
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
20-
21-
freeCompilerArgs += "-Xallow-jvm-ir-dependencies"
22-
// Turn on JVM default methods
23-
freeCompilerArgs += "-Xjvm-default=all"
24-
}
25-
26-
compile.dependsOn(compilerPluginConfig)
27-
compile.doFirst {
28-
if (!compilerPluginConfig.isEmpty()) {
29-
// Add the compiler plugin JARs using the -Xplugin flag
30-
compile.kotlinOptions.freeCompilerArgs +=
31-
"-Xplugin=${compilerPluginConfig.files.first()}"
32-
// Need to turn on the IR compiler too
33-
compile.kotlinOptions.useIR = true
34-
}
35-
}
36-
}
37-
385
android {
396
compileSdkVersion constants.compileSdk
407

@@ -48,13 +15,7 @@ android {
4815
}
4916

5017
buildFeatures {
51-
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
52-
// Compose compiler artifact has changed artifact group/name.
53-
// Instead we add the compiler manually below in the dependencies {}. Also see
54-
// the root build.gradle for info on how to apply the plugin.
55-
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details
56-
57-
// compose true
18+
compose true
5819
}
5920

6021
// Set both the Java and Kotlin compilers to target Java 8.
@@ -69,8 +30,8 @@ android {
6930
}
7031

7132
composeOptions {
72-
kotlinCompilerVersion "1.4.32"
73-
kotlinCompilerExtensionVersion "1.0.0-beta04"
33+
kotlinCompilerVersion "1.5.10"
34+
kotlinCompilerExtensionVersion "1.0.0-beta08"
7435
}
7536

7637
buildTypes {
@@ -95,9 +56,7 @@ dependencies {
9556
implementation libraries.rxrelays
9657
implementation libraries.rxandroid
9758

98-
def composeVersion = "1.0.0-beta04"
99-
// Temporary workaround (see above)
100-
kotlinCompilerPlugin "androidx.compose.compiler:compiler:$composeVersion"
59+
def composeVersion = "1.0.0-beta08"
10160

10261
// You also need to include the following Compose toolkit dependencies.
10362
implementation "androidx.compose.ui:ui:$composeVersion"

0 commit comments

Comments
 (0)