Skip to content

Commit 8486ff2

Browse files
author
jsabin
committed
Updated to Java 8. Added compile plugin to specify the version of Java in the pom. ArtifactId is now set correctly for <exclude> in dependency.
1 parent 536bcd5 commit 8486ff2

File tree

7 files changed

+80
-17
lines changed

7 files changed

+80
-17
lines changed

build.bsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jc = jp.getCompileRule();
111111
jc.addClasspath(classpath);
112112
jc.addSource(versionSrcFile);
113113
jc.addDepend(versionRule);
114-
jc.getDefinition().set("target", "1.5");
114+
jc.getDefinition().set("target", "1.8");
115115

116116
jp.getTestCompileRule().addClasspath(classpath);
117117

src/main/java/tablesaw/addons/ivy/PomRule.java

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package tablesaw.addons.ivy;
22

3-
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
4-
import org.apache.ivy.core.module.descriptor.ExcludeRule;
5-
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
63
import org.apache.ivy.core.module.id.ModuleId;
74
import org.apache.ivy.core.module.id.ModuleRevisionId;
85
import org.apache.ivy.core.report.ArtifactDownloadReport;
96
import org.w3c.dom.Document;
107
import org.w3c.dom.Element;
11-
import org.w3c.dom.Node;
128
import org.w3c.dom.NodeList;
139
import org.xml.sax.SAXException;
14-
import tablesaw.*;
10+
import tablesaw.BuildCallback;
11+
import tablesaw.MakeAction;
12+
import tablesaw.ScriptCallback;
13+
import tablesaw.Tablesaw;
14+
import tablesaw.TablesawException;
1515
import tablesaw.addons.java.JavaProgram;
1616
import tablesaw.rules.AbstractRule;
1717
import tablesaw.rules.Rule;
@@ -28,8 +28,19 @@
2828
import javax.xml.transform.dom.DOMSource;
2929
import javax.xml.transform.stream.StreamResult;
3030
import javax.xml.transform.stream.StreamSource;
31-
import java.io.*;
32-
import java.util.*;
31+
import java.io.BufferedReader;
32+
import java.io.BufferedWriter;
33+
import java.io.File;
34+
import java.io.FileWriter;
35+
import java.io.IOException;
36+
import java.io.InputStream;
37+
import java.io.StringReader;
38+
import java.io.StringWriter;
39+
import java.util.ArrayList;
40+
import java.util.Collections;
41+
import java.util.HashMap;
42+
import java.util.List;
43+
import java.util.Map;
3344

