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
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue