You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2011/05/22 19:00:10 UTC

svn commit: r1126084 - /incubator/isis/trunk/support/updateGeneratedArchetypeSources.groovy

Author: danhaywood
Date: Sun May 22 17:00:10 2011
New Revision: 1126084

URL: http://svn.apache.org/viewvc?rev=1126084&view=rev
Log:
improvements to updateGeneratedArchetypeSources.groovy

Modified:
    incubator/isis/trunk/support/updateGeneratedArchetypeSources.groovy

Modified: incubator/isis/trunk/support/updateGeneratedArchetypeSources.groovy
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/support/updateGeneratedArchetypeSources.groovy?rev=1126084&r1=1126083&r2=1126084&view=diff
==============================================================================
--- incubator/isis/trunk/support/updateGeneratedArchetypeSources.groovy (original)
+++ incubator/isis/trunk/support/updateGeneratedArchetypeSources.groovy Sun May 22 17:00:10 2011
@@ -29,11 +29,36 @@ def ROOT="quickstart/target/generated-so
 //
 /////////////////////////////////////////////////////
 
-def metaDataFile=new File(ROOT+"META-INF/maven/archetype-metadata.xml")
+def license_using_xml_comments="""<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+"""
+
+def metaDataFile=new File(ROOT+"META-INF/maven/archetype-metadata.xml")
 
 println "updating ${metaDataFile.path}"
+
+
+// read file, ignoring XML pragma
+def metaDataFileText = stripXmlPragma(metaDataFile)
 
-def metaDataXml = new XmlSlurper().parseText(metaDataFile.text)
+def metaDataXml = new XmlSlurper().parseText(metaDataFileText)
 metaDataXml.modules.module.fileSets.fileSet.each { fileSet ->
     if(fileSet.directory=='ide/eclipse') {
         fileSet.@filtered='true'
@@ -56,9 +81,21 @@ String indentXml(xml) {
     transformer.transform(new StreamSource(new ByteArrayInputStream(xml.toString().bytes)), result)
     return result.writer.toString()
 }
-
-
-metaDataFile.text = indentXml(metaDataSmb.toString())
+
+String stripXmlPragma(File file) {
+    def sw = new StringWriter()
+    file.filterLine(sw) { ! (it =~ /^\<\?xml/ ) }
+    return sw.toString()
+}
+
+def tempFile = File.createTempFile("temp",".xml")
+tempFile.text = indentXml(metaDataSmb.toString())
+def xmlText = stripXmlPragma(tempFile)
+
+
+metaDataFile.text = 
+    license_using_xml_comments + 
+    xmlText
 
 
 /////////////////////////////////////////////////////