diff --git a/kobalt-incremental-tasks.md b/kobalt-incremental-tasks.md index fee39a9a..f799a81a 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 | 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 | +| | 43 seconds | 2 seconds | + + + diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 43c628a9..e39c1c0d 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.362 \ No newline at end of file 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, 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 } } 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) } 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 } diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 43c628a9..e39c1c0d 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.362 \ No newline at end of file