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

Commit

Permalink
Merge pull request #854 from mockito/fix-847
Browse files Browse the repository at this point in the history
Fixed the pom packaging bug
  • Loading branch information
mockitoguy authored Jan 13, 2020
2 parents f2ab193 + 80fa1ef commit bc1eb92
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.shipkit.internal.gradle.util;

import groovy.xml.QName;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.XmlProvider;
Expand Down Expand Up @@ -67,8 +68,12 @@ static void customizePom(Node root, ShipkitConfiguration conf,
String projectName, String projectDescription,
ProjectContributorsSet contributorsFromGitHub) {
//Assumes project has java plugin applied. Pretty safe assumption
//TODO: we need to conditionally append nodes because given node may already be on the root (issue 847)
//TODO: all root.appendNode() need to be conditional
root.appendNode("name", projectName);
root.appendNode("packaging", "jar");
if (root.getAt(new QName("packaging")).isEmpty()) {
root.appendNode("packaging", "jar");
}

String repoLink = conf.getGitHub().getUrl() + "/" + conf.getGitHub().getRepository();
root.appendNode("url", repoLink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.testfixtures.ProjectBuilder
import org.shipkit.gradle.configuration.ShipkitConfiguration
import org.shipkit.internal.notes.contributors.DefaultProjectContributor
import org.shipkit.internal.notes.contributors.DefaultProjectContributorsSet
import spock.lang.Issue
import spock.lang.Specification

class PomCustomizerTest extends Specification {
Expand Down Expand Up @@ -254,6 +255,41 @@ class PomCustomizerTest extends Specification {
"""
}

@Issue("847")
def "preconfigured pom"() {
conf.gitHub.repository = "repo"
node.appendNode("packaging", "unbundled");

PomCustomizer.customizePom(node, conf, "foo", "Foo library", new DefaultProjectContributorsSet())

expect:
printXml(node) == """<project>
<packaging>unbundled</packaging>
<name>foo</name>
<url>https://github.com/repo</url>
<description>Foo library</description>
<licenses>
<license>
<name>The MIT License</name>
<url>https://github.com/repo/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/repo.git</url>
</scm>
<issueManagement>
<url>https://github.com/repo/issues</url>
<system>GitHub issues</system>
</issueManagement>
<ciManagement>
<url>https://travis-ci.org/repo</url>
<system>TravisCI</system>
</ciManagement>
</project>
"""
}

private static String printXml(Node node) {
def sw = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(sw))
Expand Down

0 comments on commit bc1eb92

Please sign in to comment.