<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Distribution License v. 1.0, which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: BSD-3-Clause

-->

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.sun.xml.bind.mvn</groupId>
        <artifactId>jaxb-bundles</artifactId>
        <version>2.3.2</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-xjc</artifactId>

    <packaging>jar</packaging>
    <name>Old JAXB XJC</name>
    <description>
        Old JAXB Binding Compiler. Contains source code needed for binding customization files into java sources.
        In other words: the *tool* to generate java classes for the given xml representation.
        <!--todo: finish me-->
    </description>

    <dependencies>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <version>${project.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>codemodel</artifactId>
            <version>${codemodel.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>xsom</artifactId>
            <version>${xsom.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <generated.sources.dir>${project.build.directory}/generated-sources</generated.sources.dir>
        <generated.classes.dir>${project.build.directory}/classes</generated.classes.dir>
    </properties>

    <profiles>
        <profile>
            <id>default-profile</id>
            <activation>
                <property>
                    <name>!dev</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.osgi</groupId>
                    <artifactId>osgi.core</artifactId>
                    <version>${felix.osgi.core}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jaxb</groupId>
                    <artifactId>osgi-test-xjc</artifactId>
                    <version>${project.version}</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.jaxb</groupId>
                    <artifactId>osgi-test-parent</artifactId>
                    <version>${project.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <sourceFileExcludes>
                        <sourceFileExclude>META-INF/versions/**</sourceFileExclude>
                    </sourceFileExcludes>
                    <additionalJOptions>
                        <additionalJOption>-Xdoclint:none</additionalJOption>
                        <!--Non MR-JAR version of xjc/src/main/java/com/sun/tools/xjc/CatalogUtil.java uses
                        com.sun.org.apache.xml.internal.resolver (see resolver dependency)-->
                        <additionalJOption>--module-path</additionalJOption>
                        <additionalJOption>${module.path}</additionalJOption>
                        <additionalJOption>--add-modules</additionalJOption>
                        <additionalJOption>resolver</additionalJOption>
                        <additionalJOption>--add-reads</additionalJOption>
                        <additionalJOption>com.sun.tools.xjc=resolver</additionalJOption>
                    </additionalJOptions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-junit4osgi-plugin</artifactId>
                <version>${felix.junit4osgi}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                            <skip>${skipOsgiTests}</skip>
                            <m_deployProjectArtifact>true</m_deployProjectArtifact>
                            <configuration>
                                <org.osgi.framework.system.packages.extra>
                                    javax.swing.tree,
                                    javax.xml.namespace,
                                    org.xml.sax,
                                    javax.xml.stream,
                                    org.xml.sax.ext,
                                    javax.swing,
                                    javax.xml.transform.sax,
                                    javax.swing.border,
                                    com.sun.org.apache.xml.internal.resolver.tools,
                                    javax.lang.model.util,
                                    javax.xml.parsers,
                                    org.w3c.dom,
                                    javax.xml.datatype,
                                    javax.xml.xpath,
                                    javax.xml.transform.stream,
                                    javax.xml.validation,
                                    org.xml.sax.helpers,
                                    javax.annotation.processing,
                                    javax.lang.model.type,
                                    javax.xml.transform.dom,
                                    org.w3c.dom.ls,
                                    org.apache.tools.ant.types,
                                    javax.lang.model.element,
                                    javax.tools,
                                    com.sun.org.apache.xml.internal.resolver,
                                    org.apache.tools.ant,
                                    javax.activation,
                                    javax.xml.transform,
                                    javax.xml
                                </org.osgi.framework.system.packages.extra>
                            </configuration>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-sources</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <excludes>**/module-info.java</excludes>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.glassfish.jaxb</groupId>
                                    <artifactId>jaxb-xjc</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.glassfish.jaxb</groupId>
                                    <artifactId>xsom</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.xml.bind.external</groupId>
                                    <artifactId>relaxng-datatype</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.glassfish.jaxb</groupId>
                                    <artifactId>codemodel</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.xml.bind.external</groupId>
                                    <artifactId>rngom</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.xml.dtd-parser</groupId>
                                    <artifactId>dtd-parser</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.istack</groupId>
                                    <artifactId>istack-commons-tools</artifactId>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-classes</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <excludes>**/module-info.class</excludes>
                            <skip>false</skip>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.glassfish.jaxb</groupId>
                                    <artifactId>jaxb-xjc</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.glassfish.jaxb</groupId>
                                    <artifactId>xsom</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.xml.bind.external</groupId>
                                    <artifactId>relaxng-datatype</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.glassfish.jaxb</groupId>
                                    <artifactId>codemodel</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.xml.bind.external</groupId>
                                    <artifactId>rngom</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.xml.dtd-parser</groupId>
                                    <artifactId>dtd-parser</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.sun.istack</groupId>
                                    <artifactId>istack-commons-tools</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.classes.dir}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prepare-module-path</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${module.path}</outputDirectory>
                            <silent>false</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.sun.org.apache.xml.internal</groupId>
                                    <artifactId>resolver</artifactId>
                                    <overWrite>false</overWrite>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <instructions>
                                <Export-Package>*</Export-Package>
                                <Import-Package>com.sun.org.apache.xml.internal.resolver;resolution:=optional,com.sun.org.apache.xml.internal.resolver.tools;resolution:=optional,*</Import-Package>
                            </instructions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-sources</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${generated.sources.dir}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>org.glassfish.jaxb:jaxb-xjc</include>
                                    <include>org.glassfish.jaxb:codemodel</include>
                                    <include>org.glassfish.jaxb:xsom</include>
                                    <include>com.sun.istack:istack-commons-tools</include>
                                    <include>com.sun.xml.dtd-parser:dtd-parser</include>
                                    <include>com.sun.xml.bind.external:rngom</include>
                                    <include>com.sun.xml.bind.external:relaxng-datatype</include>
                                </includes>

                                <excludes>
                                    <exclude>jakarta.xml.bind:jakarta.xml.bind-api</exclude>
                                    <exclude>org.glassfish.jaxb:txw2</exclude>
                                    <exclude>javax.xml.stream:stax-api</exclude>
                                    <exclude>com.sun.istack:istack-commons-runtime</exclude>
                                    <exclude>org.apache.ant:ant</exclude>
                                    <exclude>org.apache.ant:ant-launcher</exclude>
                                    <exclude>com.sun.org.apache.xml.internal:resolver</exclude>
                                </excludes>

                            </artifactSet>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.sun.tools.xjc.XJCFacade</mainClass>
                                    <manifestEntries>
                                        <Class-Path>jaxb-impl.jar</Class-Path>
                                        <Major-Version>${jaxb.majorVersion}.${jaxb.minorVersion}.${jaxb.incrementalVersion}</Major-Version>
                                        <Specification-Version>${jaxb-api.majorVersion}.${jaxb-api.minorVersion}</Specification-Version>
                                        <Git-Revision>${buildNumber}</Git-Revision>
                                        <Multi-Release>true</Multi-Release>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                            <skip>false</skip>
                            <systemProperties>
                                <jaxb.spec.version>${jaxb-api.version}</jaxb.spec.version>
                                <osgi.dist>${project.build.directory}/${project.build.finalName}</osgi.dist>
                            </systemProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
