<?xml version="1.0"?>
<!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you 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>
    <parent>
        <groupId>org.apache.felix</groupId>
        <artifactId>atomos-parent</artifactId>
        <version>1.0.0</version>
        <relativePath>../atomos-parent/pom.xml</relativePath>
    </parent>
    <artifactId>org.apache.felix.atomos</artifactId>
    <name>atomos</name>
    <scm>
        <connection>scm:git:https://github.com/apache/felix-atomos.git</connection>
        <developerConnection>scm:git:https://github.com/apache/felix-atomos.git</developerConnection>
        <url>https://github.com/apache/felix-atomos</url>
        <tag>atomos-distribution-1.0.0</tag>
    </scm>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.gogo.runtime</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>default-compile</id>
            <dependencies>
                <dependency>
                   <groupId>org.osgi</groupId>
                    <artifactId>osgi.core</artifactId>
                </dependency>
            </dependencies>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <!-- This profile is only to enable running unit tests in IDEs
             The artifact does actually exist.
             The actual org.apache.felix.atomos:osgi.core confuses
             IDEs because it has no module-info.java file in
             the source therefore the IDE does not know it is
             supposed to transitively require the osgi implementation.
             This effectively causes the IDE to refuse to grant access
             to the org.osgi packages for compilation.
        <profile>
            <id>unit-test</id>
            <dependencies>
                <dependency>
                    <groupId>org.eclipse.platform</groupId>
                    <artifactId>org.eclipse.osgi</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.felix.atomos.equinox</groupId>
                    <artifactId>osgi.core</artifactId>
                    <version>8.0.0</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        -->
        <profile>
            <id>equinox</id>
            <dependencies>
                <dependency>
                    <groupId>org.eclipse.platform</groupId>
                    <artifactId>org.eclipse.osgi</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.felix.atomos</groupId>
                    <artifactId>osgi.core</artifactId>
                    <version>8.0.0</version>
                    <classifier>AtomosEquinox</classifier>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>felix</id>
            <dependencies>
                <dependency>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.framework</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.apache.felix.atomos</groupId>
                    <artifactId>osgi.core</artifactId>
                    <version>8.0.0</version>
                    <classifier>AtomosFelix</classifier>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>java8</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-compile</id>
                                <configuration>
                                    <!-- compile everything with the default to ensure module-info is correct -->
                                    <release>${java.version}</release>
                                </configuration>
                            </execution>
                            <!-- compile the packages that must work with java 8 -->
                            <execution>
                                <id>java8-compile</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <excludes>
                                        <exclude>module-info.java</exclude>
                                        <exclude>org/atomos/framework/modules/*.java</exclude>
                                    </excludes>
                                    <release combine.self="override" />
                                    <source>1.8</source>
                                    <target>1.8</target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <links>
                        <link>https://docs.osgi.org/javadoc/osgi.core/8.0.0/</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <!-- Build an executable JAR -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>