maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raf...@apache.org
Subject svn commit: r572008 - in /maven/sandbox/trunk/archetypeng: archetype-creator/src/main/java/org/apache/maven/archetype/creator/ archetype-creator/src/test/java/org/apache/maven/archetype/creator/ archetype-plugin/src/main/java/org/apache/maven/archetype...
Date Sun, 02 Sep 2007 15:52:22 GMT
Author: rafale
Date: Sun Sep  2 08:52:22 2007
New Revision: 572008

URL: http://svn.apache.org/viewvc?rev=572008&view=rev
Log:
Made the poms content replacement alternative between pomWriter and string.replace by adding
the -Darchetype.preserveCData property (default to false).
This aims to fix ARCHETYPE-87

Modified:
    maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
    maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
    maven/sandbox/trunk/archetypeng/archetype-creator/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
    maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeMojo.java

Modified: maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java?rev=572008&r1=572007&r2=572008&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreator.java
Sun Sep  2 08:52:22 2007
@@ -42,6 +42,7 @@
         List filtereds,
         String defaultEncoding,
         boolean ignoreReplica,
+        boolean preserveCData,
         File archetypeRegistryFile
     )
     throws IOException,

Modified: maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java?rev=572008&r1=572007&r2=572008&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetype-creator/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java
Sun Sep  2 08:52:22 2007
@@ -109,6 +109,7 @@
         List filtereds,
         String defaultEncoding,
         boolean ignoreReplica,
+        boolean preserveCData,
         File archetypeRegistryFile
     )
     throws IOException,
@@ -285,7 +286,8 @@
                     languages,
                     filtereds,
                     defaultEncoding,
-                    ignoreReplica
+                    ignoreReplica,
+                    preserveCData
                 );
 
             archetypeDescriptor.addModule ( moduleDescriptor );
@@ -305,7 +307,8 @@
             pom,
             archetypeFilesDirectory,
             pomReversedProperties,
-            FileUtils.resolveFile ( basedir, Constants.ARCHETYPE_POM )
+            FileUtils.resolveFile ( basedir, Constants.ARCHETYPE_POM ),
+            preserveCData
         );
         getLogger ().debug ( "Created Archetype " + archetypeDescriptor.getId () + " pom"
);
 
@@ -326,7 +329,7 @@
             "Archetype " + archetypeDescriptor.getId () + " old descriptor written"
         );
 
-        archetypeRegistryManager.addGroup ( archetypeConfiguration.getGroupId(), archetypeRegistryFile
);
+        archetypeRegistryManager.addGroup ( archetypeDefinition.getGroupId (), archetypeRegistryFile
);
     }
 
     private void addRequiredProperties (
@@ -558,35 +561,42 @@
         Model pom,
         File archetypeFilesDirectory,
         Properties pomReversedProperties,
-        File initialPomFile
+        File initialPomFile,
+        boolean preserveCData
     )
     throws IOException
     {
-//        pom.setParent ( null );
-//        pom.setModules ( null );
-//        pom.setGroupId ( "${" + Constants.GROUP_ID + "}" );
-//        pom.setArtifactId ( "${" + Constants.ARTIFACT_ID + "}" );
-//        pom.setVersion ( "${" + Constants.VERSION + "}" );
-
         File outputFile =
             FileUtils.resolveFile ( archetypeFilesDirectory, Constants.ARCHETYPE_POM );
 
-        File inputFile =
-            FileUtils.resolveFile ( archetypeFilesDirectory, Constants.ARCHETYPE_POM + ".tmp"
);
+        if ( preserveCData )
+        {
+            getLogger().debug("Preserving CDATA parts of pom");
+            File inputFile =
+                FileUtils.resolveFile ( archetypeFilesDirectory, Constants.ARCHETYPE_POM
+ ".tmp" );
 
-        FileUtils.copyFile ( initialPomFile, inputFile );
+            FileUtils.copyFile ( initialPomFile, inputFile );
 
-//        pomManager.writePom ( pom, inputFile );
+            String initialcontent = FileUtils.fileRead ( inputFile );
 
-        String initialcontent = FileUtils.fileRead ( inputFile );
+            String content = getReversedContent ( initialcontent, pomReversedProperties );
 
-        String content = getReversedContent ( initialcontent, pomReversedProperties );
+            outputFile.getParentFile ().mkdirs ();
 
-        outputFile.getParentFile ().mkdirs ();
+            FileUtils.fileWrite ( outputFile.getAbsolutePath (), content );
 
-        FileUtils.fileWrite ( outputFile.getAbsolutePath (), content );
+            inputFile.delete ();
+        }
+        else
+        {
+            pom.setParent ( null );
+            pom.setModules ( null );
+            pom.setGroupId ( "${" + Constants.GROUP_ID + "}" );
+            pom.setArtifactId ( "${" + Constants.ARTIFACT_ID + "}" );
+            pom.setVersion ( "${" + Constants.VERSION + "}" );
 
-        inputFile.delete ();
+            pomManager.writePom ( pom, outputFile );
+        }
     }
 
     private FileSet createFileSet (
@@ -709,7 +719,8 @@
         List languages,
         List filtereds,
         String defaultEncoding,
-        boolean ignoreReplica
+        boolean ignoreReplica,
+        boolean preserveCData
     )
     throws IOException, XmlPullParserException
     {
@@ -771,7 +782,8 @@
                     languages,
                     filtereds,
                     defaultEncoding,
-                    ignoreReplica
+                    ignoreReplica,
+                    preserveCData
                 );
 
             archetypeDescriptor.addModule ( moduleDescriptor );
