Skip to content
This repository was archived by the owner on Jan 18, 2021. It is now read-only.

Commit dce776d

Browse files
committed
Make license used for pom configurable
1 parent aee8bfb commit dce776d

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

subprojects/shipkit/src/main/groovy/org/shipkit/gradle/configuration/ShipkitConfiguration.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ShipkitConfiguration {
2727
private final GitHub gitHub = new GitHub();
2828
private final Javadoc javadoc = new Javadoc();
2929
private final ReleaseNotes releaseNotes = new ReleaseNotes();
30+
private final LicenseInfo licenseInfo = new LicenseInfo();
3031
private final Git git = new Git();
3132
private final Team team = new Team();
3233

@@ -95,6 +96,10 @@ public ReleaseNotes getReleaseNotes() {
9596
return releaseNotes;
9697
}
9798

99+
public LicenseInfo getLicenseInfo() {
100+
return licenseInfo;
101+
}
102+
98103
public Git getGit() {
99104
return git;
100105
}
@@ -231,6 +236,24 @@ public void setWriteAuthToken(String writeAuthToken) {
231236
}
232237
}
233238

239+
public class LicenseInfo {
240+
public String getLicense() {
241+
return store.getString("licenseInfo.license");
242+
}
243+
244+
public void setLicense(String license) {
245+
store.put("licenseInfo.license", license);
246+
}
247+
248+
public String getUrl() {
249+
return store.getString("licenseInfo.url");
250+
}
251+
252+
public void setUrl(String url) {
253+
store.put("licenseInfo.url", url);
254+
}
255+
}
256+
234257
public class Javadoc {
235258
/**
236259
* GitHub Javadoc repository name, for example: "mockito/shipkit-javadoc".

subprojects/shipkit/src/main/groovy/org/shipkit/internal/gradle/util/PomCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ static void customizePom(Node root, ShipkitConfiguration conf,
7676
}
7777

7878
Node license = root.appendNode("licenses").appendNode("license");
79-
license.appendNode("name", "The MIT License");
80-
license.appendNode("url", repoLink + "/blob/master/LICENSE");
79+
license.appendNode("name", conf.getLicenseInfo().getLicense());
80+
license.appendNode("url", conf.getLicenseInfo().getUrl());
8181
license.appendNode("distribution", "repo");
8282

8383
root.appendNode("scm").appendNode("url", repoLink + ".git");

subprojects/shipkit/src/test/groovy/org/shipkit/internal/gradle/util/PomCustomizerTest.groovy

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class PomCustomizerTest extends Specification {
3434
//wwilk will not be duplicated in developers/contributors
3535
conf.team.contributors = ["mstachniuk:Marcin Stachniuk", "wwilk:Wojtek Wilk"]
3636

37+
conf.licenseInfo.license = "The MIT License"
38+
conf.licenseInfo.url = "https://github.com/repo/blob/master/LICENSE"
39+
3740
PomCustomizer.customizePom(node, conf, "foo", "Foo library", new DefaultProjectContributorsSet())
3841

3942
expect:
@@ -92,6 +95,10 @@ class PomCustomizerTest extends Specification {
9295
conf.gitHub.repository = "repo"
9396
conf.team.developers = ["mockitoguy:Szczepan Faber", "wwilk:Wojtek Wilk"]
9497
conf.team.contributors = []
98+
99+
conf.licenseInfo.license = "The MIT License"
100+
conf.licenseInfo.url = "https://github.com/repo/blob/master/LICENSE"
101+
95102
//wwilk will not be duplicated in developers/contributors
96103
def contributorsSet = new DefaultProjectContributorsSet()
97104
contributorsSet.addContributor(new DefaultProjectContributor("Wojtek Wilk", "wwilk", "https://github.com/wwilk", 5))
@@ -156,6 +163,9 @@ class PomCustomizerTest extends Specification {
156163
conf.team.developers = []
157164
conf.team.contributors = []
158165

166+
conf.licenseInfo.license = "The MIT License"
167+
conf.licenseInfo.url = "https://github.com/repo/blob/master/LICENSE"
168+
159169
PomCustomizer.customizePom(node, conf, "foo", "Foo library", new DefaultProjectContributorsSet())
160170

161171
expect:
@@ -186,6 +196,44 @@ class PomCustomizerTest extends Specification {
186196
"""
187197
}
188198

199+
def "use epl v2.0 license"() {
200+
conf.gitHub.repository = "repo"
201+
conf.team.developers = []
202+
conf.team.contributors = []
203+
204+
conf.licenseInfo.license = "Eclipse Public License v2.0"
205+
conf.licenseInfo.url = "http://www.eclipse.org/legal/epl-v20.html"
206+
207+
PomCustomizer.customizePom(node, conf, "foo", "Foo library", new DefaultProjectContributorsSet())
208+
209+
expect:
210+
printXml(node) == """<project>
211+
<name>foo</name>
212+
<packaging>jar</packaging>
213+
<url>https://github.com/repo</url>
214+
<description>Foo library</description>
215+
<licenses>
216+
<license>
217+
<name>Eclipse Public License v2.0</name>
218+
<url>http://www.eclipse.org/legal/epl-v20.html</url>
219+
<distribution>repo</distribution>
220+
</license>
221+
</licenses>
222+
<scm>
223+
<url>https://github.com/repo.git</url>
224+
</scm>
225+
<issueManagement>
226+
<url>https://github.com/repo/issues</url>
227+
<system>GitHub issues</system>
228+
</issueManagement>
229+
<ciManagement>
230+
<url>https://travis-ci.org/repo</url>
231+
<system>TravisCI</system>
232+
</ciManagement>
233+
</project>
234+
"""
235+
}
236+
189237
private static String printXml(Node node) {
190238
def sw = new StringWriter()
191239
def printer = new XmlNodePrinter(new PrintWriter(sw))

subprojects/shipkit/src/test/groovy/testutil/GradleSpecification.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ abstract class GradleSpecification extends Specification implements GradleVersio
5252
gitHub.readOnlyAuthToken = "foo"
5353
gitHub.repository = "repo"
5454
releaseNotes.publicationRepository = "repo"
55+
56+
licenseInfo.license = "The MIT License"
57+
licenseInfo.url = "https://github.com/repo/blob/master/LICENSE"
5558
}
5659
"""
5760

0 commit comments

Comments
 (0)