Skip to content

Commit a211c62

Browse files
authored
Format Groovy files in root Maven module with Spotless (jenkinsci#7834)
1 parent b56709a commit a211c62

File tree

3 files changed

+109
-81
lines changed

3 files changed

+109
-81
lines changed

Jenkinsfile

+4-12
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,22 @@ for (i = 0; i < buildTypes.size(); i++) {
101101
sourceCodeEncoding: 'UTF-8',
102102
skipBlames: true,
103103
trendChartType: 'TOOLS_ONLY',
104-
qualityGates: [
105-
[threshold: 1, type: 'NEW', unstable: true],
106-
]])
104+
qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]])
107105
recordIssues([tool: checkStyle(pattern: '**/target/checkstyle-result.xml'),
108106
sourceCodeEncoding: 'UTF-8',
109107
skipBlames: true,
110108
trendChartType: 'TOOLS_ONLY',
111-
qualityGates: [
112-
[threshold: 1, type: 'TOTAL', unstable: true],
113-
]])
109+
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]])
114110
recordIssues([tool: esLint(pattern: '**/target/eslint-warnings.xml'),
115111
sourceCodeEncoding: 'UTF-8',
116112
skipBlames: true,
117113
trendChartType: 'TOOLS_ONLY',
118-
qualityGates: [
119-
[threshold: 1, type: 'TOTAL', unstable: true],
120-
]])
114+
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]])
121115
recordIssues([tool: styleLint(pattern: '**/target/stylelint-warnings.xml'),
122116
sourceCodeEncoding: 'UTF-8',
123117
skipBlames: true,
124118
trendChartType: 'TOOLS_ONLY',
125-
qualityGates: [
126-
[threshold: 1, type: 'TOTAL', unstable: true],
127-
]])
119+
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]])
128120
if (failFast && currentBuild.result == 'UNSTABLE') {
129121
error 'Static analysis quality gates not passed; halting early'
130122
}

licenseCompleter.groovy

