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

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 2011-2013 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    http://glassfish.java.net/public/CDDL+GPL_1_1.html
    or packager/legal/LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at packager/legal/LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

<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.3</version>
    </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>cobertura-build</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <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>
                                        <taskdef classpathref="maven.test.classpath" resource="tasks.properties" />
                                        <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}"/>
                                        <cobertura-instrument datafile="${metro.instr.dir}/metro/cobertura/cobertura.ser">
                                            <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>
                                        </cobertura-instrument>
                                        <attachartifact file="${metro.instr.dir}/metro/cobertura/cobertura.ser" classifier="cobertura" type="ser"/>
                                        <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>javax.xml.bind</groupId>
            <artifactId>jaxb-api-osgi</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>org.codehaus.woodstox</groupId>
            <artifactId>woodstox-core-asl</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>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>sdo-eclipselink-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>commonj.sdo</groupId>
            <artifactId>commonj.sdo</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>
