<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>de.mhoffrogge</groupId>
        <artifactId>org-parent</artifactId>
        <version>3</version>
    </parent>

    <groupId>de.mhoffrogge.openjdk</groupId>
    <artifactId>openjdk-jaxp-parent</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <url>https://github.com/mhoffrog/openjdk-jaxp-external/</url>
    <description>
        The JAXP package of Open-JDK as external package - supposed for backward compatibility use cases.
        The package name will reflect the major JDK version and the minimum JDK code compatibility.
        The version number will reflect the corresponding original JDK version.
	</description>

    <scm>
        <connection>scm:git:ssh://git@github.com/mhoffrog/openjdk-jaxp-external.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/mhoffrog/openjdk-jaxp-external.git</developerConnection>
        <url>https://github.com/mhoffrog/openjdk-jaxp-external</url>
        <tag>HEAD</tag>
    </scm>

    <licenses>
        <license>
            <name>GNU General Public License, version 3</name>
            <url>https://opensource.org/licenses/GPL-3.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <skip.gpg.signing>false</skip.gpg.signing>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.compile.version>1.7</java.compile.version>
        <java.toolchain.version>1.7.0_60</java.toolchain.version>
        <maven.compiler.source>${java.compile.version}</maven.compiler.source>
        <maven.compiler.target>${java.compile.version}</maven.compiler.target>
        <javadoc.doclint></javadoc.doclint>

        <!-- OpenJDK version to refactor -->
        <openjdk.repo>jdk7u</openjdk.repo>
        <openjdk.tag>${openjdk.repo}60-b33</openjdk.tag>
        <openjdk.basefilename>${openjdk.repo}-${openjdk.tag}</openjdk.basefilename>
    </properties>

    <modules>
        <module>openjdk7-jaxp-external</module>
        <module>openjdk8-jaxp-external</module>
    </modules>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.7.0</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <compilerArgs>
                            <!-- Ignore the symbol file. Otherwise compile will fail for JDK 8, since org.w3c.dom.xpath is 
                                in JRE lib rt.jar but not in JDK ct.sym! -->
                            <arg>-XDignore.symbol.file</arg>
                        </compilerArgs>
                        <fork>true</fork>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.0.2</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <!-- <addClasspath>true</addClasspath> -->
                                <!-- <classpathPrefix>lib/</classpathPrefix> -->
                                <!-- <classpathLayoutType>simple</classpathLayoutType> -->
                                <!-- <mainClass>${application.main.class}</mainClass> -->
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                            <manifestEntries>
                                <X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
                                <X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
                                <Version>${project.version}</Version>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <filesets combine.children="append">
                            <fileset>
                                <directory>${basedir}</directory>
                                <excludes>
                                    <exclude>src-gen/**/.git*</exclude>
                                </excludes>
                                <includes>
                                    <include>src-gen/**/*</include>
                                </includes>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <phase>_NEVER_</phase>
                            <configuration>
                                <target>
                                    <taskdef resource="net/sf/antcontrib/antcontrib.properties"
                                        classpathref="maven.plugin.classpath" />
                                    <!-- Place any Ant task here. You can add anything you can add between <target> and </target> 
                                        in a build.xml. -->
                                </target>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>ant-contrib</groupId>
                            <artifactId>ant-contrib</artifactId>
                            <version>1.0b3</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>ant</groupId>
                                    <artifactId>ant</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the 
                        Maven build itself. -->
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-toolchains-plugin</artifactId>
                                        <versionRange>[1.1,)</versionRange>
                                        <goals>
                                            <goal>toolchain</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>${java.toolchain.version}</version>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>parse-version</id>
                        <goals>
                            <goal>parse-version</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>OPENJDK_JAXP_EXTERNAL_SOURCE_GENERATION_AND_COMPILE</id>
            <activation>
                <file>
                    <exists>${basedir}/src-gen</exists>
                </file>
            </activation>

            <properties>
                <jaxp.src.dir>src-gen/jaxp</jaxp.src.dir>
            </properties>

            <build>
                <resources>
                    <resource>
                        <directory>${jaxp.src.dir}</directory>
                        <filtering>false</filtering>
                        <excludes>
                            <exclude>**/*.java</exclude>
                            <exclude>**/.git*</exclude>
                        </excludes>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>${jaxp.src.dir}</source>
                                        <!-- <source>src/xml/java</source> -->
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <target>
                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties"
                                            classpathref="maven.plugin.classpath" />

                                        <property name="openjdk.zipfile"
                                            value="${basedir}/downloads/${openjdk.basefilename}.zip" />
                                        <property name="openjdk.github.url"
                                            value="https://github.com/openjdk/${openjdk.repo}/archive/refs/tags/${openjdk.tag}.zip" />
                                        <property name="src.package.dir"
                                            value="${basedir}/${jaxp.src.dir}/${openjdk.repo}/jaxp" />
                                        <if>
                                            <not>
                                                <available file="${openjdk.zipfile}"
                                                    property="jaxp.jar.present" />
                                            </not>
                                            <then>
                                                <echo
                                                    message="Downloading ${openjdk.zipfile} from ${openjdk.github.url}"
                                                    level="info" />
                                                <mkdir dir="${basedir}/downloads" />
                                                <get dest="${openjdk.zipfile}" verbose="true">
                                                    <url url="${openjdk.github.url}" />
                                                </get>
                                            </then>
                                        </if>
                                        <!-- <delete dir="${basedir}/${jaxp.src.dir}" /> -->
                                        <mkdir dir="${src.package.dir}" />
                                        <unzip src="${openjdk.zipfile}" dest="${src.package.dir}">
                                            <patternset>
                                                <include name="${openjdk.basefilename}/jaxp/src/com/sun/**/*" />
                                            </patternset>
                                            <chainedmapper>
                                                <filtermapper>
                                                    <replacestring from="/internal/" to="/external/" />
                                                </filtermapper>
                                                <cutdirsmapper dirs="5" />
                                            </chainedmapper>
                                        </unzip>
                                        <echo message="Refactoring sources ..." level="info" />
                                        <replace dir="${src.package.dir}">
                                            <replacefilter token="com.sun." value="${openjdk.repo}.jaxp." />
                                            <replacefilter token="com/sun/" value="${openjdk.repo}/jaxp/" />
                                            <replacefilter token=".internal." value=".external." />
                                            <replacefilter token="/internal/" value="/external/" />
                                            <replacefilter token=".internal;" value=".external;" />
                                        </replace>
                                        <echo message="Refactoring DONE." level="info" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile><!-- <id>OPENJDK_JAXP_EXTERNAL_SOURCE_GENERATION_AND_COMPILE</id> -->
    </profiles>

</project>