<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-parent</artifactId>
        <version>5.0.0</version>
    </parent>

   <artifactId>atlassian-plugins-main</artifactId>
   <packaging>jar</packaging>
   <name>Atlassian Plugins Main API</name>
   <description>
       Simplified API for interacting with the plugin framework. Also includes a standalone executable jar for
       simple testing.
   </description>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-schema</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.test</groupId>
            <artifactId>atlassian-plugins-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <optional>true</optional>
        </dependency>
        <dependency>
           <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>standalone</shadedClassifierName>
                  <artifactSet>
                    <excludes>
                      <exclude>junit:junit</exclude>
                    </excludes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.apache.commons.io</pattern>
                      <shadedPattern>com.atlassian.org.apache.commons.io</shadedPattern>
                    </relocation>
                  </relocations>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
              <archive>
                <manifest>
                  <addClasspath>true</addClasspath>
                  <mainClass>com.atlassian.plugin.main.Main</mainClass>
                </manifest>
              </archive>
            </configuration>
          </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>extract-framework-bundles</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.plugins</groupId>
                                    <artifactId>atlassian-plugins-framework-bundles</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <classifier>${springTestClassifier}</classifier>
                                    <outputDirectory>${project.build.directory}/framework-bundles</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-test-bundles</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.slf4j</groupId>
                                    <artifactId>jcl-over-slf4j</artifactId>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/framework-bundles</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
