11package 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 ;
63import org .apache .ivy .core .module .id .ModuleId ;
74import org .apache .ivy .core .module .id .ModuleRevisionId ;
85import org .apache .ivy .core .report .ArtifactDownloadReport ;
96import org .w3c .dom .Document ;
107import org .w3c .dom .Element ;
11- import org .w3c .dom .Node ;
128import org .w3c .dom .NodeList ;
139import 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 ;
1515import tablesaw .addons .java .JavaProgram ;
1616import tablesaw .rules .AbstractRule ;
1717import tablesaw .rules .Rule ;
2828import javax .xml .transform .dom .DOMSource ;
2929import javax .xml .transform .stream .StreamResult ;
3030import 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 }
0 commit comments