<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2009-2013 Roland Huss
  ~
  ~ Licensed 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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.jolokia</groupId>
  <artifactId>jolokia-osgi</artifactId>
  <version>1.7.2</version>
  <name>jolokia-osgi</name>
  <packaging>bundle</packaging>
  <description>osgi agent</description>

  <parent>
    <groupId>org.jolokia</groupId>
    <artifactId>jolokia-agent-parent</artifactId>
    <version>1.7.2</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <dependencies>
    <dependency>
      <groupId>org.jolokia</groupId>
      <artifactId>jolokia-core</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.jolokia</groupId>
      <artifactId>jolokia-jsr160</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>


    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.core</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.compendium</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
    </dependency>

    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymock</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jolokia</groupId>
      <artifactId>jolokia-test-util</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>

        <configuration>
          <instructions>
            <Bundle-SymbolicName>org.jolokia.osgi</Bundle-SymbolicName>
            <Bundle-Description>Jolokia agent exposing JMX via HTTP/JSON</Bundle-Description>

            <Bundle-Version>${project.version}</Bundle-Version>
            <Bundle-Activator>org.jolokia.osgi.JolokiaActivator</Bundle-Activator>
            <Bundle-Name>Jolokia Agent</Bundle-Name>
            <Embed-Directory>lib</Embed-Directory>
            <Embed-Dependency>
              json-simple;inline=false,
              jolokia-core;inline=true,
              jolokia-jsr160;inline=true
            </Embed-Dependency>
            <Export-Package>
              org.jolokia.osgi.security;version="${project.version}",
              org.jolokia.osgi.servlet;uses:="org.osgi.service.http,org.osgi.framework,javax.servlet";version="${project.version}",
              org.jolokia.restrictor;uses:="javax.management,javax.xml.parsers,org.w3c.dom,org.xml.sax";version="${project.version}",
              org.jolokia.util;version="${project.version}",
              org.jolokia.converter;version="${project.version}",
              org.jolokia.converter.json;version="${project.version}",
              org.jolokia.converter.object;version="${project.version}",
            </Export-Package>
            <Import-Package>
              org.jolokia.osgi.servlet;version="${project.version}",
              org.jolokia.restrictor;version="${project.version}",
              org.jolokia.util;version="${project.version}",
              org.osgi.framework;version="[1.0.0,2.0.0)",
              org.osgi.service.http;version="[1.0.0,2.0.0)";resolution:=optional,
              org.osgi.service.cm;version="[1.0.0,2.0.0)";resolution:=optional,
              org.osgi.service.log;version="[1.0.0,2.0.0)",
              org.osgi.util.tracker;version="[1.0.0,2.0.0)",
              *
            </Import-Package>
          </instructions>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.ops4j</groupId>
        <artifactId>maven-pax-plugin</artifactId>
        <version>1.4</version>
        <configuration>
          <noDependencies>false</noDependencies>
          <profiles>log,web,compendium</profiles>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <pluginRepositories>
    <pluginRepository>
      <id>ops4j.releases</id>
      <url>https://repository.ops4j.org/maven2</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <report>dependencies</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>

  <profiles>
    <profile>
      <!-- Distribution profile adaption for get also the embedded classes into the sources jar-->
      <id>dist</id>
      <build>
        <plugins>
          <!-- Unpack dependencies in target/sources -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>src-dependencies</id>
                <phase>package</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.jolokia</groupId>
                      <artifactId>jolokia-core</artifactId>
                      <classifier>sources</classifier>
                    </artifactItem>
                    <artifactItem>
                      <groupId>org.jolokia</groupId>
                      <artifactId>jolokia-jsr160</artifactId>
                      <classifier>sources</classifier>
                    </artifactItem>
                    <artifactItem>
                      <groupId>com.googlecode.json-simple</groupId>
                      <artifactId>json-simple</artifactId>
                      <classifier>sources</classifier>
                    </artifactItem>
                  </artifactItems>
                  <outputDirectory>${project.build.directory}/sources</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.9</version>
            <executions>
              <execution>
                <id>add-source</id>
                <phase>package</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${project.build.directory}/sources</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!-- Has to be mentioned again for the proper calling order of the plugins -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
