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

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

commit 45eb0e0c493f958d703f3f51070a9dc02dca882c
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed May 14 11:47:40 2025 +0200

    CAMEL-22064: camel-xml-io - Generate XSD schema
---
 core/camel-xml-io/pom.xml | 102 ++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 89 insertions(+), 13 deletions(-)

diff --git a/core/camel-xml-io/pom.xml b/core/camel-xml-io/pom.xml
index 6f0543f0061..e033216fa28 100644
--- a/core/camel-xml-io/pom.xml
+++ b/core/camel-xml-io/pom.xml
@@ -79,6 +79,17 @@
     </dependencies>
 
     <build>
+        <resources>
+            <resource>
+                <directory>target/schema</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+                <excludes>
+                    <exclude>**/*.class</exclude>
+                </excludes>
+            </resource>
+        </resources>
         <plugins>
             <plugin>
                 <groupId>org.apache.camel</groupId>
@@ -96,6 +107,34 @@
             </plugin>
 
             <!-- generate XSD -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jaxb2-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-schema</id>
+                        <phase>generate-test-sources</phase>
+                        <goals>
+                            <goal>schemagen</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    
<outputDirectory>${project.build.directory}/schema</outputDirectory>
+                    <sources>
+                        <source>${project.build.directory}/schema-src</source>
+                    </sources>
+                    <createJavaDocAnnotations>false</createJavaDocAnnotations>
+                    <schemaSourceExcludeFilters>
+                        <filter 
implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
+                            <patterns>
+                                <pattern>Helper.java</pattern>
+                                <pattern>Adapter.java</pattern>
+                            </patterns>
+                        </filter>
+                    </schemaSourceExcludeFilters>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
@@ -114,6 +153,9 @@
                                 <propertyregex property="ov.p2a" 
input="${ov.p2}" regexp="(\..+)" replace="\1" defaultValue=".0" />
                                 <property name="camel.schema.version" 
value="${ov.p1a}${ov.p2a}" />
                                 <mkdir dir="target" />
+                                <echo file="target/camel.osgi.version.txt">
+                                    camel.schema.version = 
${camel.schema.version}
+                                </echo>
                             </target>
                         </configuration>
                         <goals>
@@ -146,6 +188,7 @@
                                     <fileset 
dir="${project.basedir}/../camel-core-model/src/main/java">
                                         <include 
name="org/apache/camel/model/**/*.java" />
                                         <include 
name="org/apache/camel/package-info.java" />
+                                        <exclude 
name="org/apache/camel/model/console/**" />
                                     </fileset>
                                     <fileset 
dir="${project.basedir}/../camel-util/src/main/java">
                                         <include 
name="org/apache/camel/concurrent/ThreadPoolRejectedPolicy.java" />
@@ -163,16 +206,10 @@
                         <phase>prepare-package</phase>
                         <configuration>
                             <target>
-                                <echo>Copying XSD schema to be included in 
JAR</echo>
-                                <copy 
file="${project.build.directory}/classes/camel-spring.xsd" 
tofile="${project.build.directory}/schema/camel-xml-io.xsd" 
preservelastmodified="true" />
-                                <copy 
file="${project.build.directory}/classes/camel-spring.xsd" 
tofile="${project.build.directory}/schema/camel-xml-io-v${camel.schema.version}.xsd"
 preservelastmodified="true" />
-                                <replace 
file="${project.build.directory}/schema/camel-xml-io-v${camel.schema.version}.xsd"
 token="&quot;http://camel.apache.org/schema/spring&quot;"; 
value="&quot;http://camel.apache.org/schema/xml-io/v${camel.schema.version}&quot;";
 preservelastmodified="true" />
-                                <!-- copy modified schemas back again in 
classes so they are included in the JAR -->
-                                <copy 
todir="${project.build.directory}/classes" preservelastmodified="true">
-                                    <fileset 
dir="${project.build.directory}/schema">
-                                        <exclude name="**/*.class" />
-                                    </fileset>
-                                </copy>
+                                <echo>Updating namespace in XSD schema</echo>
+                                <replace 
file="${project.build.directory}/classes/camel-xml-io.xsd" 
token="&quot;http://camel.apache.org/schema/spring&quot;"; 
value="&quot;http://camel.apache.org/schema/xml-io&quot;"; 
preservelastmodified="true" />
+                                <copy 
file="${project.build.directory}/classes/camel-xml-io.xsd" 
tofile="${project.build.directory}/classes/camel-xml-io-v${camel.schema.version}.xsd"
 preservelastmodified="true" />
+                                <replace 
file="${project.build.directory}/classes/camel-xml-io-v${camel.schema.version}.xsd"
 token="&quot;http://camel.apache.org/schema/xml-io&quot;"; 
value="&quot;http://camel.apache.org/schema/xml-io/v${camel.schema.version}&quot;";
 preservelastmodified="true" />
                             </target>
                         </configuration>
                         <goals>
@@ -181,6 +218,24 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>properties-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>init-camel-schema-version-property-from-file</id>
+                        <phase>initialize</phase>
+                        <goals>
+                            <goal>read-project-properties</goal>
+                        </goals>
+                        <configuration>
+                            <files>
+                                <file>target/camel.osgi.version.txt</file>
+                            </files>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.apache.camel</groupId>
                 
<artifactId>camel-eip-documentation-enricher-maven-plugin</artifactId>
@@ -188,15 +243,15 @@
                 <executions>
                     <execution>
                         <id>eip-documentation-enricher</id>
-                        <!-- need to run earlier so we use the 
process-test-resources phase -->
                         <phase>process-test-resources</phase>
                         <goals>
                             <goal>eip-documentation-enricher</goal>
                         </goals>
                         <configuration>
                             
<inputCamelSchemaFile>${project.build.directory}/schema/schema1.xsd</inputCamelSchemaFile>
-                            
<outputCamelSchemaFile>${project.build.directory}/classes/camel-xml-io.xsd
-                            </outputCamelSchemaFile>
+                            
<outputCamelSchemaFile>${project.build.directory}/classes/camel-xml-io.xsd</outputCamelSchemaFile>
+                            
<camelCoreModelDir>${project.basedir}/../camel-core-model</camelCoreModelDir>
+                            
<camelCoreXmlDir>${project.basedir}/../camel-core-xml</camelCoreXmlDir>
                             <deleteFilesAfterRun>
                                 
${project.build.directory}/schema/schema1.xsd,${project.build.directory}/schema/schema2.xsd
                             </deleteFilesAfterRun>
@@ -204,6 +259,27 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    
<file>${project.build.directory}/classes/camel-xml-io.xsd</file>
+                                    <type>xsd</type>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 

Reply via email to