Fix embeddable compiler dependencies, fix dist task, use runtimeJar...

dependencies where appropriate, some helpers refactoring
This commit is contained in:
Ilya Chernikov
2017-09-19 14:28:43 +02:00
parent b7226951b6
commit d61695be55
10 changed files with 36 additions and 31 deletions
+13 -16
View File
@@ -142,7 +142,9 @@ fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit
}
fun Project.ideaPlugin(subdir: String = "lib"): Copy = ideaPlugin(subdir) {
fromRuntimeJarIfExists(this)
runtimeJarTaskIfExists()?.let {
from(it)
}
}
fun Project.dist(targetDir: File? = null,
@@ -155,27 +157,22 @@ fun Project.dist(targetDir: File? = null,
return task<Copy>("dist") {
body()
when {
fromTask != null -> from(fromTask)
else -> project.fromRuntimeJarIfExists(this)
(fromTask ?: runtimeJarTaskIfExists())?.let {
from(it)
if (targetName != null) {
rename(it.outputs.files.singleFile.name, targetName)
}
}
rename(".*", distJarName)
// rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "")
rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "")
into(targetDir ?: distLibDir)
project.addArtifact(distJarCfg, this, File(targetDir ?: distLibDir, distJarName))
}
}
private fun<T: AbstractCopyTask> Project.fromRuntimeJarIfExists(task: T) {
if (extra.has("runtimeJarTask")) {
task.from(extra["runtimeJarTask"] as Task)
}
else {
tasks.findByName("jar")?.let {
task.from(it)
}
}
}
private fun Project.runtimeJarTaskIfExists(): Task? =
if (extra.has("runtimeJarTask")) extra["runtimeJarTask"] as Task
else tasks.findByName("jar")
fun ConfigurationContainer.getOrCreate(name: String): Configuration = findByName(name) ?: create(name)