@@ -787,7 +799,8 @@
             pom,
             archetypeFilesDirectory,
             pomReversedProperties,
-            FileUtils.resolveFile ( basedir, Constants.ARCHETYPE_POM )
+            FileUtils.resolveFile ( basedir, Constants.ARCHETYPE_POM ),
+            preserveCData
         );
         getLogger ().debug ( "Created Module " + archetypeDescriptor.getId () + " pom" );
 
@@ -798,35 +811,42 @@
         Model pom,
         File archetypeFilesDirectory,
         Properties pomReversedProperties,
-        File initialPomFile
+        File initialPomFile,
+        boolean preserveCData
     )
     throws IOException
     {
-//        pom.setParent ( null );
-//        pom.setModules ( null );
-//        pom.setGroupId ( "${" + Constants.GROUP_ID + "}" );
-//        pom.setArtifactId ( "${" + Constants.ARTIFACT_ID + "}" );
-//        pom.setVersion ( "${" + Constants.VERSION + "}" );
-
         File outputFile =
             FileUtils.resolveFile ( archetypeFilesDirectory, Constants.ARCHETYPE_POM );
 
-        File inputFile =
-            FileUtils.resolveFile ( archetypeFilesDirectory, Constants.ARCHETYPE_POM + ".tmp"
);
+        if ( preserveCData )
+        {
+            getLogger().debug("Preserving CDATA parts of pom");
+            File inputFile =
+                FileUtils.resolveFile ( archetypeFilesDirectory, Constants.ARCHETYPE_POM
+ ".tmp" );
 
-        FileUtils.copyFile ( initialPomFile, inputFile );
+            FileUtils.copyFile ( initialPomFile, inputFile );
+            String initialcontent = FileUtils.fileRead ( inputFile );
 
-//        pomManager.writePom ( pom, inputFile );
+            String content = getReversedContent ( initialcontent, pomReversedProperties );
 
-        String initialcontent = FileUtils.fileRead ( inputFile );
+            outputFile.getParentFile ().mkdirs ();
 
-        String content = getReversedContent ( initialcontent, pomReversedProperties );
+            FileUtils.fileWrite ( outputFile.getAbsolutePath (), content );
 
-        outputFile.getParentFile ().mkdirs ();
+            inputFile.delete ();
+        }
+        else
+        {
+            pom.setParent ( null );
+            pom.setModules ( null );
+            pom.setGroupId ( "${" + Constants.GROUP_ID + "}" );
+            pom.setArtifactId ( "${" + Constants.ARTIFACT_ID + "}" );
+            pom.setVersion ( "${" + Constants.VERSION + "}" );
 
-        FileUtils.fileWrite ( outputFile.getAbsolutePath (), content );
+            pomManager.writePom ( pom, outputFile );
+        }
 
-        inputFile.delete ();
     }
 
     private void createReplicaFiles ( List filesets, File basedir, File replicaFilesDirectory
)

Modified: maven/sandbox/trunk/archetypeng/archetype-creator/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-creator/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java?rev=572008&r1=572007&r2=572008&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-creator/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetype-creator/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
Sun Sep  2 08:52:22 2007
@@ -105,6 +105,7 @@
             filtereds,
             "UTF-8",
             true,
+            false,
             getFile (project, "archetype-registry.xml") 
         );
 

Modified: maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeMojo.java?rev=572008&r1=572007&r2=572008&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeMojo.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeMojo.java
Sun Sep  2 08:52:22 2007
@@ -74,6 +74,11 @@
     private boolean ignoreReplica = true;
 
     /**
+     * @parameter  expression="${archetype.preserveCData}"
+     */
+    private boolean preserveCData = false;
+
+    /**
      * @parameter  expression="${project}"
      * @required
      * @readonly
@@ -106,6 +111,7 @@
                 filtereds,
                 defaultEncoding,
                 ignoreReplica,
+                preserveCData,
                 archetypeRegistryFile
             );
         }



Mime
View raw message