build: implement downloading (native) dependencies from the JFrog repo

This commit is contained in:
Svyatoslav Scherbina
2016-10-17 17:32:53 +03:00
parent ddae560ffe
commit 7ed9d9c633
4 changed files with 92 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
.DS_Store
.idea/shelf
dependencies
/dependencies/all
dist
translator/src/test/kotlin/tests/*/linked
out
+6
View File
@@ -4,4 +4,10 @@ if (new File("$project.rootDir/local.properties").exists()) {
Properties props = new Properties()
props.load(new FileInputStream("$project.rootDir/local.properties"))
props.each {prop -> project.ext.set(prop.key, prop.value)}
}
allprojects {
if (path != ":dependencies") {
evaluationDependsOn(":dependencies")
}
}
+84
View File
@@ -0,0 +1,84 @@
abstract class NativeDep extends DefaultTask {
private static String getCurrentHostTarget() {
String osName = System.properties['os.name']
String osArch = System.properties['os.arch']
// TODO: implement more generally
if (osArch in ['x86_64', 'amd64']) {
if (osName == 'Mac OS X') {
return 'darwin-macos'
} else if (osName == 'Linux') {
return 'linux-x86-64'
} else {
throw new Error("Unsupported OS: $osName")
}
} else {
throw new Error("Unsupported arch: $osArch")
}
}
protected final String target = getCurrentHostTarget();
@Input
abstract String getFileName()
protected String getUrl() {
return "http://repo.labs.intellij.net/kotlin-native/$fileName"
}
protected File getBaseOutDir() {
final File res = project.file("all")
res.mkdirs()
return res
}
protected File download() {
File result = new File(baseOutDir, fileName)
ant.get(src: url, dest: result, usetimestamp: true)
return result
}
}
class TgzNativeDep extends NativeDep {
String baseName
@Override
String getFileName() {
return "${baseName}.tar.gz"
}
@OutputDirectory
File getOutputDir() {
return new File(baseOutDir, baseName)
}
@TaskAction
public void downloadAndExtract() {
File archived = this.download()
try {
// Builtin Gradle unpacking tools seem to unable to handle symlinks;
// Use external "tar" executable as workaround:
project.exec {
executable "tar"
workingDir baseOutDir
args "xf", archived
}
} catch (Throwable e) {
project.delete(outputDir)
throw e
}
// TODO: do not extract if already extracted
}
}
task update {
dependsOn tasks.withType(NativeDep)
}
tasks.withType(TgzNativeDep) {
rootProject.ext.set("${name}Dir", outputDir.path)
}
+1
View File
@@ -1,3 +1,4 @@
include ':dependencies'
include ':Interop:Indexer'
include ':Interop:StubGenerator'
include ':Interop:Runtime'