ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r983788 - in /ant/ivy/core/trunk/src/java/org/apache/ivy: ant/IvyMakePom.java plugins/parser/m2/PomModuleDescriptorWriter.java plugins/parser/m2/PomWriterOptions.java
Date Mon, 09 Aug 2010 19:30:35 GMT
Author: maartenc
Date: Mon Aug  9 19:30:35 2010
New Revision: 983788

URL: http://svn.apache.org/viewvc?rev=983788&view=rev
Log:
Use dedicated options class to pass configuration options to PomModuleDescriptorWriter.

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomWriterOptions.java   (with
props)
Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyMakePom.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyMakePom.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyMakePom.java?rev=983788&r1=983787&r2=983788&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyMakePom.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyMakePom.java Mon Aug  9 19:30:35 2010
@@ -18,6 +18,7 @@
 package org.apache.ivy.ant;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.text.ParseException;
 import java.util.ArrayList;
@@ -28,6 +29,7 @@ import java.util.Map;
 
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter;
+import org.apache.ivy.plugins.parser.m2.PomWriterOptions;
 import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter.ConfigurationScopeMapping;
 import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
 import org.apache.ivy.util.FileUtil;
@@ -113,11 +115,7 @@ public class IvyMakePom extends IvyTask 
             }
             ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
                 getSettings(), ivyFile.toURI().toURL(), false);
-            PomModuleDescriptorWriter.write(md, splitConfs(conf),
-                headerFile == null ? null : FileUtil.readEntirely(getHeaderFile()),
-                mappings.isEmpty() 
-                    ? PomModuleDescriptorWriter.DEFAULT_MAPPING
-                    : new ConfigurationScopeMapping(getMappingsMap()), pomFile);
+            PomModuleDescriptorWriter.write(md, pomFile, getPomWriterOptions());
         } catch (MalformedURLException e) {
             throw new BuildException("unable to convert given ivy file to url: " + ivyFile
+ ": "
                     + e, e);
@@ -129,6 +127,23 @@ public class IvyMakePom extends IvyTask 
                     + " from=" + ivyFile + " to=" + pomFile, e);
         }
     }
+    
+    private PomWriterOptions getPomWriterOptions() throws IOException {
+        PomWriterOptions options = new PomWriterOptions();
+        options.setConfs(splitConfs(conf));
+        
+        if (mappings.isEmpty()) {
+            options.setMapping(PomModuleDescriptorWriter.DEFAULT_MAPPING);
+        } else {
+            options.setMapping(new ConfigurationScopeMapping(getMappingsMap()));
+        }
+        
+        if (headerFile != null) {
+            options.setLicenseHeader(FileUtil.readEntirely(getHeaderFile()));
+        }
+        
+        return options;
+    }
 
     private Map getMappingsMap() {
         Map mappingsMap = new HashMap();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java?rev=983788&r1=983787&r2=983788&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorWriter.java
Mon Aug  9 19:30:35 2010
@@ -48,8 +48,7 @@ public final class PomModuleDescriptorWr
     private PomModuleDescriptorWriter() {
     }
     
-    public static void write(ModuleDescriptor md, String[] confs,
-            String licenseHeader, ConfigurationScopeMapping mapping, File output)
+    public static void write(ModuleDescriptor md, File output, PomWriterOptions options)
             throws IOException {
         if (output.getParentFile() != null) {
             output.getParentFile().mkdirs();
@@ -58,8 +57,8 @@ public final class PomModuleDescriptorWr
                 "UTF-8"));
         try {
             out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-            if (licenseHeader != null) {
-                out.print(licenseHeader);
+            if (options.getLicenseHeader() != null) {
+                out.print(options.getLicenseHeader());
             }
             out.println("<!--"); 
             out.println("   Apache Maven 2 POM generated by Apache Ivy"); 
@@ -75,7 +74,7 @@ public final class PomModuleDescriptorWr
                     + "http://maven.apache.org/maven-v4_0_0.xsd\">\n");
             out.println("  <modelVersion>4.0.0</modelVersion>");
             printModuleId(md, out);
-            printDependencies(md, confs, mapping, out);
+            printDependencies(md, out, options);
             out.println("</project>");
         } finally {
             out.close();
@@ -121,10 +120,11 @@ public final class PomModuleDescriptorWr
         return null;
     }
 
-    private static void printDependencies(
-            ModuleDescriptor md, String[] confs, ConfigurationScopeMapping mapping, PrintWriter
out) {
-        DependencyDescriptor[] dds = getDependencies(md, confs);
+    private static void printDependencies(ModuleDescriptor md, PrintWriter out, 
+            PomWriterOptions options) {
+        DependencyDescriptor[] dds = getDependencies(md, options);
         if (dds.length > 0) {
+            ConfigurationScopeMapping mapping = options.getMapping();
             out.println("  <dependencies>");
             for (int i = 0; i < dds.length; i++) {
                 ModuleRevisionId mrid = dds[i].getDependencyRevisionId();
@@ -145,8 +145,9 @@ public final class PomModuleDescriptorWr
         }
     }
     
-    private static DependencyDescriptor[] getDependencies(ModuleDescriptor md, String[] confs)
{
-        confs = ConfigurationUtils.replaceWildcards(confs, md);
+    private static DependencyDescriptor[] getDependencies(ModuleDescriptor md, 
+            PomWriterOptions options) {
+        String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
 
         List result = new ArrayList();
         DependencyDescriptor[] dds = md.getDependencies();

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomWriterOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomWriterOptions.java?rev=983788&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomWriterOptions.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomWriterOptions.java Mon
Aug  9 19:30:35 2010
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.plugins.parser.m2;
+
+import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter.ConfigurationScopeMapping;
+
+public class PomWriterOptions {
+    private String[] confs;
+    
+    private String licenseHeader;
+    
+    private ConfigurationScopeMapping mapping;
+
+    public String[] getConfs() {
+        return confs;
+    }
+
+    public PomWriterOptions setConfs(String[] confs) {
+        this.confs = confs;
+        return this;
+    }
+
+    public String getLicenseHeader() {
+        return licenseHeader;
+    }
+
+    public PomWriterOptions setLicenseHeader(String licenseHeader) {
+        this.licenseHeader = licenseHeader;
+        return this;
+    }
+
+    public ConfigurationScopeMapping getMapping() {
+        return mapping;
+    }
+
+    public PomWriterOptions setMapping(ConfigurationScopeMapping mapping) {
+        this.mapping = mapping;
+        return this;
+    }
+    
+    
+    
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomWriterOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message