This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 139e158  CAMEL-14715: Use sources JARs for generating XSD in 
spring/blueprint so they can be separated.
139e158 is described below

commit 139e1581a9910a5cdf49a60b7db707b42712c514
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Mar 24 07:50:46 2020 +0100

    CAMEL-14715: Use sources JARs for generating XSD in spring/blueprint so 
they can be separated.
---
 components/camel-blueprint/pom.xml                 | 13 ++++--
 components/camel-spring/pom.xml                    | 20 ++++++---
 .../camel/maven/EipDocumentationEnricherMojo.java  | 49 +++++++++++++++-------
 3 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/components/camel-blueprint/pom.xml 
b/components/camel-blueprint/pom.xml
index 173783f..29abc44 100644
--- a/components/camel-blueprint/pom.xml
+++ b/components/camel-blueprint/pom.xml
@@ -375,7 +375,6 @@
                                             <classifier>sources</classifier>
                                             <overWrite>true</overWrite>
                                             
<outputDirectory>target/sources/camel-api</outputDirectory>
-                                            <includes>**/*.java</includes>
                                         </artifactItem>
                                         <artifactItem>
                                             <groupId>org.apache.camel</groupId>
@@ -385,7 +384,6 @@
                                             <classifier>sources</classifier>
                                             <overWrite>true</overWrite>
                                             
<outputDirectory>target/sources/camel-core-engine</outputDirectory>
-                                            <includes>**/*.java</includes>
                                         </artifactItem>
                                         <artifactItem>
                                             <groupId>org.apache.camel</groupId>
@@ -395,7 +393,6 @@
                                             <classifier>sources</classifier>
                                             <overWrite>true</overWrite>
                                             
<outputDirectory>target/sources/camel-core-xml</outputDirectory>
-                                            <includes>**/*.java</includes>
                                         </artifactItem>
                                         <artifactItem>
                                             <groupId>org.apache.camel</groupId>
@@ -405,7 +402,15 @@
                                             <classifier>sources</classifier>
                                             <overWrite>true</overWrite>
                                             
<outputDirectory>target/sources/camel-util</outputDirectory>
-                                            <includes>**/*.java</includes>
+                                        </artifactItem>
+                                        <artifactItem>
+                                            <groupId>org.apache.camel</groupId>
+                                            
<artifactId>camel-spring</artifactId>
+                                            
<version>${project.version}</version>
+                                            <type>jar</type>
+                                            <classifier>sources</classifier>
+                                            <overWrite>true</overWrite>
+                                            
<outputDirectory>target/sources/camel-spring</outputDirectory>
                                         </artifactItem>
                                     </artifactItems>
                                 </configuration>
diff --git a/components/camel-spring/pom.xml b/components/camel-spring/pom.xml
index d35e333..e503040 100644
--- a/components/camel-spring/pom.xml
+++ b/components/camel-spring/pom.xml
@@ -374,7 +374,6 @@
                                     <classifier>sources</classifier>
                                     <overWrite>true</overWrite>
                                     
<outputDirectory>target/sources/camel-api</outputDirectory>
-                                    <includes>**/*.java</includes>
                                 </artifactItem>
                                 <artifactItem>
                                     <groupId>org.apache.camel</groupId>
@@ -384,7 +383,6 @@
                                     <classifier>sources</classifier>
                                     <overWrite>true</overWrite>
                                     
<outputDirectory>target/sources/camel-core-engine</outputDirectory>
-                                    <includes>**/*.java</includes>
                                 </artifactItem>
                                 <artifactItem>
                                     <groupId>org.apache.camel</groupId>
@@ -394,7 +392,6 @@
                                     <classifier>sources</classifier>
                                     <overWrite>true</overWrite>
                                     
<outputDirectory>target/sources/camel-core-xml</outputDirectory>
-                                    <includes>**/*.java</includes>
                                 </artifactItem>
                                 <artifactItem>
                                     <groupId>org.apache.camel</groupId>
@@ -404,7 +401,6 @@
                                     <classifier>sources</classifier>
                                     <overWrite>true</overWrite>
                                     
<outputDirectory>target/sources/camel-util</outputDirectory>
-                                    <includes>**/*.java</includes>
                                 </artifactItem>
                             </artifactItems>
                         </configuration>
@@ -576,7 +572,6 @@
                 </executions>
             </plugin>
 
-            <!-- add the sources from camel-core-osgi and camel-core-xml as 
source code in the camel-spring-sources.jar -->
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>build-helper-maven-plugin</artifactId>
@@ -598,6 +593,21 @@
                     </execution>
                 </executions>
             </plugin>
+            <!-- generate sources JAR by default as this is needed by 
camel-blueprint -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.2.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>jar-no-fork</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.apache.camel</groupId>
                 
<artifactId>camel-eip-documentation-enricher-maven-plugin</artifactId>
diff --git 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
index 249f1e2..f490c3c 100644
--- 
a/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
+++ 
b/tooling/maven/camel-eip-documentation-enricher-maven-plugin/src/main/java/org/apache/camel/maven/EipDocumentationEnricherMojo.java
@@ -17,7 +17,6 @@
 package org.apache.camel.maven;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
@@ -34,6 +33,7 @@ import javax.xml.transform.stream.StreamResult;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathExpressionException;
 
