tools: Don't use tar to unpack dependencies
This commit is contained in:
@@ -25,11 +25,17 @@ apply plugin: 'kotlin'
|
|||||||
apply plugin: NativeInteropPlugin
|
apply plugin: NativeInteropPlugin
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
unTar
|
||||||
|
compile.extendsFrom unTar
|
||||||
cli_bc.extendsFrom compile
|
cli_bc.extendsFrom compile
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':backend.native', configuration: 'cli_bc')
|
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
|
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")
|
def testDependencies = project.file("${sourceSets.testOutputLocal.output.dirs.singleFile.absolutePath}/dependencies")
|
||||||
|
|
||||||
void prepareDependenciesDir(File testDependencies) {
|
void prepareDependenciesDir(File testDependencies) {
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package org.jetbrains.kotlin.konan
|
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.io.*
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
@@ -51,14 +54,12 @@ class DependencyDownloader(dependenciesRoot: File, val properties: Properties, v
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun extract(tarGz: File) {
|
private fun extract(tarGz: File) {
|
||||||
val tarProcess = ProcessBuilder().apply {
|
val ua = TarGZipUnArchiver()
|
||||||
command("tar", "-x", "-f", "${tarGz.canonicalPath}")
|
ua.sourceFile = tarGz
|
||||||
directory(tarGz.parentFile)
|
ua.destDirectory = dependenciesRoot
|
||||||
}.start()
|
// Workaround. This archive library crashes if the logger is not set.
|
||||||
tarProcess.waitFor()
|
ua.enableLogging(ConsoleLogger(Logger.LEVEL_DISABLED, "Logger"))
|
||||||
if (tarProcess.exitValue() != 0) {
|
ua.extract()
|
||||||
throw RuntimeException("Cannot extract archive with dependency: ${tarGz.canonicalPath}")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val Long.humanReadable: String
|
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.
|
Thread.sleep(1000) // We can use condition variable here.
|
||||||
updateProgressMsg(url.toString(), currentBytes, totalBytes)
|
updateProgressMsg(url.toString(), currentBytes, totalBytes)
|
||||||
}
|
}
|
||||||
println("Done.")
|
|
||||||
if (downloadError != null) {
|
if (downloadError != null) {
|
||||||
throw RuntimeException("Cannot download dependency: $url", downloadError)
|
throw RuntimeException("Cannot download dependency: $url", downloadError)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user