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

    Copyright (c) 2011, 2021 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>org.glassfish.metro</groupId>
        <artifactId>bundles</artifactId>
        <version>2.4.7</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>metro-standalone</artifactId>
    <packaging>pom</packaging>
    <name>Metro Web Services Standalone Zipped Bundle</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeArtifactIds>jaxws-ri</includeArtifactIds>
                            <includes>jaxws-ri/bin/**, jaxws-ri/samples/**</includes>
                            <excludes>jaxws-ri/samples/docs/**</excludes>
                            <outputDirectory>${project.build.directory}/unpacked-dependencies</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stage</id>
                        <phase>install</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/stage</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>maven-replacer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>replace-jaxws-with-metro</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                        <configuration>
                            <basedir>${project.build.directory}/unpacked-dependencies/jaxws-ri</basedir>
                            <includes>
                                <include>bin/**.bat</include>
                                <include>bin/**.sh</include>
                                <include>samples/**/build.xml</include>
                                <include>samples/**/deploy-targets.xml</include>
                                <include>samples/**/Readme.txt</include>
                                <include>samples/**/web.xml</include>
                            </includes>
                            <replacements>
                                <replacement>
                                    <token>JAX-WS</token>
                                    <value>Metro</value>
                                </replacement>
                                <replacement>
                                    <token>JAXWS_HOME</token>
                                    <value>METRO_HOME</value>
                                </replacement>
                                <replacement>
                                    <token>jaxws-tools.jar</token>
                                    <value>webservices-tools.jar</value>
                                </replacement>
                                <replacement>
                                    <token>jaxws.classpath</token>
                                    <value>metro.classpath</value>
                                </replacement>
                                <replacement>
                                    <token>/jaxws-</token>
                                    <value>/metro-</value>
                                </replacement>
                                <replacement>
                                    <token>https://jax-ws.dev.java.net/guide</token>
                                    <value>http://metro.java.net/guide</value>
                                </replacement>
                                <replacement>
                                    <token>https://jax-ws.java.net/guide</token>
                                    <value>http://metro.java.net/guide</value>
                                </replacement>
                            </replacements>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <finalName>metro</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- this is used for inheritance merges -->
                        <phase>package</phase>
                        <!-- append to the packaging phase. -->
                        <goals>
                            <goal>single</goal>
                            <!-- goals == mojos -->
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>otn</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-dependencies</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <includeArtifactIds>jaxws-ri</includeArtifactIds>
                                    <includes>jaxws-ri/bin/**, jaxws-ri/samples/**</includes>
                                    <outputDirectory>${project.build.directory}/unpacked-dependencies</outputDirectory>
                                    <overWriteReleases>false</overWriteReleases>
                                    <overWriteSnapshots>true</overWriteSnapshots>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.google.code.maven-replacer-plugin</groupId>
                        <artifactId>maven-replacer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>replace-jaxws-with-metro</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                                <configuration>
                                    <basedir>${project.build.directory}/unpacked-dependencies/jaxws-ri</basedir>
                                    <includes>
                                        <include>bin/**.bat</include>
                                        <include>bin/**.sh</include>
                                        <include>samples/docs/index.html</include>
                                        <include>samples/**/build.xml</include>
                                        <include>samples/**/deploy-targets.xml</include>
                                        <include>samples/**/Readme.txt</include>
                                        <include>samples/**/web.xml</include>
                                    </includes>
                                    <replacements>
                                        <replacement>
                                            <token>JAX-WS</token>
                                            <value>Metro</value>
                                        </replacement>
                                        <replacement>
                                            <token>JAXWS_HOME</token>
                                            <value>METRO_HOME</value>
                                        </replacement>
                                        <replacement>
                                            <token>jaxws-tools.jar</token>
                                            <value>webservices-tools.jar</value>
                                        </replacement>
                                        <replacement>
                                            <token>jaxws.classpath</token>
                                            <value>metro.classpath</value>
                                        </replacement>
                                        <replacement>
                                            <token>/jaxws-</token>
                                            <value>/metro-</value>
                                        </replacement>
                                        <replacement>
                                            <token>https://jax-ws.dev.java.net/guide</token>
                                            <value>http://metro.java.net/guide</value>
                                        </replacement>
                                        <replacement>
                                            <token>https://jax-ws.java.net/guide</token>
                                            <value>http://metro.java.net/guide</value>
                                        </replacement>
                                    </replacements>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <finalName>metro-otn</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>src/main/assembly/assembly-otn.xml</descriptor>
                            </descriptors>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make-assembly</id>
                                <!-- this is used for inheritance merges -->
                                <phase>package</phase>
                                <!-- append to the packaging phase. -->
                                <goals>
                                    <goal>single</goal>
                                    <!-- goals == mojos -->
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>coverage</id>
            <activation>
                <property>
                    <name>jacoco-build</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jacoco</groupId>
                    <artifactId>org.jacoco.core</artifactId>
                    <version>${jacoco.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.jacoco</groupId>
                    <artifactId>org.jacoco.report</artifactId>
                    <version>${jacoco.version}</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-jacoco-lib</id>
                                <phase>process-test-sources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jacoco</groupId>
                                            <artifactId>org.jacoco.ant</artifactId>
                                            <type>jar</type>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.jacoco</groupId>
                                            <artifactId>org.jacoco.core</artifactId>
                                            <type>jar</type>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.jacoco</groupId>
                                            <artifactId>org.jacoco.report</artifactId>
                                            <type>jar</type>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.ow2.asm</groupId>
                                            <artifactId>asm</artifactId>
                                            <type>jar</type>
                                            <version>${asm.version}</version>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.ow2.asm</groupId>
                                            <artifactId>asm-commons</artifactId>
                                            <type>jar</type>
                                            <version>${asm.version}</version>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.ow2.asm</groupId>
                                            <artifactId>asm-tree</artifactId>
                                            <type>jar</type>
                                            <version>${asm.version}</version>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>instrument-shaded-jar</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        <taskdef classpathref="maven.test.classpath" resource="tasks.properties" />
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="target/lib/org.jacoco.ant-0.8.5.jar:target/lib/org.jacoco.core-0.8.5.jar:target/lib/org.jacoco.report-0.8.5.jar:target/lib/asm-7.2.jar:target/lib/asm-commons-7.2.jar:target/lib/asm-tree-7.2.jar" />
                                        </taskdef>
                                        <property name="metro.instr.dir" location="${project.build.directory}/metro-instrumented"/>
                                        <property name="metro.instr.full.name" location="${project.build.directory}/metro-instrumented-full.zip"/>
                                        <unzip src="${project.build.directory}/metro.zip" dest="${metro.instr.dir}"/>
                                        <jacoco:instrument destdir="${metro.instr.dir}">
                                            <!--ignore regex="javax.xml.(crypto|rpc).*|com.(ctc|sun.xml.(rpc|registry)).*|org.(codehaus.stax2|glassfish).*" />
                                            <excludeClasses regex="javax.xml.(crypto|rpc).*|com.(ctc|sun.xml.(rpc|registry)).*|org.(codehaus.stax2|glassfish).*" />
                                            <includeClasses regex=".*" /-->
                                            <fileset dir="${metro.instr.dir}/metro/lib">
                                                <include name="webservices-rt.jar" />
                                                <include name="webservices-tools.jar" />
                                                <include name="databinding/*.jar" />
                                            </fileset>
                                        </jacoco:instrument>
                                        <!--attachartifact file="${metro.instr.dir}/metro/jacoco/jacoco.exec" classifier="jacoco" type="exec"/-->
                                        <zip destfile="${metro.instr.full.name}" basedir="${project.build.directory}/metro-instrumented"/>
                                        <attachartifact file="${metro.instr.full.name}" classifier="instrumented" type="zip"/>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-extra-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-extra</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-rt</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-tools</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>wstx-services</artifactId>
            <type>war</type>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-osgi</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-api-osgi</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-extra-jdk-packages</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-osgi</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-osgi-aix</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.woodstox</groupId>
            <artifactId>woodstox-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.woodstox</groupId>
            <artifactId>stax2-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-ri</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-eclipselink-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>sdo-eclipselink-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>commonj.sdo</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.santuario</groupId>
            <artifactId>xmlsec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
    </dependencies>

    <properties>
        <maven.build.timestamp.format>MMMM dd, yyyy</maven.build.timestamp.format>

        <java.home.string>java.home</java.home.string>
        <java.version.string>java.version</java.version.string>
        <as.home.env.string>env.AS_HOME</as.home.env.string>
        <catalina.home.env.string>env.CATALINA_HOME</catalina.home.env.string>

        <product.name>Metro ${project.version}</product.name>
        <release.date>${maven.build.timestamp}</release.date>
        <bundle.artifact.name>${project.artifactId}-${project.version}.zip</bundle.artifact.name>
        <src.bundle.artifact.name>${project.artifactId}-${project.version}.src.zip</src.bundle.artifact.name>
        <download.link>${release.repository.url}/org/glassfish/metro/${project.artifactId}/${project.version}/${bundle.artifact.name}</download.link>
    </properties>
</project>
