mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Merge branch 'master' of github.com:cbeust/kobalt
This commit is contained in:
commit
a187061af9
7 changed files with 53 additions and 24 deletions
|
@ -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 |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.360
|
||||
kobalt.version=0.362
|
|
@ -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,
|
||||
|
|
|
@ -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<File>) : 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<File>) : 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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<InstallConfig>(), 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<Jar>()
|
||||
val wars = arrayListOf<War>()
|
||||
val zips = arrayListOf<Zip>()
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.360
|
||||
kobalt.version=0.362
|
Loading…
Add table
Add a link
Reference in a new issue