cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1457944 - in /cxf/trunk: maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java systests/databinding/pom.xml
Date Mon, 18 Mar 2013 19:53:42 GMT
Author: dkulp
Date: Mon Mar 18 19:53:42 2013
New Revision: 1457944

URL: http://svn.apache.org/r1457944
Log:
[CXF-3045] If the output generates non-java stuff, add them to the projects resources

Modified:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
    cxf/trunk/systests/databinding/pom.xml

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java?rev=1457944&r1=1457943&r2=1457944&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
Mon Mar 18 19:53:42 2013
@@ -50,6 +50,7 @@ import org.apache.maven.artifact.resolve
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Repository;
+import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -259,7 +260,8 @@ public abstract class AbstractCodegenMoh
         if (project != null && getGeneratedTestRoot() != null) {
             project.addTestCompileSourceRoot(getGeneratedTestRoot().getAbsolutePath());
         }
-
+        checkResources();
+        
         // if this is an m2e configuration build then return immediately without doing any
work
         if (project != null && buildContext.isIncremental() && !buildContext.hasDelta(project.getBasedir()))
{
             return;
@@ -325,6 +327,7 @@ public abstract class AbstractCodegenMoh
                                 originalProxyUser, originalProxyPassword);
         }
 
+        checkResources();
         // refresh the generated sources
         if (project != null && getGeneratedSourceRoot() != null && getGeneratedSourceRoot().exists())
{
             buildContext.refresh(getGeneratedSourceRoot().getAbsoluteFile());
@@ -335,6 +338,71 @@ public abstract class AbstractCodegenMoh
         System.gc();
     }
 
+    private void checkResources() {
+        File root = project.getBasedir();
+        Resource sourceRoot = null;
+        Resource testRoot = null;
+
+        File genroot = getGeneratedSourceRoot();
+        if (genroot != null) {
+            
+            List<Resource> resources = project.getBuild().getResources();
+            for (Resource r : resources) {
+                File d = new File(root, r.getDirectory());
+                if (d.equals(genroot)) {
+                    sourceRoot = r;
+                } 
+            }
+            Resource r2 = scanForResources(genroot, sourceRoot);
+            if (r2 != sourceRoot) {
+                r2.setDirectory(getGeneratedSourceRoot().getAbsolutePath());
+                r2.setTargetPath(project.getBuild().getOutputDirectory());
+                project.addResource(r2);
+            }
+        }
+        genroot = getGeneratedTestRoot();
+        if (genroot != null) {
+            List<Resource> resources = project.getBuild().getTestResources();
+            for (Resource r : resources) {
+                File d = new File(root, r.getDirectory());
+                if (d.equals(genroot)) {
+                    testRoot = r;
+                } 
+            }
+            Resource r2 = scanForResources(genroot, testRoot);
+            if (r2 != testRoot) {
+                r2.setDirectory(getGeneratedTestRoot().getAbsolutePath());
+                r2.setTargetPath(project.getBuild().getTestOutputDirectory());
+                project.addTestResource(r2);
+            }
+        }
+    }
+
+    private Resource scanForResources(File rootFile, Resource root) {
+        File files[] = rootFile.listFiles();
+        if (files == null) {
+            return root;
+        }
+        for (File f : files) {
+            if (f.isDirectory()) {
+                root = scanForResources(f, root);
+            } else if (!f.getName().endsWith(".java")) {
+                String n = f.getName();
+                int idx = n.lastIndexOf('.');
+                if (idx != -1) {
+                    n = "**/*" + n.substring(idx);
+                }
+                if (root == null) {
+                    root = new Resource();
+                }
+                if (!root.getIncludes().contains(n)) {
+                    root.addInclude(n);
+                }
+            }
+        }
+        return root;
+    }
+
     private void restoreProxySetting(String originalProxyHost, String originalProxyPort,
                                      String originalNonProxyHosts,
                                      String originalProxyUser,

Modified: cxf/trunk/systests/databinding/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/pom.xml?rev=1457944&r1=1457943&r2=1457944&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/pom.xml (original)
+++ cxf/trunk/systests/databinding/pom.xml Mon Mar 18 19:53:42 2013
@@ -70,31 +70,6 @@
                 </executions>
             </plugin>
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>copy-test-resources</id>
-                        <phase>process-test-sources</phase>
-                        <goals>
-                            <goal>copy-resources</goal>
-                        </goals>
-                        <configuration>
-                            <outputDirectory>${basedir}/target/test-classes/schemaorg_apache_xmlbeans</outputDirectory>
-                            <resources>
-                                <resource>
-                                    <directory>${basedir}/target/generated/src/test/java/schemaorg_apache_xmlbeans</directory>
-                                    <includes>
-                                        <include>**/*.xsb</include>
-                                        <include>**/*.class</include>
-                                        <include>**/*.wsdl</include>
-                                    </includes>
-                                </resource>
-                            </resources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.cxf</groupId>
                 <artifactId>cxf-codegen-plugin</artifactId>
                 <version>${project.version}</version>



Mime
View raw message