3445
/**
3546
Created with IntelliJ IDEA.
@@ -44,7 +55,7 @@ public class PomRule extends AbstractRule<PomRule>
4455
public static final String ARTIFACT_ID_PROPERTY = JavaProgram.PROGRAM_NAME_PROPERTY;
4556

4657
public static final String GROUP_ID_PROPERTY = "tablesaw.java.ivy.group_id";
47-
58+
4859
public static final String VERSION_PROPERTY = JavaProgram.PROGRAM_VERSION_PROPERTY;
4960

5061
public static final String PACKAGING_PROPERTY = "tablesaw.java.ivy.packaging";
@@ -94,6 +105,18 @@ public class PomRule extends AbstractRule<PomRule>
94105

95106
s_indentMap.put("<exclusion", 1);
96107
s_indentMap.put("</exclusion", -1);
108+
109+
s_indentMap.put("<build", 1);
110+
s_indentMap.put( "</build", -1);
111+
112+
s_indentMap.put("<plugins", 1);
113+
s_indentMap.put("</plugins", -1);
114+
115+
s_indentMap.put("<plugin", 1);
116+
s_indentMap.put("</plugin", -1);
117+
118+
s_indentMap.put("<configuration", 1);
119+
s_indentMap.put("</configuration", -1);
97120
}
98121

99122

@@ -113,6 +136,7 @@ public class PomRule extends AbstractRule<PomRule>
113136
private String m_url;
114137
private String m_scmUrl;
115138
private String m_scmConnection;
139+
private String m_javaVersion;
116140

117141

118142
private List<Triple<String, String, String>> m_licenses;
@@ -232,7 +256,39 @@ private void setDevelopers(Document document)
232256
}
233257
}
234258

235-
private void setTransParam(Transformer transformer, String property, String value)
259+
private void setJavaVersion(Document document)
260+
{
261+
if (m_javaVersion != null && m_javaVersion.length() > 0)
262+
{
263+
Element rootNode = document.getDocumentElement();
264+
Element build = document.createElementNS(MAVEN_NS, "build");
265+
rootNode.appendChild(build);
266+
267+
Element plugins = document.createElementNS(MAVEN_NS, "plugins");
268+
build.appendChild(plugins);
269+
270+
Element plugin = document.createElementNS(MAVEN_NS, "plugin");
271+
plugins.appendChild(plugin);
272+
273+
Element groupId = document.createElementNS(MAVEN_NS, "groupId");
274+
groupId.setTextContent("org.apache.maven.plugins");
275+
Element artifactId = document.createElementNS(MAVEN_NS, "artifactId");
276+
artifactId.setTextContent("maven-compiler-plugin");
277+
Element configuration = document.createElementNS(MAVEN_NS, "configuration");
278+
plugin.appendChild(groupId);
279+
plugin.appendChild(artifactId);
280+
plugin.appendChild(configuration);
281+
282+
Element source = document.createElementNS(MAVEN_NS, "source");
283+
source.setTextContent(m_javaVersion);
284+
Element target = document.createElementNS(MAVEN_NS, "target");
285+
target.setTextContent(m_javaVersion);
286+
configuration.appendChild(source);
287+
configuration.appendChild(target);
288+
}
289+
}
290+
291+
private void setTransParam(Transformer transformer, String property, String value)
236292
{
237293
if ((value == null) || (value.equals("")))
238294
return;
@@ -312,6 +368,7 @@ else if (resolvedDependencies.get(moduleRevisionId).equals(TEST_SCOPE))
312368

313369
setLicenses(doc);
314370
setDevelopers(doc);
371+
setJavaVersion(doc);
315372

316373
if (m_domCallback != null)
317374
m_domCallback.doCallback(doc);
@@ -451,4 +508,10 @@ public PomRule setPomScmConnection(String scmConnection)
451508
m_scmConnection = scmConnection;
452509
return this;
453510
}
511+
512+
public PomRule setJavaVersion(String javaVersion)
513+
{
514+
m_javaVersion = javaVersion;
515+
return this;
516+
}
454517
}

src/main/java/tablesaw/addons/ivy/pom.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This file is read only. Generated by the Tablesaw Ivy plugin.
6666
<groupId>*</groupId>
6767
</xsl:otherwise>
6868
</xsl:choose>
69-
<artifactId><xsl:value-of select="@module"/></artifactId>
69+
<artifactId><xsl:value-of select="@name"/></artifactId>
7070
</exclusion>
7171
</xsl:for-each>
7272
</exclusions>

src/main/java/tablesaw/rules/AbstractSourceRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public T addSources(Object... sources)
7878
if ((sources.length == 1) && (sources[0] instanceof Iterable))
7979
return (addSources((Iterable<Object>)sources[0]));
8080
else if ((sources.length == 1) && (sources[0] instanceof AbstractFileSet))
81-
return (addSources(((AbstractFileSet)sources[0]).getFullFilePaths()));
81+
return (T) addSources(((AbstractFileSet)sources[0]).getFullFilePaths());
8282
else
8383
return (addSources(Arrays.asList(sources)));
8484
}

test/resources/generated_pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This file is read only. Generated by the Tablesaw Ivy plugin.
5454
</exclusion>
5555
<exclusion>
5656
<groupId>joda-time</groupId>
57-
<artifactId>joda-time</artifactId>
57+
<artifactId>joda-time-api</artifactId>
5858
</exclusion>
5959
</exclusions>
6060
</dependency>

test/resources/generated_test_pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This file is read only. Generated by the Tablesaw Ivy plugin.
6060
</exclusion>
6161
<exclusion>
6262
<groupId>joda-time</groupId>
63-
<artifactId>joda-time</artifactId>
63+
<artifactId>joda-time-api</artifactId>
6464
</exclusion>
6565
</exclusions>
6666
</dependency>

test/resources/ivy.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
<dependency org="org.hectorclient" name="hector-core" rev="1.1-4">
1717
<artifact name="hector-core" type="bundle" ext="jar"/>
18-
<exclude org="javax.servlet" module="servlet-api"/>
18+
<exclude org="javax.servlet" name="servlet-api"/>
1919
</dependency>
2020

2121
<dependency org="org.hectorclient" name="hector-object-mapper" rev="3.1-09">
22-
<exclude module="cassandra-all"/>
23-
<exclude org="joda-time" module="joda-time"/>
22+
<exclude name="cassandra-all"/>
23+
<exclude org="joda-time" name="joda-time-api"/>
2424
</dependency>
2525

2626
</dependencies>

0 commit comments

Comments
 (0)