Skip to content

Commit e19c3ad

Browse files
committed
Specify additional task outputs
1 parent 9778473 commit e19c3ad

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

gradle/java-setup.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ apply plugin: 'com.github.spotbugs'
1717
spotbugs {
1818
toolVersion = VER_SPOTBUGS
1919
ignoreFailures = false // bug free or it doesn't ship!
20-
reportsDir = file('build/spotbugs')
2120
reportLevel = 'medium' // low|medium|high (low = sensitive to even minor mistakes)
2221
omitVisitors = [
2322
'FindReturnRef'] // https://spotbugs.readthedocs.io/en/latest/detectors.html#findreturnref
2423
}
2524
tasks.named('spotbugsTest') {
2625
enabled = false
2726
}
27+
28+
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
29+
outputs.file("$buildDir/reports/spotbugs/${it.name}.html")
30+
outputs.file("$buildDir/spotbugs/auxclasspath/${it.name}")
31+
reports {
32+
html.enabled = true
33+
}
34+
}
35+
2836
tasks.named('spotbugsMain') {
2937
// only run on Java 8 (no benefit to running twice)
3038
enabled = org.gradle.api.JavaVersion.current() == org.gradle.api.JavaVersion.VERSION_11

plugin-maven/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import java.nio.file.Files
2727
import java.nio.file.Paths
2828

2929
import static java.nio.charset.StandardCharsets.UTF_8
30-
import static java.nio.file.StandardOpenOption.CREATE_NEW
30+
import static java.nio.file.StandardOpenOption.CREATE
3131
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING
3232

3333
ext.artifactId = project.artifactIdMaven
@@ -91,9 +91,7 @@ dependencies {
9191
testImplementation "org.apache.maven:maven-core:${VER_MAVEN_API}"
9292
}
9393

94-
task cleanMavenProjectDir(type: Delete) { delete MAVEN_PROJECT_DIR }
95-
96-
task copySourceFiles(type: Sync, dependsOn: cleanMavenProjectDir) {
94+
task copySourceFiles(type: Sync) {
9795
from "src/main/java"
9896
into "${MAVEN_PROJECT_DIR}/src/main/java"
9997
}
@@ -137,6 +135,9 @@ libs.each {
137135
}
138136

139137
task createPomXml(dependsOn: installLocalDependencies) {
138+
def newPomXml = Paths.get(MAVEN_PROJECT_DIR, "pom.xml")
139+
140+
outputs.file(newPomXml)
140141
doLast {
141142
def additionalDependencies = project.configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.findAll {
142143
return !libs.contains(it.moduleVersion.id.name)
@@ -158,10 +159,9 @@ task createPomXml(dependsOn: installLocalDependencies) {
158159
]
159160

160161
def pomXmlTemplate = Paths.get(PROJECT_DIR, "src/test/resources/pom-build.xml.mustache")
161-
def newPomXml = Paths.get(MAVEN_PROJECT_DIR, "pom.xml")
162162

163163
Files.newBufferedReader(pomXmlTemplate).withCloseable { reader ->
164-
Files.newBufferedWriter(newPomXml, UTF_8, CREATE_NEW, TRUNCATE_EXISTING).withCloseable { writer ->
164+
Files.newBufferedWriter(newPomXml, UTF_8, CREATE, TRUNCATE_EXISTING).withCloseable { writer ->
165165
def mustache = new DefaultMustacheFactory().compile(reader, "pom")
166166
mustache.execute(writer, versions)
167167
}
@@ -170,11 +170,12 @@ task createPomXml(dependsOn: installLocalDependencies) {
170170
}
171171

172172
task runMavenBuild(type: Exec, dependsOn: [
173-
cleanMavenProjectDir,
174173
copySourceFiles,
175174
copyMvnw,
176175
createPomXml
177176
]) {
177+
outputs.dir(LOCAL_MAVEN_REPO_DIR)
178+
178179
workingDir MAVEN_PROJECT_DIR
179180
// -B batch mode to make dependency download logging less verbose
180181
commandLine mvnw("clean install -B -Dmaven.repo.local=${LOCAL_MAVEN_REPO_DIR}")

0 commit comments

Comments
 (0)