<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2013 Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags.
  ~
  ~ 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.
  -->

<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">

    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>21</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.wildfly.security</groupId>
    <artifactId>wildfly-elytron-tool</artifactId>
    <version>1.0.0.Final</version>
    <packaging>jar</packaging>

    <name>WildFly Elytron Tool</name>
    <description>Set of tools for WildFly Elytron</description>
    <url>https://github.com/wildfly-security/wildfly-elytron-tool</url>

    <issueManagement>
        <system>Jira</system>
        <url>https://issues.jboss.org/browse/ELY</url>
    </issueManagement>

    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:wildfly-security/wildfly-elytron-tool.git</connection>
        <url>https://github.com/wildfly-security/wildfly-elytron-tool</url>
    </scm>

    <properties>
        <version.elytron>1.1.0.Final</version.elytron>
        <version.commons-cli>1.3.1</version.commons-cli>
        <version.org.jboss.logging>3.3.1.Final</version.org.jboss.logging>
        <version.org.jboss.logmanager>2.0.6.Final</version.org.jboss.logmanager>
        <version.org.jboss.logmanager.log4j-jboss>1.1.3.Final</version.org.jboss.logmanager.log4j-jboss>
        <version.org.jboss.logging.tools>2.0.1.Final</version.org.jboss.logging.tools>
        <version.org.jboss.slf4j>1.0.3.GA</version.org.jboss.slf4j>
        <version.org.kohsuke.metainf-services.metainf-services>1.7</version.org.kohsuke.metainf-services.metainf-services>
        <version.junit.junit>4.11</version.junit.junit>
        <version.jmockit>1.22</version.jmockit>
        <version.org.wildfly.checkstyle-config>1.0.6.Final</version.org.wildfly.checkstyle-config>
        <version.org.wildfly.client.config>1.0.0.Final</version.org.wildfly.client.config>
        <version.org.wildfly.common>1.2.0.Final</version.org.wildfly.common>
        <version.org.apache.commons>3.5</version.org.apache.commons>

        <test.level>INFO</test.level>
        <!-- Checkstyle configuration -->
        <linkXRef>false</linkXRef>

        <version.shade.plugin>3.0.0</version.shade.plugin>

        <!-- version from jboss-parent is 6.15 but then some checks fail -->
        <version.checkstyle>6.8</version.checkstyle>
        <!-- Modularized JDK support (various workarounds) - activated via profile -->
        <modular.jdk.args/>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <resources>
            <resource>
                <directory>${project.build.sourceDirectory}</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xsd</include>
                    <include>META-INF/LICENSE.txt</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <!-- Shade -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>${version.shade.plugin}</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <createDependencyReducedPom>false</createDependencyReducedPom>
                                <artifactSet>
                                    <excludes>
                                        <exclude>junit:junit</exclude>
                                        <exclude>jmock:*</exclude>
                                        <exclude>*:xml-apis</exclude>
                                        <exclude>org.apache.maven:lib:tests</exclude>
                                        <exclude>log4j:log4j:jar:</exclude>
                                    </excludes>
                                </artifactSet>
                                <filters>
                                    <filter>
                                        <artifact>org.wildfly.security:wildfly-elytron</artifact>
                                        <excludes>
                                            <exclude>schema/*.xsd</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>org.wildfly.security.tool.ElytronTool</mainClass>
                                    </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <!-- Surefire -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${version.surefire.plugin}</version>
                    <configuration>
                        <systemPropertyVariables>
                            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                            <log4j.defaultInitOverride>true</log4j.defaultInitOverride>
                            <test.level>${test.level}</test.level>
                        </systemPropertyVariables>
                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        <enableAssertions>true</enableAssertions>
                        <trimStackTrace>false</trimStackTrace>
                        <includes>
                            <include>**/*Test.java</include>
                            <include>**/*TestSuite.java</include>
                        </includes>
                        <childDelegation>true</childDelegation>
                        <reuseForks>false</reuseForks>
                        <argLine>${modular.jdk.args}</argLine>
                    </configuration>
                </plugin>

                <!-- JAR -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${version.jar.plugin}</version>
                </plugin>

                <!-- Javadoc -->
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <configuration>
                        <doclet>net.gleamynode.apiviz.APIviz</doclet>
                        <docletArtifact>
                            <groupId>org.jboss.apiviz</groupId>
                            <artifactId>apiviz</artifactId>
                            <version>1.3.2.GA</version>
                        </docletArtifact>
                        <excludePackageNames>*._private</excludePackageNames>
                    </configuration>
                </plugin>

                <!-- Checkstyle -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${version.checkstyle.plugin}</version>
                    <configuration>
                        <configLocation>wildfly-checkstyle/checkstyle.xml</configLocation>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <useFile/>
                        <excludes>**/*$logger.java,**/*$bundle.java</excludes>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.wildfly.checkstyle</groupId>
                            <artifactId>wildfly-checkstyle-config</artifactId>
                            <version>${version.org.wildfly.checkstyle-config}</version>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <id>check-style</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>checkstyle</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.wildfly.security</groupId>
            <artifactId>wildfly-elytron</artifactId>
            <version>${version.elytron}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>${version.org.jboss.logging}</version>
        </dependency>
        <dependency>
            <groupId>org.wildfly.common</groupId>
            <artifactId>wildfly-common</artifactId>
            <version>${version.org.wildfly.common}</version>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>${version.commons-cli}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-annotations</artifactId>
            <version>${version.org.jboss.logging.tools}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-processor</artifactId>
            <version>${version.org.jboss.logging.tools}</version>
            <scope>provided</scope>
        </dependency>
        <!--
              Test Scope Only
         -->
        <dependency>
            <groupId>org.jboss.logmanager</groupId>
            <artifactId>jboss-logmanager</artifactId>
            <version>${version.org.jboss.logmanager}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logmanager</groupId>
            <artifactId>log4j-jboss-logmanager</artifactId>
            <version>${version.org.jboss.logmanager.log4j-jboss}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.slf4j</groupId>
            <artifactId>slf4j-jboss-logmanager</artifactId>
            <version>${version.org.jboss.slf4j}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${version.org.apache.commons}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>modularizedJdk</id>
            <activation>
                <jdk>9</jdk>
            </activation>
            <properties>
                <!-- [WFCORE-1431] remove SASL workaround -->
                <modular.jdk.args>--add-modules java.corba,java.sql --add-exports java.security.sasl/com.sun.security.sasl.digest=ALL-UNNAMED
                --add-exports java.security.sasl/com.sun.security.sasl=ALL-UNNAMED --add-exports jdk.unsupported/sun.reflect=ALL-UNNAMED
                --add-exports java.base/sun.security.x509=ALL-UNNAMED
                </modular.jdk.args>
                <!-- There are lots of issues with checkstyle runtime on JDK9, it somewhat works but really slows down build, disabling it for now-->
                <checkstyle.skip>true</checkstyle.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${version.compiler.plugin}</version>
                        <configuration>
                            <!-- fork is needed so compiler args can be used -->
                            <fork>true</fork>
                            <compilerArgs>
                                <arg>-J--add-modules</arg>
                                <arg>-Jjava.annotations.common</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>public-jboss</id>
            <name>Public JBoss Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>public-jboss-plugins</id>
            <name>Public JBoss Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
        </pluginRepository>
    </pluginRepositories>
</project>
