<!--
  This module is meant to create a distribution fragement that contains
  Apache Felix and associated configuration files and bundles.
  The layout relative to glassfish root looks like this:
  osgi/
    felix/
       bin/
          felix.jar
       conf/
          config.properties
          system.properties
  modules/
       org.apache.felix.shell.jar 
       org.apache.felix.shell.tui.jar 
       org.apache.felix.shell.remote.jar 
       autostart/
          org.apache.felix.scr.jar 

   This is more or less how the layout would look if one downloads the Felix
   distribution from Felix project and installs. The only difference being we keep
   the bundles in glassfish/modules dir as opposed to bundle dir in felix.
-->
<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>org.glassfish.osgi-platforms</groupId>
      <artifactId>osgi-platforms</artifactId>
      <version>3.0.1-b12</version>
      <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>felix</artifactId>
    <name>Apache Felix and associated bundles and configuration files</name>
    <!-- This is a distribution fragement.
         It is distributed as part of nucleus-base. 
    -->
    <packaging>distribution-fragment</packaging>
    <properties>
        <felix.outdir>${project.build.OutputDirectory}/glassfish/osgi/felix/</felix.outdir>
        <glassfish.modulesdir>${project.build.OutputDirectory}/glassfish/modules/</glassfish.modulesdir>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                           <goal>copy</goal>
                        </goals>
                        <configuration>
                            <stripVersion>true</stripVersion>
                            <artifactItems>
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.main</artifactId>
                               <version>2.0.2</version>
                               <outputDirectory>${felix.outdir}/bin</outputDirectory>
                               <destFileName>felix.jar</destFileName>
                             </artifactItem>
                             <!-- We bundle Felix Shell bundles so that
                                  user can use them to utilize the full power
                                  of Felix even while using GlassFish -->
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.shell</artifactId>
                               <version>1.4.1</version>
                               <type>jar</type>
                               <outputDirectory>${glassfish.modulesdir}</outputDirectory>
                             </artifactItem>
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.shell.tui</artifactId>
                               <version>1.4.1</version>
                               <type>jar</type>
                               <outputDirectory>${glassfish.modulesdir}</outputDirectory>
                             </artifactItem>
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.shell.remote</artifactId>
                               <version>1.0.4</version>
                               <type>jar</type>
                               <outputDirectory>${glassfish.modulesdir}</outputDirectory>
                             </artifactItem>
                             <!-- We install fileinstall bundle which monitors modules
                                  dir and autodeploy dir for addition/removal/updation of bundles -->
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.fileinstall</artifactId>
                               <version>2.0.4</version>
                               <type>jar</type>
                               <outputDirectory>${glassfish.modulesdir}</outputDirectory>
                             </artifactItem>
                             <!-- fileinstall needs configadmin service -->
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.configadmin</artifactId>
                               <version>1.2.4</version>
                               <type>jar</type>
                               <outputDirectory>${glassfish.modulesdir}</outputDirectory>
                             </artifactItem>
                             <artifactItem>
                               <groupId>org.apache.felix</groupId>
                               <artifactId>org.apache.felix.scr</artifactId>
                               <version>1.0.8</version>
                               <type>jar</type>
                               <outputDirectory>${glassfish.modulesdir}/autostart/</outputDirectory>
                             </artifactItem>
                           </artifactItems>
                         </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
                <artifactId>maven-antrun-extended-plugin</artifactId>
                <configuration>
                    <tasks>
                        <ant dir="." antfile="build.xml" target="create.bundle" />
                    </tasks>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <extensions>
            <extension>
                <groupId>org.glassfish.build</groupId>
                <artifactId>maven-glassfishbuild-extension</artifactId>
                <version>${project.version}</version>
            </extension>
        </extensions>
    </build>

    <dependencies>
        <!--
            add it as a test scope dependency so that IDEs can recognize this as a dependency
            and show the source code during the debugging
        -->
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.main</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
