Skip to content

Commit 127469a

Browse files
committed
Initial commit
0 parents  commit 127469a

File tree

23 files changed

+1380
-0
lines changed

23 files changed

+1380
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.idea/
2+
*.iml
3+
*.ipr
4+
*.iws
5+
*.log*
6+
out/
7+
build/
8+
target/
9+
.gradle/
10+
.settings/
11+
.project
12+
.classpath
13+
.DS_Store

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
notifications:
2+
email: false
3+
4+
git:
5+
depth: false
6+
quiet: true
7+
8+
language: java
9+
jdk: oraclejdk8
10+
node_js: lts/*
11+
12+
addons:
13+
apt:
14+
packages:
15+
- bash
16+
- tree
17+
18+
env:
19+
global:
20+
- TERM=dumb
21+
22+
install: true
23+
before_install:
24+
- sudo apt-get update -yqq
25+
26+
script:
27+
- ./gradlew check -PignoreBugs
28+
- tree ./build/spotbugs
29+
#
30+
- ./gradlew clean
31+
- ./gradlew check || echo 'error expected.'
32+
- tree ./build/spotbugs
33+
34+
cache:
35+
packages: true
36+
directories:
37+
- ${HOME}/.gradle

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# spotbugs gradle multi-project build [![Build Status](https://travis-ci.org/daggerok/spotbugs-gradle-plugin-multi-project-example.svg?branch=master)](https://travis-ci.org/daggerok/spotbugs-gradle-plugin-multi-project-example)
2+
Example of usage `spotbugs-gradle-plugin` (findbugs replacement) with HTML reports enabled in multi module Gradle project
3+
4+
config:
5+
6+
`build.gradle` file:
7+
8+
```gradle
9+
buildscript {
10+
ext {
11+
spotbugsVersion = '1.6.8'
12+
toolVersion = '3.1.10'
13+
}
14+
}
15+
16+
plugins {
17+
id 'com.github.spotbugs' version '1.6.8' apply false
18+
}
19+
20+
apply from: "$rootProject.projectDir/gradle/spotbugs.gradle"
21+
22+
defaultTasks 'clean', 'check'
23+
```
24+
25+
`gradle/spotbugs.gradle` file:
26+
27+
```gradle
28+
buildscript {
29+
repositories {
30+
maven { url "https://plugins.gradle.org/m2/" }
31+
}
32+
dependencies {
33+
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:$spotbugsVersion"
34+
}
35+
}
36+
37+
subprojects {
38+
apply plugin: "com.github.spotbugs"
39+
40+
repositories {
41+
maven { url "https://plugins.gradle.org/m2/" }
42+
}
43+
44+
spotbugs {
45+
toolVersion = project.toolVersion
46+
effort = "max"
47+
ignoreFailures = project.findProperty('ignoreBugs') != null
48+
}
49+
50+
tasks.withType(com.github.spotbugs.SpotBugsTask) {
51+
reports {
52+
html {
53+
enabled = true
54+
}
55+
xml {
56+
enabled = false
57+
}
58+
}
59+
}
60+
}
61+
```
62+
63+
versions:
64+
65+
- gradle: 5.1
66+
- spotbugs-gradle-plugin: 1.6.8
67+
- tool: 3.1.10
68+
69+
usage:
70+
71+
```bash
72+
./gradlew # to be failed
73+
./gradlew -PignoreBugs # do not failed on found bugs
74+
```
75+
76+
links:
77+
78+
- [spotbugs gradle plugin html report in multi-project issue](https://github.com/spotbugs/spotbugs-gradle-plugin/issues/32)
79+
- [not generates HTML report when lombok gradle plugin enabled issue](https://github.com/spotbugs/spotbugs-gradle-plugin/issues/94)

build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
buildscript {
2+
ext {
3+
spotbugsVersion = '1.6.8'
4+
toolVersion = '3.1.10'
5+
6+
javaVersion = JavaVersion.VERSION_1_8
7+
lombokVersion = '1.18.4'
8+
logbackVersion = '1.2.3'
9+
slf4jVersion = '1.7.25'
10+
vavrVersion = '0.9.2'
11+
12+
junitPlatformVersion = '1.3.0'
13+
junitJupiterVersion = '5.3.1'
14+
assertjVersion = '3.11.1'
15+
hamcrestVersion = '2.1'
16+
junit4Version = '4.12'
17+
}
18+
}
19+
20+
plugins {
21+
id 'com.github.spotbugs' version '1.6.8' apply false
22+
// // one more bug:
23+
// // SpotBugs HTML reports not working (generates XML instead)
24+
// // when gradle lombok plugin also applied
25+
// id 'io.franzbecker.gradle-lombok' version '1.14' apply false
26+
}
27+
28+
apply from: "$rootProject.projectDir/gradle/java.gradle"
29+
apply from: "$rootProject.projectDir/gradle/spotbugs.gradle"
30+
31+
defaultTasks 'clean', 'check'

gradle/java.gradle

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
allprojects {
2+
apply plugin: 'java'
3+
4+
clean.doFirst {
5+
delete "$project.buildDir"
6+
}
7+
}
8+
9+
subprojects {
10+
// // one more bug:
11+
// // SpotBugs HTML reports not working (generates XML instead)
12+
// // when gradle lombok plugin also applied
13+
// apply plugin: 'io.franzbecker.gradle-lombok'
14+
// lombok.version = project.lombokVersion
15+
16+
version = project.findProperty('org.gradle.project.version') ?: '1.0.0-SNAPSHOT'
17+
group = 'com.github.daggerok'
18+
sourceCompatibility = targetCompatibility = "$javaVersion"
19+
20+
defaultTasks 'clean', 'check'
21+
22+
dependencies {
23+
implementation "org.slf4j:slf4j-api:$slf4jVersion"
24+
implementation "ch.qos.logback:logback-classic:$logbackVersion"
25+
26+
// test
27+
testImplementation "junit:junit:$junit4Version"
28+
testImplementation "org.assertj:assertj-core:$assertjVersion"
29+
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
30+
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
31+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
32+
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junitJupiterVersion", {
33+
because 'allows JUnit 3 and JUnit 4 tests to run'
34+
}
35+
testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion", {
36+
because 'allows tests to run from IDEs that bundle older version of launcher'
37+
}
38+
testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'
39+
}
40+
41+
test {
42+
useJUnitPlatform {
43+
includeEngines 'junit-jupiter', 'junit-vintage'
44+
}
45+
}
46+
}

gradle/spotbugs.gradle

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
buildscript {
2+
repositories {
3+
maven { url "https://plugins.gradle.org/m2/" }
4+
}
5+
dependencies {
6+
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:$spotbugsVersion"
7+
}
8+
}
9+
10+
subprojects {
11+
apply plugin: "com.github.spotbugs"
12+
13+
repositories {
14+
maven { url "https://plugins.gradle.org/m2/" }
15+
}
16+
17+
def suffix = project.path.replaceAll(':', '-').replaceFirst('-', '')
18+
def prefix = rootProject.buildDir.absolutePath
19+
def path = "$prefix/spotbugs/$suffix" // customize reports location
20+
21+
spotbugs {
22+
toolVersion = project.toolVersion
23+
effort = "max"
24+
reportsDir = file("$path")
25+
ignoreFailures = project.findProperty('ignoreBugs') != null // gradle -PignoreBugs ..
26+
}
27+
28+
tasks.withType(com.github.spotbugs.SpotBugsTask) {
29+
reports {
30+
html {
31+
enabled = true
32+
impliesSubProjects = true
33+
// // disabled on 1.6.8
34+
// destination = "$path/index.html"
35+
}
36+
xml {
37+
enabled = false
38+
}
39+
}
40+
// pluginClasspath = project.configurations.spotbugsPlugins
41+
}
42+
}
43+

gradle/wrapper/gradle-wrapper.jar

53.9 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)