<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.2.3.rc1</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>
    </properties>

    <profiles>
        <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>/opt/performance/tools/jprofiler521/</jprofiler.home>
                <jprofiler.profileid>111</jprofiler.profileid>
                <jprofiler.configfile>${project.build.directory}/test-classes/jprofilerconfig.xml</jprofiler.configfile>
                <setuptest.runtime>100</setuptest.runtime>
                <fixedload.offset>101</fixedload.offset><!--This probably wont trigger unless things go really bad-->
            </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}" />
                                      <!--
                                      <replace file="${jprofiler.configfile}" token="@setupoffset@" value="${setuptest.runtime}" />
                                      <replace file="${jprofiler.configfile}" token="@fixedoffset@" value="${fixedload.offset}" />
                                      -->
                                  </tasks>
                              </configuration>
                          </execution>
                      </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>perftest</id>
            <properties>
                <jmeter.home>/opt/performance/tools/jmeter</jmeter.home>
                <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>
                        <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.*,com.jprofiler.*</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>2.5.5</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-io</artifactId>
                                    <version>${springDmVersion}</version>
                                </artifactItem>

                                <artifactItem>
                                    <groupId>org.aopalliance</groupId>
                                    <artifactId>com.springsource.org.aopalliance</artifactId>
                                    <version>1.0.0</version>
                                </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-logging,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>

                </configuration>
            </plugin>

        </plugins>
    </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>
            <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>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-logging</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>biz.aQute</groupId>
            <artifactId>bndlib</artifactId>

            <version>0.0.255</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springVersion}</version>
            <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>


        <!-- patch for FELIX-721 and FELIX-827 -->
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.main</artifactId>
            <version>1.2.1-atlassian-7</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.shell</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.shell</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.shell.tui</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.bundlerepository</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

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

            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>

                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>

                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.mail</groupId>

                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </exclusion>
            </exclusions>

        </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-webfragment</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>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

</project>


