Skip to content

Commit

Permalink
migrate first generic subprojects configuration to Kotlin DSL (#123)
Browse files Browse the repository at this point in the history
Note: Using a `String` for dependency configuration is ugly but the
alternative is to apply `java-library` plugins within `plugins` closure
which would also apply it to root project which is very much unwanted.
This also does not allow to use `java` closure and `javadoc` task.

Alternative: We could split build into multiple files with a lot
duplicated code, though.

Which one is better?
  • Loading branch information
aaschmid committed Dec 22, 2019
1 parent 231bcb0 commit 3b3665b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
40 changes: 40 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,44 @@ allprojects {
}
}

subprojects {
apply<JacocoPlugin>()
apply<JavaLibraryPlugin>()
apply<com.github.spotbugs.SpotBugsPlugin>()
apply<aQute.bnd.gradle.BndBuilderPlugin>()

group = "com.tngtech.junit.dataprovider"
version = "2.7-SNAPSHOT"

dependencies {
"compileOnly"("com.github.spotbugs:spotbugs-annotations:3.1.5")
"testImplementation"("com.github.spotbugs:spotbugs-annotations:3.1.5")
}

configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf("-Xlint:all", "-Werror"))
}

withType<Jar> {
from(project.rootDir) {
include("LICENSE.md", "LICENSE-notice.md")
into("META-INF")
}
}

named<Javadoc>("javadoc") {
if (JavaVersion.current().isJava9Compatible()) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}
}
}

apply(from = "legacy.build.gradle")
38 changes: 0 additions & 38 deletions legacy.build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
subprojects {
apply(plugin: "jacoco")
apply(plugin: "java-library")
apply(plugin: "com.github.spotbugs")
apply(plugin: "biz.aQute.bnd.builder")

group = "com.tngtech.junit.dataprovider"
version = "2.7-SNAPSHOT"

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs += [ "-Xlint:all", "-Werror" ]
}

tasks.withType(Jar) {
from(project.rootDir) {
include("LICENSE.md", "LICENSE-notice.md")
into("META-INF")
}
}

dependencies {
compileOnly("com.github.spotbugs:spotbugs-annotations:3.1.5")
testImplementation("com.github.spotbugs:spotbugs-annotations:3.1.5")
}

java {
withJavadocJar()
withSourcesJar()
}

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
}
}

project(":core") {
archivesBaseName = "junit-dataprovider-core"
description = "The common core for a TestNG like dataprovider runner for JUnit."
Expand Down

0 comments on commit 3b3665b

Please sign in to comment.