+import org.apache.maven.project.MavenProject;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -57,6 +57,12 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
 public class EipDocumentationEnricherMojo extends AbstractMojo {
 
     /**
+     * The maven project.
+     */
+    @Parameter(property = "project", required = true, readonly = true)
+    protected MavenProject project;
+
+    /**
      * Path to camel EIP schema.
      */
     @Parameter(required = true)
@@ -71,37 +77,43 @@ public class EipDocumentationEnricherMojo extends 
AbstractMojo {
     /**
      * Path to camel core-engine project root directory.
      */
-    @Parameter(defaultValue = 
"${project.build.directory}/../../../core/camel-core-engine")
+    @Parameter(defaultValue = 
"${project.build.directory}/sources/camel-core-engine")
     public File camelCoreDir;
 
     /**
      * Path to camel core xml project root directory.
      */
-    @Parameter(defaultValue = 
"${project.build.directory}/../../../core/camel-core-xml")
+    @Parameter(defaultValue = 
"${project.build.directory}/sources/camel-core-xml")
     public File camelCoreXmlDir;
 
     /**
      * Path to camel spring project root directory.
      */
-    @Parameter(defaultValue = 
"${project.build.directory}/../../../components/camel-spring")
+    @Parameter(defaultValue = 
"${project.build.directory}/sources/camel-spring")
     public File camelSpringDir;
 
     /**
+     * Sub path to itself
+     */
+    @Parameter(defaultValue = "${project.build.directory}/classes")
+    public String targetDir;
+
+    /**
      * Sub path from camel core directory to model directory with generated 
json files for components.
      */
-    @Parameter(defaultValue = "target/classes/org/apache/camel/model")
+    @Parameter(defaultValue = "org/apache/camel/model")
     public String pathToModelDir;
 
     /**
      * Sub path from camel core xml directory to model directory with 
generated json files for components.
      */
-    @Parameter(defaultValue = "target/classes/org/apache/camel/core/xml")
+    @Parameter(defaultValue = "org/apache/camel/core/xml")
     public String pathToCoreXmlModelDir;
 
     /**
      * Sub path from camel spring directory to model directory with generated 
json files for components.
      */
-    @Parameter(defaultValue = "target/classes/org/apache/camel/spring")
+    @Parameter(defaultValue = "org/apache/camel/spring")
     public String pathToSpringModelDir;
 
     /**
@@ -122,16 +134,21 @@ public class EipDocumentationEnricherMojo extends 
AbstractMojo {
             return;
         }
 
+        // is current dir blueprint
+        boolean blueprint = targetDir != null && 
targetDir.contains("camel-blueprint");
+
         validateExists(inputCamelSchemaFile, "inputCamelSchemaFile");
         validateIsFile(inputCamelSchemaFile, "inputCamelSchemaFile");
         validateExists(camelCoreDir, "camelCoreDir");
         validateExists(camelCoreXmlDir, "camelCoreXmlDir");
-        validateExists(camelSpringDir, "camelSpringDir");
         validateIsDirectory(camelCoreDir, "camelCoreDir");
         validateIsDirectory(camelCoreXmlDir, "camelCoreXmlDir");
-        validateIsDirectory(camelSpringDir, "camelSpringDir");
+        if (blueprint) {
+            validateExists(camelSpringDir, "camelSpringDir");
+            validateIsDirectory(camelSpringDir, "camelSpringDir");
+        }
         try {
-            runPlugin();
+            runPlugin(blueprint);
         } catch (Exception e) {
             throw new MojoExecutionException("Error during plugin execution", 
e);
         }
@@ -140,7 +157,7 @@ public class EipDocumentationEnricherMojo extends 
AbstractMojo {
         }
     }
 
-    private void runPlugin() throws Exception {
+    private void runPlugin(boolean blueprint) throws Exception {
         Document document = 
XmlHelper.buildNamespaceAwareDocument(inputCamelSchemaFile);
         XPath xPath = XmlHelper.buildXPath(new CamelSpringNamespace());
         DomFinder domFinder = new DomFinder(document, xPath);
@@ -150,7 +167,11 @@ public class EipDocumentationEnricherMojo extends 
AbstractMojo {
         Set<File> files = new HashSet<>();
         PackageHelper.findJsonFiles(new File(camelCoreDir, pathToModelDir), 
files);
         PackageHelper.findJsonFiles(new File(camelCoreXmlDir, 
pathToCoreXmlModelDir), files);
-        PackageHelper.findJsonFiles(new File(camelSpringDir, 
pathToSpringModelDir), files);
+        if (blueprint) {
+            PackageHelper.findJsonFiles(new File(camelSpringDir, 
pathToSpringModelDir), files);
+        } else {
+            PackageHelper.findJsonFiles(new File(targetDir, 
pathToSpringModelDir), files);
+        }
         Map<String, File> jsonFiles = new HashMap<>();
         files.forEach(f -> jsonFiles.put(PackageHelper.asName(f.toPath()), f));
 
@@ -202,7 +223,7 @@ public class EipDocumentationEnricherMojo extends 
AbstractMojo {
                                                DocumentationEnricher 
documentationEnricher,
                                                File jsonFile,
                                                String type,
-                                               Set<String> injectedTypes) 
throws XPathExpressionException, IOException {
+                                               Set<String> injectedTypes) 
throws XPathExpressionException {
         if (injectedTypes.contains(type)) {
             return;
         }
@@ -241,7 +262,7 @@ public class EipDocumentationEnricherMojo extends 
AbstractMojo {
         return baseType.replace("tns:", "");
     }
 
-    private void saveToFile(Document document, File outputFile, Transformer 
transformer) throws FileNotFoundException, IOException, TransformerException {
+    private void saveToFile(Document document, File outputFile, Transformer 
transformer) throws IOException, TransformerException {
         try (FileOutputStream os = new FileOutputStream(outputFile)) {
             StreamResult result = new StreamResult(os);
             DOMSource source = new DOMSource(document);

Reply via email to