<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  Wildfly Camel Enricher
  %%
  Copyright (C) 2013 - 2014 RedHat
  %%
  Licensed 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.
  #L%
  -->


<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wildfly.camel</groupId>
        <artifactId>wildfly-camel-feature</artifactId>
        <version>10.0.0</version>
    </parent>

    <name>Wildfly Camel :: Feature :: Pack</name>

    <artifactId>wildfly-camel-feature-pack</artifactId>
    <packaging>pom</packaging>

    <properties>
        <license.dir>${project.basedir}/src/main/license-resources</license.dir>
        <galleon.license.resources.dir>${project.build.directory}/resources/content/docs/licenses-wildfly-camel</galleon.license.resources.dir>
        <galleon.licenses.xml.path>${galleon.license.resources.dir}/licenses.xml</galleon.licenses.xml.path>
        <wildfly.camel.dir>${project.build.directory}/wildfly-camel-${project.version}</wildfly.camel.dir>
        <wildfly-camel-feature-pack.basedir>${project.basedir}</wildfly-camel-feature-pack.basedir>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.camel</groupId>
                <artifactId>wildfly-camel-bom</artifactId>
                <version>${project.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.wildfly.camel</groupId>
            <artifactId>wildfly-camel-feature-modules</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wildfly.camel</groupId>
            <artifactId>wildfly-camel-feature-extrasA</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wildfly.camel</groupId>
            <artifactId>wildfly-camel-feature-extrasB</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.wildfly.camel</groupId>
            <artifactId>wildfly-camel-feature-extrasC</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jboss.galleon</groupId>
                <artifactId>galleon-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>provision-wildfly-camel</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <install-dir>${project.build.directory}/wildfly-camel-${project.version}</install-dir>
                            <record-state>false</record-state><!-- speedup by avoiding to save any state to .galleon dir  -->
                            <offline>false</offline>
                            <log-time>true</log-time>
                            <resolve-locals>
                                <resolve-local>
                                    <groupId>org.wildfly.camel</groupId>
                                    <artifactId>wildfly-camel-feature-modules</artifactId>
                                    <version>${project.version}</version>
                                </resolve-local>
                                <resolve-local>
                                    <groupId>org.wildfly.camel</groupId>
                                    <artifactId>wildfly-camel-feature-extrasA</artifactId>
                                    <version>${project.version}</version>
                                </resolve-local>
                                <resolve-local>
                                    <groupId>org.wildfly.camel</groupId>
                                    <artifactId>wildfly-camel-feature-extrasB</artifactId>
                                    <version>${project.version}</version>
                                </resolve-local>
                                <resolve-local>
                                    <groupId>org.wildfly.camel</groupId>
                                    <artifactId>wildfly-camel-feature-extrasC</artifactId>
                                    <version>${project.version}</version>
                                </resolve-local>
                            </resolve-locals>
                            <feature-packs>
                                <!-- We cannot provision wildfly-camel-feature-pack because it is not ready yet in the
                                     compile phase. But at the same time we need a module tree to
                                     run module-checker.groovy and to produce fuse-resources.txt used for licenses.xml.
                                     So we fall back to provisioning wildfly-camel-feature-extras[C,B] (which also
                                     installs A and modules). That's OK as long as wildfly-camel-feature-pack does not
                                     contain any JBoss modules. -->
                                <feature-pack>
                                    <groupId>org.wildfly.camel</groupId>
                                    <artifactId>wildfly-camel-feature-extrasB</artifactId>
                                    <version>${project.version}</version>
                                    <inherit-configs>false</inherit-configs>
                                    <inherit-packages>false</inherit-packages>
                                    <includedPackages>
                                        <includedPackage>modules.all</includedPackage><!-- we want only the modules directory -->
                                    </includedPackages>
                                </feature-pack>
                                <feature-pack>
                                    <groupId>org.wildfly.camel</groupId>
                                    <artifactId>wildfly-camel-feature-extrasC</artifactId>
                                    <version>${project.version}</version>
                                    <inherit-configs>false</inherit-configs>
                                    <inherit-packages>false</inherit-packages>
                                    <includedPackages>
                                        <includedPackage>modules.all</includedPackage><!-- we want only the modules directory -->
                                    </includedPackages>
                                </feature-pack>
                            </feature-packs>
                            <plugin-options>
                                <jboss-fork-embedded>false</jboss-fork-embedded>
                                <jboss-maven-dist>true</jboss-maven-dist>
                            </plugin-options>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-license-resources</id>
                        <phase>generate-test-sources</phase><!-- after license-maven-plugin@update-licenses-xml -->
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${galleon.license.resources.dir}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${license.dir}</directory>
                                    <includes>
                                        <include>licenses.xml</include>
                                        <include>licenses.xsl</include>
                                        <include>licenses.css</include>
                                    </includes>
                                    <filtering>false</filtering>
                                </resource>
                                <resource>
                                    <directory>${license.dir}/licenses</directory>
                                    <includes>
                                        <include>*</include>
                                    </includes>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>groovy-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>module-check</id>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <source>${project.basedir}/scripts/module-checker.groovy</source>
                        </configuration>
                    </execution>
                    <execution>
                        <id>create-dist-dir</id>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <source>// workaround for https://issues.jboss.org/browse/GAL-261
                              java.nio.file.Files.createDirectories(java.nio.file.Paths.get("${basedir}/target/wildfly-camel-9.2.0-SNAPSHOT"))
                            </source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.wildfly.galleon-plugins</groupId>
                <artifactId>wildfly-galleon-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>feature-pack-build</id>
                        <goals>
                            <goal>build-feature-pack</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.ec4j.maven</groupId>
                <artifactId>editorconfig-maven-plugin</artifactId>
                <configuration>
                    <excludes combine.children="append">
                        <exclude>src/main/license-resources/licenses/**</exclude>
                        <exclude>src/main/license-resources/licenses.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>update-licenses-xml</id>
            <activation>
                <property>
                    <name>!skip-update-licenses-xml</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>license-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>update-licenses-xml</id>
                                <goals>
                                    <goal>download-licenses</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <licensesConfigFile>${basedir}/etc/licenses/licenses-config.xml</licensesConfigFile>
                                    <licensesOutputDirectory>${license.dir}/licenses</licensesOutputDirectory>
                                    <licensesOutputFile>${license.dir}/licenses.xml</licensesOutputFile>
                                    <sortByGroupIdAndArtifactId>true</sortByGroupIdAndArtifactId>
                                    <errorRemedy>xmlOutput</errorRemedy>
                                    <!-- Uncomment or run with -Dlicense.cleanLicensesOutputDirectory=true to download all licenses anew -->
                                    <!-- <cleanLicensesOutputDirectory>true</cleanLicensesOutputDirectory> -->
                                    <artifactFiltersUrl>${project.baseUri}/target/fuse-resources.txt</artifactFiltersUrl>
                                    <socketTimeout>15000</socketTimeout>
                                    <useDefaultContentSanitizers>true</useDefaultContentSanitizers>
                                    <useDefaultUrlReplacements>true</useDefaultUrlReplacements>
                                    <licenseUrlReplacements>
                                        <licenseUrlReplacement>
                                            <regexp>\Qhttp://www.day.com/content/dam/day/downloads/jsr283/LICENSE.txt\E</regexp>
                                            <replacement>https://web.archive.org/web/20100220121505id_/http://www.day.com/content/dam/day/downloads/jsr283/LICENSE.txt</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>\Qhttp://www.day.com/dam/day/downloads/jsr283/day-spec-license.htm\E</regexp>
                                            <replacement>https://web.archive.org/web/20100220121453id_/http://www.day.com/dam/day/downloads/jsr283/day-spec-license.htm</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>\Qhttp://www.mozilla.org/MPL/MPL-1.1.txt\E</regexp>
                                            <replacement>https://www.mozilla.org/media/MPL/1.1/index.0c5913925d40.txt</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?://glassfish\.(dev\.)?java\.net/(nonav/)?public/CDDL\+GPL(_1_1)?\.html</regexp>
                                            <replacement>https://raw.githubusercontent.com/javaee/glassfish/master/LICENSE</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?\Q://glassfish.dev.java.net/\E(nonav/)?\Qpublic/CDDLv1.0.html\E</regexp>
                                            <replacement>https://opensource.org/licenses/CDDL-1.0</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?://(www\.)?opensource\.org/licenses/apache2.0(\.(php|html))?</regexp>
                                            <replacement>https://opensource.org/licenses/Apache-2.0</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?://(www\.)?opensource\.org/licenses/bsd-license(\.(php|html))?</regexp>
                                            <replacement>https://opensource.org/licenses/BSD-2-Clause</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?://(www\.)?opensource\.org/licenses/CDDL-1\.0\.php</regexp>
                                            <replacement>https://opensource.org/licenses/CDDL-1.0</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?://(www\.)?opensource\.org/licenses/cddl1(\.(php|html))?</regexp>
                                            <replacement>https://opensource.org/licenses/CDDL-1.0</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>https?://(www\.)?opensource\.org/licenses/mit-license(\.(php|html))?</regexp>
                                            <replacement>https://opensource.org/licenses/MIT</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>^https?://github\.com/([^/]+)/([^/]+)/blob/(.*)$</regexp>
                                            <replacement>https://raw.githubusercontent.com/$1/$2/$3</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>^https?://(www\.)?creativecommons.org/licenses/([^/]+)/([^/]+)/$</regexp>
                                            <replacement>http://creativecommons.org/licenses/$1/$2/legalcode</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>^https?://(www\.)?apache\.org/license/LICENSE-2\.0\.txt$</regexp>
                                            <replacement>https://www.apache.org/licenses/LICENSE-2.0.txt</replacement>
                                        </licenseUrlReplacement>
                                        <licenseUrlReplacement>
                                            <regexp>^https?://repository\.jboss\.com/licenses/lgpl\.txt$</regexp>
                                            <replacement>https://web.archive.org/web/20171202125112id_/http://repository.jboss.com/licenses/lgpl.txt</replacement>
                                        </licenseUrlReplacement>
                                    </licenseUrlReplacements>
                                    <licenseUrlFileNames>
                                        <spdx />
                                        <bsd-antlr.html>https?://(www\.)?antlr\.org/license\.html</bsd-antlr.html>
                                        <edl-v10.html>https?://(www\.)?eclipse\.org/org/documents/edl-v10\.php</edl-v10.html>
                                        <lgpl-3.0.txt>
                                            sha1:a8a12e6867d7ee39c21d9b11a984066099b6fb6b
                                            https?://(www\.)?gnu\.org/licenses/lgpl\.txt
                                            https?://(www\.)?fsf\.org/licensing/licenses/lgpl\.txt
                                        </lgpl-3.0.txt>
                                        <lgpl-2.1.txt>
                                            sha1:01a6b4bf79aca9b556822601186afab86e8c4fbf
                                            https?://(www\.)?gnu\.org/licenses/old-licenses/lgpl-2\.1\.txt
                                            https?://repository\.jboss\.org/licenses/lgpl-2\.1\.txt
                                        </lgpl-2.1.txt>
                                        <mit-license-auth0.txt>
                                            sha1:44258edfa65d99689f3b8e939a04fe98815dba66
                                            \Qhttps://raw.githubusercontent.com/auth0/java-jwt/master/LICENSE\E
                                        </mit-license-auth0.txt>
                                        <mit-license-pubnub.txt>
                                            sha1:898827e65f86217b02c921cdac8bfbe99d0f5429
                                            \Qhttps://raw.githubusercontent.com/jeevatkm/digitalocean-api-java/master/LICENSE\E
                                        </mit-license-pubnub.txt>
                                        <mit-license-jeevanandam-m.txt>
                                            sha1:2035018f22cb2d75bcc79d401cf3e2db78e99563
                                            \Qhttps://raw.githubusercontent.com/pubnub/pubnub-api/master/LICENSE\E
                                        </mit-license-jeevanandam-m.txt>
                                        <mit-license-pablo-fernandez.txt>
                                            sha1:8d7e620d498f99b3fc47c63a613ed1b3975c9564
                                            \Qhttps://raw.githubusercontent.com/scribejava/scribejava/master/LICENSE.txt\E
                                            \Qhttps://raw.githubusercontent.com/fernandezpablo85/scribe-java/master/LICENSE.txt\E
                                        </mit-license-pablo-fernandez.txt>
                                        <mit-license-pablo-fernandez.txt>
                                            sha1:f6c324a01dd4132f6a6ff75be9342676a2a4137a
                                            \Qhttps://raw.githubusercontent.com/xetorthio/jedis/master/LICENSE.txt\E
                                        </mit-license-pablo-fernandez.txt>
                                    </licenseUrlFileNames>
                                    <licenseUrlFileNameSanitizers>
                                        <licenseUrlFileNameSanitizer>
                                            <regexp>[\s-_,;]+</regexp>
                                            <replacement>-</replacement>
                                        </licenseUrlFileNameSanitizer>
                                        <licenseUrlFileNameSanitizer>
                                            <regexp>-($|\.)</regexp>
                                            <replacement>$1</replacement>
                                        </licenseUrlFileNameSanitizer>
                                    </licenseUrlFileNameSanitizers>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
