<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>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-parent</artifactId>
        <version>2.13.2-m5</version>
    </parent>

    <artifactId>atlassian-plugins-osgi</artifactId>

    <name>Atlassian Plugins - OSGi Loader</name>
    <description>
        An extension to Atlassian Plugins that provides a loader that loads plugins into OSGi
    </description>

    <properties>
        <!-- This should use ${project.build.directory} instead of target, but Maven < 2.0.9 fails to interpolate. -->
        <frameworkBundleDirectory>target/framework-bundles</frameworkBundleDirectory>
        <!-- DEBUG<global.jvm.opts>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</global.jvm.opts>-->
        <jvm.opts1>-Ddummy1=1</jvm.opts1>
        <!--NPE's if you leave these blank -->
        <jvm.opts2>-Ddummy2=2</jvm.opts2>
        <jmeter.version>2.3.4</jmeter.version>
        <jmeter.home>${project.build.directory}/jakarta-jmeter-${jmeter.version}/</jmeter.home>
    </properties>

    <profiles>
        <!-- If a 1.6 JDK is available, use the faster JMeter-->
        <profile>
            <id>jmeter-java-1.5</id>
            <activation>
                <jdk>1.5</jdk>
            </activation>
            <properties>
                <jmeter.version>2.3.4</jmeter.version>
            </properties>
        </profile>
        <profile>
            <id>jmeter-java-1.6</id>
            <activation>
                <jdk>1.6</jdk>
            </activation>
            <properties>
                <jmeter.version>2.3.4-atlassian-1</jmeter.version>
            </properties>
        </profile>

        <profile>
            <id>perfprofile</id>
            <properties>
                <jvm.opts1>-agentlib:jprofilerti=offline,id=${jprofiler.profileid},config=${jprofiler.configfile}</jvm.opts1>
                <jvm.opts2>-Xbootclasspath/a:${jprofiler.home}/bin/agent.jar</jvm.opts2>
                <jprofiler.home>${project.build.directory}/jprofiler6/</jprofiler.home>
                <jprofiler.version>6.0.4</jprofiler.version>
                <jprofiler.profileid>108</jprofiler.profileid>
                <jprofiler.configfile>${project.build.directory}/test-classes/jprofilerconfig.xml</jprofiler.configfile>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>30_update-jprofiler-paths</id>
                                <!-- Antrun is broken WRT phases, so this is bound to process-test-classes instead of pre-integration-test -->
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <replace file="${jprofiler.configfile}" token="@project-dir@" value="${project.build.directory}" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.0-alpha-4</version>
                        <executions>
                            <execution>
                                <id>31_unpack-jprofiler</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.ej-technologies</groupId>
                                            <artifactId>jprofiler</artifactId>
                                            <type>tar.gz</type>
                                            <version>${jprofiler.version}</version>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>perftest</id>
            <properties>
                <history.directory>
                    /opt/performance/history/plugins2/perflegacy-${project.version}-${java.specification.version}
                </history.directory>
                <sitedoc.url>
                    dav:https://internal.docs.atlassian.com/plugins2-performance/perflegacy-${project.version}-${java.specification.version}
                </sitedoc.url>
                <skipTests>true</skipTests>
            </properties>
            <distributionManagement>
                <site>
                    <id>atlassian-documentation</id>
                    <url>${sitedoc.url}</url>
                </site>
            </distributionManagement>
            <build>
                <defaultGoal>verify</defaultGoal>
                <plugins>
                    <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>test-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>test-jar</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip>
                                    <forceCreation>true</forceCreation>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.0-alpha-4</version>
                        <executions>
                            <execution>
                                <id>71_unpack-jmeter</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.apache.jmeter</groupId>
                                            <artifactId>apache-jmeter</artifactId>
                                            <type>tar.gz</type>
                                            <version>2.3.4</version>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>chronos-maven-plugin</artifactId>
                        <version>1.0-atlassian-2</version>
                        <configuration>
                            <jmeterhome>${jmeter.home}</jmeterhome>
                            <heap>1024m</heap>
                            <permsize>128m</permsize>
                            <historydir>${history.directory}</historydir>
                            <sysproperties>
                                <!-- WTF.  No idea why, but maven doesn't interpolate this variable.
                                <property>
                                    <name>script.base</name>
                                    <value>${project.build.directory}</value>
                                </property>-->
                                <property>
                                    <name>loops.testlegacyframework</name>
                                    <value>10</value>
                                </property>
                                <property>
                                    <name>className</name>
                                    <value>com.atlassian.plugin.osgi.performance.TestLegacyFrameworkRestart</value>
                                </property>
                            </sysproperties>
                            <options>
                                <value>${jvm.opts1}</value>
                                <value>${jvm.opts2}</value>
                                <!--<value>-Datlassian.org.osgi.framework.bootdelegation=java.*,javax.*,com.jprofiler.*,sun.*,com.sun.*</value>-->
                            </options>
                        </configuration>
                        <executions>
                            <execution>
                                <id>perftest-legacy</id>
                                <phase>integration-test</phase>
                                <configuration>
                                    <dataid>perftest-legacy</dataid>
                                    <input>${project.build.directory}/test-classes/perftest-legacy.jmx</input>
                                </configuration>
                                <goals>
                                    <goal>jmeter</goal>
                                    <goal>savehistory</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <reporting>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>chronos-maven-plugin</artifactId>
                        <version>1.0-atlassian-2</version>
                        <configuration>
                            <historydir>${history.directory}</historydir>
                        </configuration>
                        <reportSets>
                            <reportSet>
                                <id>perftest-legacy</id>
                                <configuration>
                                    <dataid>perftest-legacy</dataid>
                                    <reportid>perftest-legacy</reportid>
                                    <title>JMeter Plugins 2 Legacy Report</title>
                                    <description>
                                        <![CDATA[Test Report]]>
                                    </description>
                                </configuration>
                                <reports>
                                    <report>report</report>
                                    <report>historyreport</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>
                </plugins>
            </reporting>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-framework-bundles</id>
                        <phase>generate-sources</phase>

                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>

                                <artifactItem>
                                    <groupId>org.springframework</groupId>
                                    <artifactId>spring</artifactId>

                                    <version>${springVersion}</version>
                                </artifactItem>
                                
                                <artifactItem>
                                    <groupId>org.springframework.osgi</groupId>

                                    <artifactId>spring-osgi-annotation</artifactId>
                                    <version>${springDmVersion}</version>
                                </artifactItem>

                                <artifactItem>
                                    <groupId>org.springframework.osgi</groupId>
                                    <artifactId>spring-osgi-core</artifactId>

                                    <version>${springDmVersion}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.springframework.osgi</groupId>
                                    <artifactId>spring-osgi-extender</artifactId>

                                    <version>${springDmVersion}</version>
                                    <type>bundle</type>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.springframework.osgi</groupId>
                                    <artifactId>spring-osgi-io</artifactId>
                                    <version>${springDmVersion}</version>
                                </artifactItem>

                                <artifactItem>
                                    <groupId>com.atlassian.bundles</groupId>
                                    <artifactId>velocity</artifactId>
                                    <version>1.6.2-1</version>
                                </artifactItem>

                                <artifactItem>
                                    <groupId>org.slf4j</groupId>
                                    <artifactId>jcl-over-slf4j</artifactId>
                                </artifactItem>

                            </artifactItems>
                            <outputDirectory>${frameworkBundleDirectory}</outputDirectory>

                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-internal-framework-bundles</id>
                        <phase>generate-sources</phase>

                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${frameworkBundleDirectory}</outputDirectory>
                            <includeArtifactIds>atlassian-plugins-osgi-bridge,atlassian-plugins-osgi-spring-extender
                            </includeArtifactIds>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>

                            <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                            <includeArtifactIds>atlassian-plugins-simpletest</includeArtifactIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>

                <version>2.2-beta-1</version>
                <configuration>
                    <finalName>osgi</finalName>
                    <descriptors>
                        <descriptor>src/main/assembly/framework-bundles.xml</descriptor>
                    </descriptors>
                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>

                </configuration>
                <executions>
                    <execution>
                        <id>create-framework-bundles</id>
                        <!--
                            so that it happens just after the unit tests ran successfuly
                            it should be changes to pre-package when maven 2.1 is out
                        -->
                        <phase>process-resources</phase>
                        <goals>
                            <goal>attached</goal>

                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/performance/**</exclude>
                    </excludes>
                    <!-- Necessary due to a permgen memory leak restarting Felix in Sun's 64bit server VM -->
                    <argLine>-XX:PermSize=64m -XX:MaxPermSize=256m</argLine>
                    <!--argLine>-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/mrdon/dev/tmp</argLine-->
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.0.0</version>
                <extensions>true</extensions>
            </plugin>

        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-assembly-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.2-beta-1,)
                                        </versionRange>
                                        <goals>
                                            <goal>attached</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.apache.maven.plugins
                                        </groupId>
                                        <artifactId>
                                            maven-dependency-plugin
                                        </artifactId>
                                        <versionRange>[2.1,)</versionRange>
                                        <goals>
                                            <goal>copy</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-core</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-spring-extender</artifactId>
            <version>${project.version}</version>
            <type>bundle</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-events</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-bridge</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>biz.aQute</groupId>
            <artifactId>bndlib</artifactId>
            <version>1.43.0-atlassian-1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${springVersion}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
        </dependency>

        <dependency>
            <groupId>org.twdata.pkgscanner</groupId>
            <artifactId>package-scanner</artifactId>
            <version>0.9.5</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins.test</groupId>
            <artifactId>atlassian-plugins-test</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>

        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.test</groupId>
            <artifactId>atlassian-plugins-simpletest</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-servlet</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- This tests the ability of Spring DM to access xerces due to lame service finding algorithms in JAXP -->
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Needed to compile TestServiceUnavailable -->
        <dependency>
            <groupId>org.springframework.osgi</groupId>
            <artifactId>spring-osgi-core</artifactId>
            <version>${springDmVersion}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
