From a44d0e94726610b2247b5bac02706e1de7e6d105 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 21:02:00 +0400 Subject: [PATCH 1/8] Android timings. --- kobalt-incremental-tasks.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kobalt-incremental-tasks.md b/kobalt-incremental-tasks.md index fee39a9a..25157d82 100644 --- a/kobalt-incremental-tasks.md +++ b/kobalt-incremental-tasks.md @@ -46,7 +46,7 @@ Another advantage of checksums is that they are generic and not necessarily tied Internally, Kobalt maintains information about all the checksums and tasks that it has seen in a file `.kobalt/build-info.json`. Whenever an incremental task is about to run, Kobalt compares its input and output checksums to the ones from the previous run and if any differs, that task is run. Otherwise, it's skipped. -Example timings: +Example timings for Kobalt: | Task | First run | Second run | | ---- | --------- | ---------- | @@ -58,6 +58,20 @@ Example timings: | kobalt:assemble | 42333 ms | 2130 ms | | | 70 seconds | 2 seconds | +Android (u2020): + +| Task | First run | Second run | +| ---- | --------- | ---------- | +| u2020:generateRInternalDebug | 33025 ms | 1652 ms | +| u2020:compileInternalDebug | 23 ms | 24 ms | +| u2020:retrolambdaInternalDebug | 234 ms | 255 ms | +| u2020:generateDexInternalDebug | 2 ms | 2 ms | +| u2020:signApkInternalDebug | 449 ms | 394 ms | +| u2020:assembleInternalDebug | 0 ms | 0 ms | +| | 33 seconds | 2 seconds | + + + From 496620da2828d49f98d45e8df5aec0a7a7399115 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 22:02:08 +0400 Subject: [PATCH 2/8] Fix timings. --- kobalt-incremental-tasks.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kobalt-incremental-tasks.md b/kobalt-incremental-tasks.md index 25157d82..f799a81a 100644 --- a/kobalt-incremental-tasks.md +++ b/kobalt-incremental-tasks.md @@ -62,13 +62,13 @@ Android (u2020): | Task | First run | Second run | | ---- | --------- | ---------- | -| u2020:generateRInternalDebug | 33025 ms | 1652 ms | -| u2020:compileInternalDebug | 23 ms | 24 ms | -| u2020:retrolambdaInternalDebug | 234 ms | 255 ms | -| u2020:generateDexInternalDebug | 2 ms | 2 ms | -| u2020:signApkInternalDebug | 449 ms | 394 ms | +| u2020:generateRInternalDebug | 32350 ms | 1652 ms | +| u2020:compileInternalDebug | 3629 ms | 24 ms | +| u2020:retrolambdaInternalDebug | 668 ms | 473 ms | +| u2020:generateDexInternalDebug | 6130 ms |55 ms | +| u2020:signApkInternalDebug | 449 ms | 404 ms | | u2020:assembleInternalDebug | 0 ms | 0 ms | -| | 33 seconds | 2 seconds | +| | 43 seconds | 2 seconds | From b1b3e692670b0969ef7570ce9df882c085338d79 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 22:02:29 +0400 Subject: [PATCH 3/8] Output checksum on correct build directory. --- .../main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 242bf28c..e325e529 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -172,8 +172,7 @@ abstract class JvmCompilerPlugin @Inject constructor( val inputChecksum = Md5.toMd5Directories(project.sourceDirectories.map { File(project.directory, it) }) - val outputChecksum = Md5.toMd5Directories(listOf(File(KFiles.joinDir(project.directory, project.buildDirectory, - KFiles.CLASSES_DIR)))) + val outputChecksum = Md5.toMd5Directories(listOf(File(project.classesDir(context)))) return IncrementalTaskInfo( inputChecksum = inputChecksum, outputChecksum = outputChecksum, From 54ec63e3fde0fc3cd86d27436570a01ed615bb56 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 22:03:13 +0400 Subject: [PATCH 4/8] Null checksums if the directory doesn't exist. --- .../main/kotlin/com/beust/kobalt/maven/Md5.kt | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt index 7693a9ea..850b2451 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt @@ -9,33 +9,41 @@ import javax.xml.bind.DatatypeConverter public class Md5 { companion object { // private fun md5(file: File) : String { +// if (file.isDirectory) { +// println("PROBLEM") +// } // val md5 = MessageDigest.getInstance("MD5") // val bytes = file.readBytes() // md5.update(bytes, 0, bytes.size) // return DatatypeConverter.printHexBinary(md5.digest()).toLowerCase() // } - fun toMd5Directories(directories: List) : String { - MessageDigest.getInstance("MD5").let { md5 -> - directories.forEach { file -> - if (file.isFile) { - val bytes = file.readBytes() - md5.update(bytes, 0, bytes.size) - } else { - val files = KFiles.findRecursively(file) // , { f -> f.endsWith("java")}) - log(2, " Calculating checksum of ${files.size} files in $file") - files.map { - File(file, it) - }.filter { - it.isFile - }.forEach { - val bytes = it.readBytes() + fun toMd5Directories(directories: List) : String? { + val ds = directories.filter { it.exists() } + if (ds.size > 0) { + MessageDigest.getInstance("MD5").let { md5 -> + directories.filter { it.exists() }.forEach { file -> + if (file.isFile) { + val bytes = file.readBytes() md5.update(bytes, 0, bytes.size) + } else { + val files = KFiles.findRecursively(file) // , { f -> f.endsWith("java")}) + log(2, " Calculating checksum of ${files.size} files in $file") + files.map { + File(file, it) + }.filter { + it.isFile + }.forEach { + val bytes = it.readBytes() + md5.update(bytes, 0, bytes.size) + } } } + val result = DatatypeConverter.printHexBinary(md5.digest()).toLowerCase() + return result } - val result = DatatypeConverter.printHexBinary(md5.digest()).toLowerCase() - return result + } else { + return null } } From ec13a5c1f0cfe6040dbb1cc044aeb4952535811a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 22:03:22 +0400 Subject: [PATCH 5/8] NPE. --- .../src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt index 7041d4b3..4864b3d5 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi.kt @@ -37,7 +37,7 @@ public class GithubApi @Inject constructor(val executors: KobaltExecutors, private fun parseRetrofitError(e: Throwable) : RetrofitErrorsResponse { val re = e as RetrofitError - val json = String((re.response.body as TypedByteArray).bytes) + val json = String((re.response?.body as TypedByteArray).bytes) return Gson().fromJson(json, RetrofitErrorsResponse::class.java) } From 454492829ea051baa76c293e13071ab2be6ad945 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 22:46:33 +0400 Subject: [PATCH 6/8] 0.361. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 43c628a9..9aa4fbda 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.360 \ No newline at end of file +kobalt.version=0.361 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 43c628a9..9aa4fbda 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.360 \ No newline at end of file +kobalt.version=0.361 \ No newline at end of file From 0a81f95f4daba33e3955476d1b3dee35729bbda5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 24 Dec 2015 23:02:15 +0400 Subject: [PATCH 7/8] Generate .pom if mavenJars{} is invoked --- .../beust/kobalt/plugin/packaging/PackagingPlugin.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index 869a8866..22e07c85 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -12,6 +12,7 @@ import com.beust.kobalt.api.annotation.Task import com.beust.kobalt.glob import com.beust.kobalt.internal.JvmCompilerPlugin import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.maven.PomGenerator import com.beust.kobalt.misc.* import java.io.File import java.io.FileOutputStream @@ -24,7 +25,8 @@ import javax.inject.Singleton @Singleton class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager, val executors: KobaltExecutors, val jarGenerator: JarGenerator, val warGenerator: WarGenerator, - val zipGenerator: ZipGenerator, val taskContributor: TaskContributor) + val zipGenerator: ZipGenerator, val taskContributor: TaskContributor, + val pomFactory: PomGenerator.IFactory) : ConfigPlugin(), ITaskContributor { companion object { @@ -180,6 +182,9 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana pkg.jars.forEach { jarGenerator.generateJar(pkg.project, context, it) } pkg.wars.forEach { warGenerator.generateWar(pkg.project, context, it, projects) } pkg.zips.forEach { zipGenerator.generateZip(pkg.project, context, it) } + if (pkg.generatePom) { + pomFactory.create(project).generate() + } } return TaskResult() } @@ -228,6 +233,7 @@ class PackageConfig(val project: Project) : AttributeHolder { val jars = arrayListOf() val wars = arrayListOf() val zips = arrayListOf() + var generatePom: Boolean = false init { (Kobalt.findPlugin(PackagingPlugin.PLUGIN_NAME) as PackagingPlugin).addPackage(this) @@ -283,6 +289,8 @@ class PackageConfig(val project: Project) : AttributeHolder { mainJar.addAttribute(it.first, it.second) } + generatePom = true + return m } From 231b18302e32f07de7ac9fae57a1b3dde02f0704 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 25 Dec 2015 01:01:35 +0400 Subject: [PATCH 8/8] 0.362. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 9aa4fbda..e39c1c0d 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.361 \ No newline at end of file +kobalt.version=0.362 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 9aa4fbda..e39c1c0d 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.361 \ No newline at end of file +kobalt.version=0.362 \ No newline at end of file