Skip to content

Commit 527d507

Browse files
pavlosptRolf-Smit
authored andcommitted
Update dependencies (#4)
* Update Kotlin to 1.3.11 * Update Gradle to 5.1.1 * Update Android Gradle Plugin to 3.3.0 * Update RootCoveragePlugin for Gradle 5+ changes
1 parent 41a8486 commit 527d507

File tree

6 files changed

+40
-121
lines changed

6 files changed

+40
-121
lines changed

gradle/dependencies.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ ext {
44
targetSdk : 28,
55
compileSdk : 28,
66
// Kotlin version is used in multiple places hence it is available as version variable
7-
kotlin : "1.2.71"
7+
kotlin : "1.3.11"
88
]
99
projectDependency = [
1010

1111
// Gradle Plugins
1212
kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${projectVersion.kotlin}",
13-
gradlePlugin : "com.android.tools.build:gradle:3.2.1",
13+
gradlePlugin : "com.android.tools.build:gradle:3.3.0",
1414

1515
// Dependencies
1616
kotlinStdlibJdk7 : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${projectVersion.kotlin}",
@@ -28,4 +28,4 @@ ext {
2828
"org.jetbrains.kotlin.android": "${projectVersion.kotlin}",
2929
"org.jetbrains.kotlin.jvm": "${projectVersion.kotlin}"
3030
]
31-
}
31+
}

gradle/wrapper/gradle-wrapper.jar

1.8 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
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-4.10-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

100644100755
File mode changed.

gradlew.bat

Lines changed: 0 additions & 84 deletions
This file was deleted.

plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -177,41 +177,44 @@ class RootCoveragePlugin : Plugin<Project> {
177177

178178
val name = variant.name.capitalize()
179179

180-
val task = project.tasks.create("codeCoverageReport$name", RootCoverageModuleTask::class.java)
181-
task.group = null // null makes sure the group does not show in the gradle-view in Android Studio/Intellij
182-
task.description = "Generate unified Jacoco code codecoverage report"
183-
184-
if (!rootProjectExtension.skipTestExecution) {
185-
if (rootProjectExtension.testTypes.contains(TestVariantBuildOutput.TestType.UNIT)) {
186-
task.dependsOn("test${name}UnitTest")
187-
}
188-
if (rootProjectExtension.testTypes.contains(TestVariantBuildOutput.TestType.ANDROID_TEST)) {
189-
task.dependsOn("connected${name}AndroidTest")
180+
val codeCoverageReportTask = project.tasks.register("codeCoverageReport$name", RootCoverageModuleTask::class.java)
181+
codeCoverageReportTask.configure { task ->
182+
task.group = null // null makes sure the group does not show in the gradle-view in Android Studio/Intellij
183+
task.description = "Generate unified Jacoco code codecoverage report"
184+
185+
if (!rootProjectExtension.skipTestExecution) {
186+
if (rootProjectExtension.testTypes.contains(TestVariantBuildOutput.TestType.UNIT)) {
187+
task.dependsOn("test${name}UnitTest")
188+
}
189+
if (rootProjectExtension.testTypes.contains(TestVariantBuildOutput.TestType.ANDROID_TEST)) {
190+
task.dependsOn("connected${name}AndroidTest")
191+
}
190192
}
191-
}
192193

193-
// Collect the class files based on the Java Compiler output
194-
val javaClassTrees = variant.javaCompiler.outputs.files.map { file ->
195-
project.fileTree(file, excludes = getFileFilterPatterns()).excludeNonClassFiles()
196-
}
197-
// Hard coded alternative to get class files for Java.
198-
//val classesTree = project.fileTree(mapOf("dir" to "${project.buildDir}/intermediates/classes/${variant.dirName}", "excludes" to getFileFilterPatterns()))
194+
// Collect the class files based on the Java Compiler output
195+
val javaClassOutputs = variant.javaCompileProvider.get().outputs
196+
val javaClassTrees = javaClassOutputs.files.map { file ->
197+
project.fileTree(file, excludes = getFileFilterPatterns()).excludeNonClassFiles()
198+
}
199+
// Hard coded alternative to get class files for Java.
200+
//val classesTree = project.fileTree(mapOf("dir" to "${project.buildDir}/intermediates/classes/${variant.dirName}", "excludes" to getFileFilterPatterns()))
199201

200-
// TODO: No idea how to dynamically get the kotlin class files output folder, so for now this is hardcoded.
201-
// TODO: For some reason the tmp/kotlin-classes folder does not use the variant.dirName property, for now we instead use the variant.name.
202-
val kotlinClassFolder = "${project.buildDir}/tmp/kotlin-classes/${variant.name}"
203-
project.logger.info("Kotlin class folder for variant '${variant.name}': $kotlinClassFolder")
202+
// TODO: No idea how to dynamically get the kotlin class files output folder, so for now this is hardcoded.
203+
// TODO: For some reason the tmp/kotlin-classes folder does not use the variant.dirName property, for now we instead use the variant.name.
204+
val kotlinClassFolder = "${project.buildDir}/tmp/kotlin-classes/${variant.name}"
205+
project.logger.info("Kotlin class folder for variant '${variant.name}': $kotlinClassFolder")
204206

205-
val kotlinClassTree = project.fileTree(kotlinClassFolder, excludes = getFileFilterPatterns()).excludeNonClassFiles()
207+
val kotlinClassTree = project.fileTree(kotlinClassFolder, excludes = getFileFilterPatterns()).excludeNonClassFiles()
206208

207-
// getSourceFolders returns ConfigurableFileCollections, but we only need the base directory of each ConfigurableFileCollection.
208-
val sourceFiles = variant.getSourceFolders(SourceKind.JAVA).map { file -> file.dir }
209+
// getSourceFolders returns ConfigurableFileCollections, but we only need the base directory of each ConfigurableFileCollection.
210+
val sourceFiles = variant.getSourceFolders(SourceKind.JAVA).map { file -> file.dir }
209211

210-
task.sourceDirectories = project.files(sourceFiles)
211-
task.classDirectories = project.files(javaClassTrees, kotlinClassTree)
212-
task.executionData = project.fileTree(project.buildDir, includes = getExecutionDataFilePatterns())
212+
task.sourceDirectories = project.files(sourceFiles)
213+
task.classDirectories = project.files(javaClassTrees, kotlinClassTree)
214+
task.executionData = project.fileTree(project.buildDir, includes = getExecutionDataFilePatterns())
215+
}
213216

214-
return task
217+
return codeCoverageReportTask.get()
215218
}
216219

217220
private fun addSubTaskDependencyToRootTask(rootTask: JacocoReport, subModuleTask: RootCoverageModuleTask) {
@@ -221,19 +224,19 @@ class RootCoveragePlugin : Plugin<Project> {
221224

222225
// Set or add the sub-task class directories to the root task
223226
if (rootTask.classDirectories == null) {
224-
rootTask.classDirectories = subModuleTask.classDirectories
227+
rootTask.classDirectories.setFrom(subModuleTask.classDirectories)
225228
} else {
226-
rootTask.classDirectories += subModuleTask.classDirectories
229+
rootTask.additionalClassDirs(subModuleTask.classDirectories)
227230
}
228231

229232
// Set or add the sub-task source directories to the root task
230233
if (rootTask.sourceDirectories == null) {
231-
rootTask.sourceDirectories = subModuleTask.sourceDirectories
234+
rootTask.sourceDirectories.setFrom(subModuleTask.sourceDirectories)
232235
} else {
233-
rootTask.sourceDirectories += subModuleTask.sourceDirectories
236+
rootTask.additionalSourceDirs(subModuleTask.sourceDirectories)
234237
}
235238

236239
// Add the sub-task class directories to the root task
237240
rootTask.executionData(subModuleTask.executionData)
238241
}
239-
}
242+
}

0 commit comments

Comments
 (0)