+89-69
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,104 @@
11
/*
2-
This script augments the missing license information in our dependencies.
3-
*/
2+
* This script augments the missing license information in our dependencies.
3+
*/
44
complete {
5-
// license constants
6-
def apacheLicense = license("The Apache Software License, Version 2.0","http://www.apache.org/licenses/LICENSE-2.0.txt")
7-
def cddl = license("CDDL","http://www.sun.com/cddl/")
8-
def lgpl = license("LGPL 2.1","http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html")
9-
def mitLicense = license("MIT License","http://www.opensource.org/licenses/mit-license.php")
10-
def bsdLicense = license("BSD License","http://opensource.org/licenses/BSD-2-Clause")
11-
def jenkinsLicense = license("MIT License","https://www.jenkins.io/mit-license")
12-
def ccby = license("Creative Commons Attribution License","http://creativecommons.org/licenses/by/2.5")
5+
// license constants
6+
def apacheLicense = license("The Apache Software License, Version 2.0", "http://www.apache.org/licenses/LICENSE-2.0.txt")
7+
def cddl = license("CDDL", "http://www.sun.com/cddl/")
8+
def lgpl = license("LGPL 2.1", "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html")
9+
def mitLicense = license("MIT License", "http://www.opensource.org/licenses/mit-license.php")
10+
def bsdLicense = license("BSD License", "http://opensource.org/licenses/BSD-2-Clause")
11+
def jenkinsLicense = license("MIT License", "https://www.jenkins.io/mit-license")
12+
def ccby = license("Creative Commons Attribution License", "http://creativecommons.org/licenses/by/2.5")
1313

1414

15-
match("asm:*") {
16-
if (dependency.licenses.isEmpty())
17-
rewriteLicense([], license("BSD License","http://asm.ow2.org/license.html"))
18-
}
15+
match("asm:*") {
16+
if (dependency.licenses.isEmpty())
17+
rewriteLicense([], license("BSD License", "http://asm.ow2.org/license.html"))
18+
}
1919

20-
// Apache components
21-
// logkit is a part of Avalon
22-
match(["org.apache.ant:*","commons-jelly:*","log4j:*","avalon-framework:*","logkit:logkit","oro:oro","commons-codec:*","commons-beanutils:*","commons-net:*","commons-cli:*","*:commons-jelly","org.jvnet.hudson:commons-jelly-tags-define","slide:slide-webdavlib"]) {
23-
if (dependency.licenses.isEmpty())
24-
rewriteLicense([], apacheLicense)
25-
}
20+
// Apache components
21+
// logkit is a part of Avalon
22+
match([
23+
"org.apache.ant:*",
24+
"commons-jelly:*",
25+
"log4j:*",
26+
"avalon-framework:*",
27+
"logkit:logkit",
28+
"oro:oro",
29+
"commons-codec:*",
30+
"commons-beanutils:*",
31+
"commons-net:*",
32+
"commons-cli:*",
33+
"*:commons-jelly",
34+
"org.jvnet.hudson:commons-jelly-tags-define",
35+
"slide:slide-webdavlib"
36+
]) {
37+
if (dependency.licenses.isEmpty())
38+
rewriteLicense([], apacheLicense)
39+
}
2640

27-
// GlassFish components are dual-licensed between CDDL and GPL+Classpath Exception
28-
// we elect to take them under CDDL.
29-
// note that central has a different POM from m.g.o-public (http://repo2.maven.org/maven2/javax/mail/mail/1.4/mail-1.4.pom
30-
// vs http://maven.glassfish.org/content/groups/public/javax/mail/mail/1.4/mail-1.4.pom), so we aren't using rewriteLicense here
31-
match(["javax.mail:*","org.jvnet.hudson:activation","org.jvnet:tiger-types","javax.servlet:jstl","javax.xml.stream:stax-api"]) {
32-
if (dependency.licenses.isEmpty())
33-
dependency.licenses=[cddl]
34-
}
35-
36-
/* TODO
37-
// according to JSR-250 1.0-20050927.133100 POM, it came from JAX-WS, which is under CDDL.
38-
match("javax.annotation:jsr250-api") {
39-
rewriteLicense([], cddl)
40-
}
41-
*/
41+
// GlassFish components are dual-licensed between CDDL and GPL+Classpath Exception
42+
// we elect to take them under CDDL.
43+
// note that central has a different POM from m.g.o-public (http://repo2.maven.org/maven2/javax/mail/mail/1.4/mail-1.4.pom
44+
// vs http://maven.glassfish.org/content/groups/public/javax/mail/mail/1.4/mail-1.4.pom), so we aren't using rewriteLicense here
45+
match([
46+
"javax.mail:*",
47+
"org.jvnet.hudson:activation",
48+
"org.jvnet:tiger-types",
49+
"javax.servlet:jstl",
50+
"javax.xml.stream:stax-api"
51+
]) {
52+
if (dependency.licenses.isEmpty())
53+
dependency.licenses=[cddl]
54+
}
4255

43-
match("org.jenkins-ci.dom4j:dom4j") {
44-
rewriteLicense([],license("BSD License","http://dom4j.sourceforge.net/dom4j-1.6.1/license.html"))
45-
}
56+
/* TODO
57+
// according to JSR-250 1.0-20050927.133100 POM, it came from JAX-WS, which is under CDDL.
58+
match("javax.annotation:jsr250-api") {
59+
rewriteLicense([], cddl)
60+
}
61+
*/
4662

47-
match(["org.jenkins-ci.groovy:*"]) {
48-
// see https://groovy-lang.org/faq.html
49-
// see http://jmdns.sourceforge.net/license.html
50-
rewriteLicense([],apacheLicense)
51-
}
63+
match("org.jenkins-ci.dom4j:dom4j") {
64+
rewriteLicense([], license("BSD License", "http://dom4j.sourceforge.net/dom4j-1.6.1/license.html"))
65+
}
5266

53-
match("relaxngDatatype:relaxngDatatype") {
54-
// see http://sourceforge.net/projects/relaxng/
55-
rewriteLicense([],bsdLicense)
56-
}
67+
match(["org.jenkins-ci.groovy:*"]) {
68+
// see https://groovy-lang.org/faq.html
69+
// see http://jmdns.sourceforge.net/license.html
70+
rewriteLicense([], apacheLicense)
71+
}
5772

58-
match(["org.kohsuke.jinterop:j-interop","org.kohsuke.jinterop:j-interopdeps"]) {
59-
rewriteLicense([license("MIT license", "http://www.opensource.org/licenses/mit-license.php")],license("LGPL v3","http://www.j-interop.org/license.html"))
60-
}
73+
match("relaxngDatatype:relaxngDatatype") {
74+
// see http://sourceforge.net/projects/relaxng/
75+
rewriteLicense([], bsdLicense)
76+
}
6177

62-
// these are our own modules that have license in the trunk but not in these released versions
63-
// as we upgrade them, we should just pick up the license info from POM
64-
match(["*:maven2.1-interceptor","*:lib-jenkins-maven-embedder"]) {
65-
rewriteLicense([],jenkinsLicense)
66-
}
78+
match(["org.kohsuke.jinterop:j-interop", "org.kohsuke.jinterop:j-interopdeps"]) {
79+
rewriteLicense([license("MIT license", "http://www.opensource.org/licenses/mit-license.php")], license("LGPL v3", "http://www.j-interop.org/license.html"))
80+
}
6781

68-
match("org.codehaus.plexus:plexus-interactivity-api") {
69-
rewriteLicense([],mitLicense)
70-
}
82+
// these are our own modules that have license in the trunk but not in these released versions
83+
// as we upgrade them, we should just pick up the license info from POM
84+
match(["*:maven2.1-interceptor", "*:lib-jenkins-maven-embedder"]) {
85+
rewriteLicense([], jenkinsLicense)
86+
}
7187

72-
match("de.zeigermann.xml:xml-im-exporter:1.1") {
73-
rewriteLicense([],license("BSD License","http://xml-im-exporter.cvs.sourceforge.net/viewvc/xml-im-exporter/xml-im-exporter/Copying.txt?revision=1.3&view=markup"))
74-
}
88+
match("org.codehaus.plexus:plexus-interactivity-api") {
89+
rewriteLicense([], mitLicense)
90+
}
7591

76-
match("*:sezpoz") {
77-
// GPL-phobia people react to "GPL" strongly, so accept sezpoz under CDDL
78-
rewriteLicense([license("CDDL or GPL 2 with Classpath Exception",null)],cddl)
79-
}
80-
81-
match("net.jcip:jcip-annotations") {
82-
rewriteLicense([],ccby)
83-
}
92+
match("de.zeigermann.xml:xml-im-exporter:1.1") {
93+
rewriteLicense([], license("BSD License", "http://xml-im-exporter.cvs.sourceforge.net/viewvc/xml-im-exporter/xml-im-exporter/Copying.txt?revision=1.3&view=markup"))
94+
}
95+
96+
match("*:sezpoz") {
97+
// GPL-phobia people react to "GPL" strongly, so accept sezpoz under CDDL
98+
rewriteLicense([license("CDDL or GPL 2 with Classpath Exception", null)], cddl)
99+
}
100+
101+
match("net.jcip:jcip-annotations") {
102+
rewriteLicense([], ccby)
103+
}
84104
}

pom.xml

+16
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,15 @@ THE SOFTWARE.
354354
<antlr4>
355355
<antlr4Formatter />
356356
</antlr4>
357+
<groovy>
358+
<includes>
359+
<include>Jenkinsfile</include>
360+
<include>licenseCompleter.groovy</include>
361+
</includes>
362+
<greclipse>
363+
<file>config/greclipse.properties</file>
364+
</greclipse>
365+
</groovy>
357366
<java>
358367
<endWithNewline />
359368
<importOrder />
@@ -374,6 +383,13 @@ THE SOFTWARE.
374383
</sortPom>
375384
</pom>
376385
</configuration>
386+
<dependencies>
387+
<dependency>
388+
<groupId>io.jenkins.lib</groupId>
389+
<artifactId>shared-resources</artifactId>
390+
<version>1.0</version>
391+
</dependency>
392+
</dependencies>
377393
<executions>
378394
<execution>
379395
<!-- Runs in verify phase by default -->

0 commit comments

Comments
 (0)