<?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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.camel.karaf</groupId>
        <artifactId>camel-karaf-components</artifactId>
        <version>4.9.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>camel-blueprint</artifactId>
    <packaging>bundle</packaging>
    <name>Apache Camel :: Karaf :: Components :: Blueprint</name>
    <properties>
        <firstVersion>2.4.0</firstVersion>
        <label>java,osgi</label>
        <camel.osgi.export>
            org.apache.camel.blueprint*;version=${project.version},
            org.apache.camel.util.blueprint*;version=${project.version}
        </camel.osgi.export>
        <camel.osgi.import>
            jakarta.xml.bind*;version="[3,5)",
            *
        </camel.osgi.import>
        <camel.osgi.private>
            org.glassfish.jaxb*
        </camel.osgi.private>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core-engine</artifactId>
            <version>${camel-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core-xml</artifactId>
            <version>${camel-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.karaf</groupId>
            <artifactId>camel-core-osgi</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xml-jaxp</artifactId>
            <version>${camel-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xml-jaxb</artifactId>
            <version>${camel-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-bean</artifactId>
            <version>${camel-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.bundle</groupId>
            <artifactId>org.apache.karaf.bundle.core</artifactId>
            <version>${karaf-version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.aries.blueprint</groupId>
            <artifactId>org.apache.aries.blueprint.core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.aries</groupId>
            <artifactId>org.apache.aries.util</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>target/schema</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <excludes>
                    <exclude>**/*.class</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.apache.camel.karaf</groupId>
                                <artifactId>camel-blueprint</artifactId>
                                <version>${project.version}</version>
                                <type>jar</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>${project.build.directory}/schema</outputDirectory>
                                <includes>camel-blueprint.xsd</includes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-package-maven-plugin</artifactId>
                <version>${camel-version}</version>
                <executions>
                    <execution>
                        <id>jaxb-list</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>generate-jaxb-list</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin-version}</version>
                <executions>
                    <execution>
                        <id>copy-generated-resources-jaxb</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${basedir}/target/generated/camel/jaxb</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-eip-documentation-enricher-maven-plugin</artifactId>
                <version>${camel-version}</version>
                <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}/schema/camel-blueprint.xsd</outputCamelSchemaFile>
                            <deleteFilesAfterRun>${project.build.directory}/schema/schema1.xsd,${project.build.directory}/schema/schema2.xsd</deleteFilesAfterRun>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>${maven-jaxb2-plugin-version}</version>
                <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>
                                <pattern>BeanModelDevConsole.java</pattern>
                            </patterns>
                        </filter>
                    </schemaSourceExcludeFilters>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- XML XSD schema generator -->
        <profile>
            <id>enable-schemagen</id>
            <activation>
                <property>
                    <name>!disable-schemagen</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- unpack sources which are needed for the scheme generator -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>process-sources</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.apache.camel</groupId>
                                            <artifactId>camel-api</artifactId>
                                            <version>${camel-version}</version>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/sources/camel-api</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.camel</groupId>
                                            <artifactId>camel-core-model</artifactId>
                                            <version>${camel-version}</version>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                            <overWrite>true</overWrite>
                                            <excludes>**/*nConfigurer.java</excludes>
                                            <outputDirectory>target/sources/camel-core-model</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.camel</groupId>
                                            <artifactId>camel-core-xml</artifactId>
                                            <version>${camel-version}</version>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/sources/camel-core-xml</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.camel</groupId>
                                            <artifactId>camel-util</artifactId>
                                            <version>${camel-version}</version>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/sources/camel-util</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.camel</groupId>
                                            <artifactId>camel-spring-xml</artifactId>
                                            <version>${camel-version}</version>
                                            <type>jar</type>
                                            <classifier>sources</classifier>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>target/sources/camel-spring</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>${maven-antrun-plugin-version}</version>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>process-sources</id>
                                <phase>process-classes</phase>
                                <configuration>
                                    <target>
                                        <!-- Workaround to fix the violation in CircuitBreakerDefinition -->
                                        <replace file="${project.build.directory}/sources/camel-core-model/org/apache/camel/model/CircuitBreakerDefinition.java" value="@jakarta.xml.bind.annotation.XmlTransient private OnFallbackDefinition">
                                            <replacetoken><![CDATA[@XmlElement
    private OnFallbackDefinition]]></replacetoken>
                                        </replace>
                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
                                        <echo>Copying to code together for the XSD generation</echo>
                                        <mkdir dir="${project.build.directory}/schema-src" />
                                        <mkdir dir="${project.build.directory}/schema" />
                                        <mkdir dir="${project.build.directory}/schema/META-INF/JAXB" />
                                        <copy todir="${project.build.directory}/schema-src">
                                            <fileset dir="${basedir}/src/main/java">
                                                <include name="org/apache/camel/blueprint/Camel*.java" />
                                                <include name="org/apache/camel/blueprint/ErrorHandler*.java" />
                                                <include name="org/apache/camel/blueprint/package-info.java" />
                                                <include name="org/apache/camel/util/blueprint/**/*.java" />
                                            </fileset>
                                            <fileset dir="${project.build.directory}/sources/camel-core-xml">
                                                <include name="org/apache/camel/core/xml/*.java" />
                                                <include name="org/apache/camel/core/xml/util/**/*.java" />
                                            </fileset>
                                            <fileset dir="${project.build.directory}/sources/camel-api">
                                                <include name="org/apache/camel/ExchangePattern.java" />
                                                <include name="org/apache/camel/LoggingLevel.java" />
                                                <include name="org/apache/camel/ManagementStatisticsLevel.java" />
                                                <include name="org/apache/camel/ShutdownRoute.java" />
                                                <include name="org/apache/camel/ShutdownRunningTask.java" />
                                                <include name="org/apache/camel/WaitForTaskToComplete.java" />
                                            </fileset>
                                            <fileset dir="${project.build.directory}/sources/camel-core-model">
                                                <include name="org/apache/camel/model/**/*.java" />
                                                <include name="org/apache/camel/package-info.java" />
                                                <exclude name="org/apache/camel/model/app/*.java" />
                                            </fileset>
                                            <fileset dir="${project.build.directory}/sources/camel-util">
                                                <include name="org/apache/camel/util/concurrent/ThreadPoolRejectedPolicy.java" />
                                            </fileset>
                                        </copy>
                                    </target>
                                    <exportAntProperties>true</exportAntProperties>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                            <!-- after the eip-documentation-enricher we need to copy some schema files -->
                            <execution>
                                <id>include-schemas</id>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <target>
                                        <echo>Copying XSD schema to be included in JAR</echo>
                                        <replace file="${project.build.directory}/schema/camel-blueprint.xsd" token="xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;" value="xs:schema xmlns=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;" />
                                        <replace file="${project.build.directory}/schema/camel-blueprint.xsd" token="http://camel.apache.org/schema/spring" value="http://camel.apache.org/schema/blueprint" />
                                        <copy todir="${project.build.directory}/classes">
                                            <fileset dir="${project.build.directory}/schema">
                                                <exclude name="**/*.class" />
                                            </fileset>
                                        </copy>
                                        <!-- copy modified schemas back again in classes so they are included in the JAR -->
                                        <fileset dir="${project.build.directory}/schema">
                                            <exclude name="**/*.class" />
                                        </fileset>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </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>./target/schema/camel-blueprint.xsd</file>
                                            <type>xsd</type>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
