tools: Don't use tar to unpack dependencies

This commit is contained in:
Ilya Matveev
2017-03-24 15:12:03 +07:00
committed by ilmat192
parent 798687e680
commit 8df9b535f2
2 changed files with 22 additions and 9 deletions
+13
View File
@@ -25,11 +25,17 @@ apply plugin: 'kotlin'
apply plugin: NativeInteropPlugin
configurations {
unTar
compile.extendsFrom unTar
cli_bc.extendsFrom compile
}
dependencies {
compile project(path: ':backend.native', configuration: 'cli_bc')
// https://mvnrepository.com/artifact/org.codehaus.plexus/plexus-archiver
unTar group: 'org.codehaus.plexus', name: 'plexus-archiver', version: '3.4'
// https://mvnrepository.com/artifact/org.codehaus.plexus/plexus-container-default
unTar group: 'org.codehaus.plexus', name: 'plexus-container-default', version: '1.7.1'
cli_bc jar.outputs.files
}
@@ -39,6 +45,13 @@ sourceSets {
}
}
// TODO: shrink jar
jar {
from {
configurations.unTar.collect { it.isDirectory() ? it : zipTree(it) }
}
}
def testDependencies = project.file("${sourceSets.testOutputLocal.output.dirs.singleFile.absolutePath}/dependencies")
void prepareDependenciesDir(File testDependencies) {
@@ -1,5 +1,8 @@
package org.jetbrains.kotlin.konan
import org.codehaus.plexus.archiver.tar.TarGZipUnArchiver
import org.codehaus.plexus.logging.Logger
import org.codehaus.plexus.logging.console.ConsoleLogger
import java.io.*
import java.net.URL
import java.util.Properties
@@ -51,14 +54,12 @@ class DependencyDownloader(dependenciesRoot: File, val properties: Properties, v
}
private fun extract(tarGz: File) {
val tarProcess = ProcessBuilder().apply {
command("tar", "-x", "-f", "${tarGz.canonicalPath}")
directory(tarGz.parentFile)
}.start()
tarProcess.waitFor()
if (tarProcess.exitValue() != 0) {
throw RuntimeException("Cannot extract archive with dependency: ${tarGz.canonicalPath}")
}
val ua = TarGZipUnArchiver()
ua.sourceFile = tarGz
ua.destDirectory = dependenciesRoot
// Workaround. This archive library crashes if the logger is not set.
ua.enableLogging(ConsoleLogger(Logger.LEVEL_DISABLED, "Logger"))
ua.extract()
}
private val Long.humanReadable: String
@@ -114,7 +115,6 @@ class DependencyDownloader(dependenciesRoot: File, val properties: Properties, v
Thread.sleep(1000) // We can use condition variable here.
updateProgressMsg(url.toString(), currentBytes, totalBytes)
}
println("Done.")
if (downloadError != null) {
throw RuntimeException("Cannot download dependency: $url", downloadError)
}