<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>net.freeutils</groupId>
    <artifactId>parent</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <name>parent</name>
    <description>The parent module contains the common Maven configurations</description>
    <url>http://www.freeutils.net/</url>
    <organization>
        <name>freeutils.net</name>
        <url>http://www.freeutils.net/</url>
    </organization>
    <licenses>
        <!--
            Note: this is the license for this module, and the default for child modules.
            Child modules should override it or add dual-licensing as necessary.
        -->
        <license>
            <name>GNU General Public License (GPL), Version 2.0</name>
            <url>http://www.gnu.org/licenses/gpl-2.0.html</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>amichai</id>
            <name>Amichai Rothman</name>
            <email>support@freeutils.net</email>
        </developer>
    </developers>

    <prerequisites>
        <maven>3.0.0</maven>
    </prerequisites>

    <scm>
        <!-- sources are available on the project website -->
        <url>${project.url}</url>
    </scm>

    <properties>
        <!-- common properties -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <file.encoding>UTF-8</file.encoding>
        <!-- project-specific properties (override as necessary) -->
        <jdk.version>1.6</jdk.version>
        <animal.sniffer.jdk.version>java16</animal.sniffer.jdk.version>
        <skip.assembly>true</skip.assembly>
        <!-- OSGi bundle properties -->
        <bundle.namespace>net.freeutils</bundle.namespace>
        <bundle.symbolicName>${project.groupId}</bundle.symbolicName>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.6.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.4</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.9.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.8</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>animal-sniffer-maven-plugin</artifactId>
                    <version>1.14</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.3</version>
                    <configuration>
                        <quiet>true</quiet>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.5.4</version>
                </plugin>
                <!-- generate a default OSGi bundle manifest -->
                <!-- this requires the jar plugin useDefaultManifestFile configuration to include it in jar -->
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.5.3</version>
                    <executions>
                        <execution>
                            <id>bundle-manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                            <configuration>
                                <instructions>
                                    <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                                    <Bundle-Version>${project.version}</Bundle-Version>
                                    <Export-Package>${bundle.namespace}.*;version="${project.version}"</Export-Package>
                                    <Private-Package>${bundle.namespace}.*</Private-Package>
                                </instructions>
                                <supportedProjectTypes>
                                    <supportedProjectType>jar</supportedProjectType>
                                </supportedProjectTypes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- add external META-INF resources in addition to standard ones -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-resource</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${basedir}</directory>
                                    <targetPath>META-INF</targetPath>
                                    <includes>
                                        <include>LICENSE*.txt</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- specify compiler jdk version -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>
            <!-- check against older jdk for proper backwards compatibility -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>check-jdk-version</id>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <signature>
                        <groupId>org.codehaus.mojo.signature</groupId>
                        <artifactId>${animal.sniffer.jdk.version}</artifactId>
                        <version>1.0</version>
                    </signature>
                </configuration>
            </plugin>
            <!-- use custom manifest in jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!-- note: this needs to be duplicated also in assembly plugin's jar-with-dependencies config -->
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <!--
                            unfortunately, the jar plugin provides no way to remove unwanted manifest
                            entries that are created by default, and produces an unsorted manifest
                            which makes it less human-readable - this will hopefully be fixed in the future
                        -->
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                        <manifestEntries>
                            <!-- make build reproducible on all machines (wish we could just remove this entry) -->
                            <Built-By>Amichai Rothman</Built-By>
                            <!-- vendor ID is not the same as groupId (which is project-specific) -->
                            <Implementation-Vendor-Id>net.freeutils</Implementation-Vendor-Id>
                            <!-- add a generic informative URL -->
                            <X-Vendor-URL>http://www.freeutils.net</X-Vendor-URL>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- create all release artifacts in addition to the jar -->
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- create sources artifact -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- create javadocs artifact -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- assemble the distribution zip file -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <dependencies>
                            <!-- shared assembly descriptors -->
                            <dependency>
                                <groupId>net.freeutils</groupId>
                                <artifactId>build-tools</artifactId>
                                <version>1.0</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>make-assembly-simple</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <skipAssembly>${skip.assembly}</skipAssembly>
                                    <descriptorRefs>
                                        <descriptorRef>assembly-simple</descriptorRef>
                                    </descriptorRefs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>make-assembly-full</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <skipAssembly>${skip.assembly}</skipAssembly>
                                    <descriptorRefs>
                                        <descriptorRef>assembly-full</descriptorRef>
                                    </descriptorRefs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>make-assembly-distribution</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <skipAssembly>${skip.assembly}</skipAssembly>
                                    <descriptorRefs>
                                        <descriptorRef>assembly-distribution</descriptorRef>
                                    </descriptorRefs>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
