Skip to content

Commit ccea449

Browse files
Update Build (#7)
Switch to Kotlin DSL. Move the publishing code to a pre-compiled script plugin. Reduce repeated code blocks.
1 parent 09b787a commit ccea449

File tree

26 files changed

+422
-673
lines changed

26 files changed

+422
-673
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ root = true
44
charset = utf-8
55
end_of_line = lf
66

7-
[*.{java,gradle}]
7+
[*.{java,gradle,gradle.kts}]
88
indent_size = 4
99
indent_style = space
1010
insert_final_newline = true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66

77
# Ignore Gradle build output directory
88
build/
9+
!buildSrc/src/**/build

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ jobs:
1414
- name: OpenJDK 11
1515
jdk: openjdk11
1616
script: ./gradlew jacocoTestReport sonarqube
17+
- name: OpenJDK 17
18+
jdk: openjdk17
19+
script: ./gradlew jacocoTestReport check

build.gradle

Lines changed: 0 additions & 107 deletions
This file was deleted.

build.gradle.kts

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
plugins {
2+
java
3+
`jvm-test-suite`
4+
jacoco
5+
`jacoco-report-aggregation`
6+
id("org.sonarqube") version "3.3"
7+
}
8+
9+
val springVersion = "5.3.8"
10+
val springBootVersion = "2.4.7"
11+
12+
val rootJacocoDir by extra("${rootProject.buildDir}/reports/jacoco/testCodeCoverageReport")
13+
val reportXmlFile by extra("$rootJacocoDir/jacocoTestReport.xml")
14+
15+
val javadocLinks = arrayOf(
16+
"https://docs.oracle.com/javase/8/docs/api/",
17+
"https://docs.oracle.com/javaee/7/api/",
18+
"https://docs.spring.io/spring/docs/$springVersion/javadoc-api/",
19+
"https://docs.spring.io/spring-boot/docs/$springBootVersion/api/"
20+
)
21+
22+
allprojects {
23+
repositories {
24+
mavenCentral()
25+
}
26+
}
27+
28+
subprojects {
29+
apply(plugin = "java")
30+
apply(plugin = "jacoco")
31+
apply(plugin = "org.sonarqube")
32+
apply(plugin = "jvm-test-suite")
33+
34+
group = "com.mattbertolini"
35+
version = "0.5.0-SNAPSHOT"
36+
37+
java {
38+
toolchain {
39+
languageVersion.set(JavaLanguageVersion.of(8))
40+
}
41+
}
42+
43+
// sourceCompatibility = 1.8
44+
45+
dependencies {
46+
implementation(platform("org.springframework:spring-framework-bom:$springVersion"))
47+
implementation(platform("javax.servlet:javax.servlet-api:3.1.0"))
48+
implementation(platform("com.google.code.findbugs:jsr305:3.0.2"))
49+
50+
constraints {
51+
implementation("org.springframework.boot:spring-boot-starter:$springBootVersion")
52+
implementation("org.springframework.boot:spring-boot-test:$springBootVersion")
53+
}
54+
55+
// Test
56+
implementation(platform("org.junit:junit-bom:5.6.1"))
57+
implementation(platform("org.assertj:assertj-core:3.15.0"))
58+
implementation(platform("nl.jqno.equalsverifier:equalsverifier:3.1.13"))
59+
implementation(platform("org.mockito:mockito-core:3.3.3"))
60+
}
61+
62+
tasks.jar {
63+
manifest {
64+
attributes(
65+
"Implementation-Title" to project.name,
66+
"Implementation-Version" to archiveVersion,
67+
)
68+
}
69+
}
70+
71+
testing {
72+
suites {
73+
val test by getting(JvmTestSuite::class) {
74+
useJUnitJupiter()
75+
}
76+
}
77+
}
78+
79+
tasks.jacocoTestReport {
80+
reports {
81+
xml.required.set(true)
82+
html.required.set(true)
83+
csv.required.set(false)
84+
}
85+
}
86+
87+
tasks.test { finalizedBy(tasks.jacocoTestReport) }
88+
89+
tasks.javadoc {
90+
options {
91+
this as StandardJavadocDocletOptions
92+
source = "8"
93+
links(*javadocLinks)
94+
addStringOption("Xdoclint:none", "-quiet")
95+
if (java.toolchain.languageVersion.get().asInt() >= 9) {
96+
addBooleanOption("html5", true)
97+
}
98+
}
99+
100+
}
101+
}
102+
103+
reporting {
104+
reports {
105+
val testCodeCoverageReport by getting(JacocoCoverageReport::class) {
106+
testType.set(TestSuiteType.UNIT_TEST)
107+
}
108+
}
109+
}
110+
111+
dependencies {
112+
jacocoAggregation(project(":docs"))
113+
jacocoAggregation(project(":integration-tests"))
114+
jacocoAggregation(project(":spring-annotated-data-binder-core"))
115+
jacocoAggregation(project(":spring-webflux-annotated-data-binder"))
116+
jacocoAggregation(project(":spring-webmvc-annotated-data-binder"))
117+
jacocoAggregation(project(":webflux-annotated-data-binder-spring-boot-starter"))
118+
jacocoAggregation(project(":webmvc-annotated-data-binder-spring-boot-starter"))
119+
}
120+
121+
sonarqube {
122+
properties {
123+
property("sonar.projectKey", "mattbertolini_spring-annotated-web-data-binder")
124+
// property "sonar.coverage.jacoco.xmlReportPaths", reportXmlFile
125+
}
126+
}

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// buildSrc settings file. Required even if this file is empty
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.mattbertolini.build
2+
3+
plugins {
4+
java
5+
`maven-publish`
6+
signing
7+
}
8+
9+
abstract class MavenCentralPublishExtension {
10+
abstract val name: Property<String>
11+
abstract val description: Property<String>
12+
}
13+
14+
val extension = extensions.create("mavenCentralPublish", MavenCentralPublishExtension::class)
15+
16+
java {
17+
withJavadocJar()
18+
withSourcesJar()
19+
}
20+
21+
publishing {
22+
repositories {
23+
maven {
24+
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
25+
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
26+
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
27+
credentials {
28+
username = findProperty("sonatype.ossrh.username") as String?
29+
password = findProperty("sonatype.ossrh.password") as String?
30+
}
31+
}
32+
}
33+
34+
publications {
35+
create<MavenPublication>("mavenJava") {
36+
groupId = project.group as String
37+
artifactId = project.name
38+
version = project.version as String
39+
40+
from(components["java"])
41+
42+
pom {
43+
name.set(extension.name)
44+
description.set(extension.description)
45+
url.set("https://github.com/mattbertolini/spring-annotated-web-data-binder")
46+
developers {
47+
developer {
48+
name.set("Matt Bertolini")
49+
}
50+
}
51+
licenses {
52+
license {
53+
name.set("The Apache License, Version 2.0")
54+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
55+
}
56+
}
57+
scm {
58+
connection.set("scm:git:git://github.com/mattbertolini/spring-annotated-web-data-binder.git")
59+
developerConnection.set("scm:git:ssh://github.com/mattbertolini/spring-annotated-web-data-binder.git")
60+
url.set("https://github.com/mattbertolini/spring-annotated-web-data-binder")
61+
}
62+
}
63+
}
64+
}
65+
}
66+
67+
signing {
68+
sign(publishing.publications["mavenJava"])
69+
}

docs/build.gradle

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)