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

    Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.

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

    SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <name>EclipseLink ASM</name>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.asm</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.parent</artifactId>
        <version>3.0.0-M2</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm-commons</artifactId>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm-tree</artifactId>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>
        <!--Test dependencies-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <!--Unpack origin ASM sources-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>src-dependencies</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.ow2.asm</includeGroupIds>
                            <includeScope>provided</includeScope>
                            <classifier>sources</classifier>
                            <outputDirectory>${project.build.directory}/unpacked-sources/asm-src</outputDirectory>
                            <!-- original html doc excluded to avoid javadoc build error on JDK 11/ASM 7.3.1-->
                            <excludes>META-INF/MANIFEST.MF,**/*.html</excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--Repackage ASM sources to internal packages-->
            <plugin>
                <groupId>com.sun.wts.tools.ant</groupId>
                <artifactId>package-rename-task</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <id>repackage-sources</id>
                        <goals>
                            <goal>rename</goal>
                        </goals>
                        <configuration>
                            <srcDir>${project.build.directory}/unpacked-sources/asm-src</srcDir>
                            <rootDir>${project.build.directory}/generated-sources/asm-src</rootDir>
                            <patterns>
                                <!-- Refactor classes package from .../unpacked-sources to org.eclipse.persistence.internal.libraries.asm -->
                                <org.objectweb.asm>org.eclipse.persistence.internal.libraries.asm</org.objectweb.asm>
                            </patterns>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--Generate OSGi bundle/manifest-->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <instructions>
                                <Export-Package>*</Export-Package>
                            </instructions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
