Skip to content

Commit

Permalink
migrate second generic subprojects configuration to Kotlin DSL (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschmid committed Dec 29, 2019
1 parent db047f0 commit a67b9dc
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 69 deletions.
71 changes: 71 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,77 @@ project(":junit-jupiter-params") {
}
}

// configure after properties are set and integration tests are added
subprojects {
configure<JacocoPluginExtension> {
toolVersion = "0.8.3"
}

configure<com.github.spotbugs.SpotBugsExtension> {
toolVersion = "3.1.12"
isIgnoreFailures = true
}

tasks {
named<Jar>("jar") {
manifest {
val now = java.time.LocalDate.now()

val title = project.the<BasePluginConvention>().archivesBaseName
val company = "TNG Technology Consulting GmbH"
val today = now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"))
val copyright = "${now.year} $company"

attributes(
"Built-By" to "Gradle ${gradle.gradleVersion}",
"Built-Date" to today, // using now would destroy incremental build feature
"Specification-Title" to title,
"Specification-Version" to archiveVersion,
"Specification-Vendor" to company,
"Implementation-Title" to title,
"Implementation-Version" to archiveVersion,
"Implementation-Vendor" to company,
"Issue-Tracker" to "/~https://github.com/TNG/junit-dataprovider/issues",
"Documentation-URL" to "/~https://github.com/TNG/junit-dataprovider/wiki",
"Copyright" to copyright,
"License" to "Apache License v2.0, January 2004",

// OSGi / p2 plugin information
"Bundle-Copyright" to copyright,
"Bundle-Name" to title,
"Bundle-SymbolicName" to "${project.group}.$title",
"Bundle-Vendor" to company,
"Export-Package" to "com.tngtech.junit.dataprovider.*"
)
}
}

val test = named<Test>("test") {
ignoreFailures = isBuildOnJenkins
}

val touchTestResultsForJenkins = register<TouchTestResults>("touchTestResultsForJenkins") {
tasks(test)
enabled = isBuildOnJenkins
}
getByName("build").dependsOn(touchTestResultsForJenkins)

named<JacocoReport>("jacocoTestReport") {
reports {
xml.isEnabled = true // coveralls plugin depends on xml format report
}
}

withType<com.github.spotbugs.SpotBugsTask> {
enabled = !skipSpotBugs
}

plugins.withType<LifecycleBasePlugin> {
get("check").dependsOn(rootProject.tasks["cpdCheck"])
}
}
}

// -- Custom tasks ------------------------------------------------------------
/**
* Task to touch all junit xml report files for all given {@link Test} {@code tasks}.
Expand Down
69 changes: 0 additions & 69 deletions legacy.build.gradle
Original file line number Diff line number Diff line change
@@ -1,72 +1,3 @@

// configure after properties are set and integration tests are added
subprojects {
jar {
manifest {
def now = new Date()

def company = "TNG Technology Consulting GmbH"
def today = now.format("yyyy-MM-dd")
def copyright = "${now[Calendar.YEAR]} ${company}"

attributes(
"Built-By": "Gradle ${gradle.gradleVersion}",
"Built-Date": today, // using now would destroy incremental build feature
"Specification-Title": archivesBaseName,
"Specification-Version": archiveVersion,
"Specification-Vendor": company,
"Implementation-Title": archivesBaseName,
"Implementation-Version": archiveVersion,
"Implementation-Vendor": company,
"Issue-Tracker": "/~https://github.com/TNG/junit-dataprovider/issues",
"Documentation-URL": "/~https://github.com/TNG/junit-dataprovider/wiki",
"Copyright": copyright,
"License": "Apache License v2.0, January 2004",

// OSGi / p2 plugin information
"Bundle-Copyright": copyright,
"Bundle-Name": archivesBaseName,
"Bundle-SymbolicName": "${project.group}.${archivesBaseName}",
"Bundle-Vendor": company,
"Export-Package": "com.tngtech.junit.dataprovider.*",
)
}
}

test {
ignoreFailures = isBuildOnJenkins
}

task touchTestResultsForJenkins(type: TouchTestResults) {
tasks(test)
enabled = isBuildOnJenkins
}
build.dependsOn(touchTestResultsForJenkins)

jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
}
}
jacoco {
toolVersion = "0.8.3"
}

spotbugs {
toolVersion = "3.1.12"
ignoreFailures = true
}

plugins.withType(LifecycleBasePlugin) {
check.dependsOn(rootProject.cpdCheck)
}

// TODO comment for the sake of migration as this does not work anymore if file is imported from Kotlin DSL build file :-(
// tasks.withType(com.github.spotbugs.SpotBugsTask).each { task ->
// task.enabled = !rootProject.skipSpotBugs
// }
}

cpd {
// Use Java 8 and later to execute cpd successfully
toolVersion = "6.13.0"
Expand Down

0 comments on commit a67b9dc

Please sign in to comment.