<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.   
-->
<!-- 
    Please keep the project tag on one line to avoid confusing 
    the release plugin.
-->
<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.apache.openjpa</groupId>
        <artifactId>openjpa-parent</artifactId>
        <version>2.2.2</version>
    </parent>

    <artifactId>openjpa</artifactId>
    <packaging>bundle</packaging>
    <name>OpenJPA Aggregate Jar</name>

    <build>
        <plugins>
            <!-- disable creating javadoc for this module -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <!-- disable creating source jars for this module -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <configuration>
                    <attach>false</attach>
                </configuration>
            </plugin>

            <!-- Create our aggregate JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <createSourcesJar>${createSources}</createSourcesJar>
                            <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
                            <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
                            <!--
                                 Specify a subset of depends to include,
                                 which must match the <dependencies> section.
                            -->
                            <artifactSet>
                                <includes>
                                    <include>org.apache.openjpa:openjpa-lib</include>
                                    <include>org.apache.openjpa:openjpa-kernel</include>
                                    <include>org.apache.openjpa:openjpa-jdbc</include>
                                    <include>org.apache.openjpa:openjpa-persistence</include>
                                    <include>org.apache.openjpa:openjpa-persistence-jdbc</include>
                                    <include>org.apache.openjpa:openjpa-xmlstore</include>
                                    <include>org.apache.openjpa:openjpa-slice</include>
                                    <include>org.apache.openjpa:openjpa-jest</include>
                                </includes>
                            </artifactSet>
                            <!-- OpenJPA unique META-INF setup -->
                            <transformers>
                                <!-- Need to concatinate the services resources:
                                 org.apache.openjpa.lib.conf.ProductDerivation
                                 javax.persistence.spi.PersistenceProvider
                                 org.apache.openjpa.kernel.exps.ExpressionParser
                                -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- create an OSGi bundle -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <!-- OpenJPA metadata -->
                        <Main-Class>org.apache.openjpa.conf.OpenJPAVersion</Main-Class>
                        <Premain-Class>org.apache.openjpa.enhance.PCEnhancerAgent</Premain-Class>
                        <Agent-Class>org.apache.openjpa.enhance.InstrumentationFactory</Agent-Class>
                        <Can-Redefine-Classes>true</Can-Redefine-Classes>
                        <Can-Retransform-Classes>true</Can-Retransform-Classes>
                        <Specification-Title>JSR-317 Java Persistence</Specification-Title>
                        <Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
                        <Specification-Version>2.0</Specification-Version>
                        <!-- OSGi Bundle Metadata -->
                        <Bundle-DocURL>${project.url}</Bundle-DocURL>
                        <Bundle-Activator>org.apache.openjpa.persistence.osgi.PersistenceActivator</Bundle-Activator>
                        <Private-Package />
                        <Export-Package>org.apache.openjpa.*;version=${project.version}</Export-Package>
                        <Import-Package>com.ibm.*;resolution:=optional,org.postgresql.*;resolution:=optional,org.apache.tools.ant.*;resolution:=optional,org.apache.log4j.*;resolution:=optional,org.slf4j.*;resolution:=optional,org.apache.commons.logging.*;resolution:=optional,javax.activation.xa*;resolution:=optional,javax.jms.*;version="[1.1.0,1.2)";resolution:=optional,javax.transaction.*;version="[1.1.0,1.2)";resolution:=optional,javax.validation.*;version="[1.0.0,1.1)";resolution:=optional,javax.xml.bind.*;resolution:=optional,serp.*;resolution:=optional,javax.persistence.*;version="[1.1.0,2.1)",*</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- JARs to include in aggregate JAR via maven-shade-plugin -->
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-lib</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-kernel</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-jdbc</artifactId>
            <version>${project.version}</version>
            <!-- 
                 Need to exclude jaxb, so the following will not get included
                 as compile depends in the aggregate JAR by the shade plugin:
                     javax.xml.bind:jaxb-api:jar:2.0
                     javax.xml.bind:jsr173_api:jar:1.0
                     javax.activation:activation:jar:1.1
                     com.sun.xml.bind:jaxb-impl:jar:2.0.5
            -->
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Need to manually add back optional openjpa-jdbc depends -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jsr173_api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <scope>compile</scope>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jsr173_api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- end optional openjpa-jdbc depends -->
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-persistence</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-persistence-jdbc</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-xmlstore</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-slice</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-jest</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</project>
