Use Gradle conventions through base plugin

This commit is contained in:
Daniel Wolf 2019-08-03 22:31:06 +02:00
parent 356e30f446
commit 7c49f76efe
4 changed files with 27 additions and 16 deletions

View File

@ -3,20 +3,20 @@ plugins {
// See https://guides.gradle.org/creating-build-scans/#enable_build_scans_on_all_builds_of_your_project // See https://guides.gradle.org/creating-build-scans/#enable_build_scans_on_all_builds_of_your_project
id("com.gradle.build-scan") version "2.1" id("com.gradle.build-scan") version "2.1"
// Sets up standard lifecycle tasks like `build` and `assemble`.
// Also required for the Zip task to compute its archive file name.
base base
} }
group = "com.rhubarb_lip_sync" group = "com.rhubarb_lip_sync"
version = "2.0.0-pre-alpha" version = "2.0.0-pre-alpha"
val distsDirName = convention.getPlugin(BasePluginConvention::class).distsDirName
tasks { tasks {
val zip by creating(Zip::class) { val zip by creating(Zip::class) {
subprojects.forEach { dependsOn("${it.name}:assemble") } subprojects.forEach { dependsOn("${it.name}:assemble") }
for (subproject in subprojects) { for (subproject in subprojects) {
from(File(subproject.buildDir, "distributions")) { from(File(subproject.buildDir, distsDirName)) {
into(if (subproject.name == "rhubarb") "" else subproject.name) into(if (subproject.name == "rhubarb") "" else subproject.name)
} }
} }

View File

@ -1,12 +1,17 @@
tasks { plugins {
var distDirectory = File(project.buildDir, "distributions") base
}
val assemble by creating(Copy::class) { val distsDirName = convention.getPlugin(BasePluginConvention::class).distsDirName
var distDirectory = File(project.buildDir, distsDirName)
tasks {
val copy by creating(Copy::class) {
from(listOf("Rhubarb Lip Sync.jsx", "README.adoc")) from(listOf("Rhubarb Lip Sync.jsx", "README.adoc"))
into(distDirectory) into(distDirectory)
} }
val build by creating { assemble {
dependsOn(assemble) dependsOn(copy)
} }
} }

View File

@ -18,9 +18,10 @@ dependencies {
testCompile("org.assertj:assertj-core:3.11.1") testCompile("org.assertj:assertj-core:3.11.1")
} }
tasks { val distsDirName = convention.getPlugin(BasePluginConvention::class).distsDirName
var distDirectory = File(project.buildDir, "distributions") var distDirectory = File(project.buildDir, distsDirName)
tasks {
withType<KotlinCompile> { withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8" kotlinOptions.jvmTarget = "1.8"
} }

View File

@ -1,7 +1,12 @@
tasks { val distsDirName = convention.getPlugin(BasePluginConvention::class).distsDirName
var distDirectory = File(project.buildDir, "distributions") var distDirectory = File(project.buildDir, distsDirName)
val assemble by creating(Copy::class) { plugins {
base
}
tasks {
val copy by creating(Copy::class) {
from(listOf( from(listOf(
"Debug Rhubarb.cs", "Debug Rhubarb.cs",
"Debug Rhubarb.cs.config", "Debug Rhubarb.cs.config",
@ -12,7 +17,7 @@ tasks {
into(distDirectory) into(distDirectory)
} }
create("build") { assemble {
dependsOn(assemble) dependsOn(copy)
} }
} }