<?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.
-->
<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/xsd/maven-4.0.0.xsd">
  <parent>
    <artifactId>deps</artifactId>
    <groupId>org.apache.tomee</groupId>
    <version>10.0.0-M2</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>commons-dbcp2-shade</artifactId>
  <name>TomEE :: Deps :: Apache Commons DBCP2 shade</name>

  <dependencies>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-dbcp2</artifactId>
      <version>${version.commons-dbcp2}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.6.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createSourcesJar>true</createSourcesJar>
              <useBaseVersion>true</useBaseVersion>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <artifactSet>
                <includes>
                  <include>org.apache.commons:commons-dbcp2</include> <!-- only this dep to make sure we don't add other things -->
                </includes>
              </artifactSet>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
              </transformers>
              <relocations>
                <relocation>
                  <pattern>javax.transaction</pattern>
                  <shadedPattern>jakarta.transaction</shadedPattern>
                  <excludes>
                    <exclude>javax.transaction.xa.**</exclude>
                  </excludes>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <!--
        Purpose of build-helper-maven-plugin is to ensure that IntelliJ sees shaded classes.
        When navigating over to java classes in importing modules, the shaded imported classes will
        show as resolved instead of unknown.
        The artifact specified below is created when this module is built but is also used to resolve classes in IntelliJ.
        "phase" is set to "none" - with this setting, the artifact jar will not be uploaded to repo
        when running standalone "mvn install" command.

        build-helper-maven-plugin can be removed completely with no effect on the "mvn clean" and "mvn install",
        which is handled by maven-shade-plugin.
        -->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.6.0</version>
        <executions>
          <execution>
            <id>workaround-makeItVisibleOnIntellij</id>
            <phase>none</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/commons-dbcp2-shade-10.0.0-M2.jar</file>
                  <type>jar</type>
                  <classifier>optional</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>


  </build>
</project>
