<?xml version="1.0" encoding="UTF-8"?>
<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">

    <!--

        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.
    -->

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>tooling</artifactId>
        <version>4.3.7</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>karaf-maven-plugin</artifactId>
    <packaging>maven-plugin</packaging>
    <name>Apache Karaf :: Tooling :: Maven Karaf Plugin</name>

    <properties>
        <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
        <mvn.opts />
        <invoker.skip />
        <compiler.fork />
        <jacoco-class-line-covered-ratio>0.00</jacoco-class-line-covered-ratio>
        <jacoco-class-instruction-covered-ratio>0.00</jacoco-class-instruction-covered-ratio>
        <jacoco-class-missed-count-maximum>1</jacoco-class-missed-count-maximum>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.karaf</groupId>
                <artifactId>karaf-bom</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>${javax.annotation.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.annotation</groupId>
                    <artifactId>jsr250-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.resolver</groupId>
            <artifactId>maven-resolver-api</artifactId>
            <version>${maven.resolver.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.resolver</groupId>
            <artifactId>maven-resolver-util</artifactId>
            <version>${maven.resolver.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-resolver-provider</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-resolver-provider</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>${maven-plugin-annotations.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>org.apache.karaf.util</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>org.apache.karaf.tools.utils</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-filtering</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-utils</artifactId>
            <version>${plexus-utils.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.bundlerepository</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.aether</groupId>
                    <artifactId>aether-util</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-archiver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.osgi</groupId>
                    <artifactId>org.osgi.core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-archiver</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-archiver</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-archiver</artifactId>
            <version>4.2.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.fileinstall</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>org.apache.karaf.features.core</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>org.apache.karaf.shell.console</artifactId>
                    <groupId>org.apache.karaf.shell</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.profile</groupId>
            <artifactId>org.apache.karaf.profile.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.resolver</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.osgi</groupId>
                    <artifactId>org.osgi.core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-wrap</artifactId>
            <classifier>uber</classifier>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-aether</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-war</artifactId>
            <classifier>uber</classifier>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.deployer</groupId>
            <artifactId>org.apache.karaf.deployer.spring</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.deployer</groupId>
            <artifactId>org.apache.karaf.deployer.blueprint</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.deployer</groupId>
            <artifactId>org.apache.karaf.deployer.features</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.deployer</groupId>
            <artifactId>org.apache.karaf.deployer.kar</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.kar</groupId>
            <artifactId>org.apache.karaf.kar.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.shell</groupId>
            <artifactId>org.apache.karaf.shell.console</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>org.apache.karaf.main</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.diagnostic</groupId>
            <artifactId>org.apache.karaf.diagnostic.boot</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-finder-shaded</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>biz.aQute.bnd</groupId>
            <artifactId>biz.aQute.bndlib</artifactId>
            <version>6.1.0</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>${project.basedir}/src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>${project.basedir}/src/test/filtered-resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <debug>true</debug>
                    <projectsDirectory>src/it</projectsDirectory>
                    <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                    <pomIncludes>
                        <pomInclude>*/pom.xml</pomInclude>
                    </pomIncludes>
                    <pomExcludes>
                        <!-- The following IT may fail as the SNAPSHOT is not on a remote repo -->
                        <!-- So, it requires to skip test for the early first build to populate the local repo -->
                        <pomExclude>test-run/pom.xml</pomExclude>
                        <pomExclude>test-assembly/pom.xml</pomExclude>
                        <pomExclude>test-check-dependencies-failure/pom.xml</pomExclude>
                        <pomExclude>test-assembly-prop-edits/pom.xml</pomExclude>
                        <pomExclude>test-dockerfile/pom.xml</pomExclude>
                    </pomExcludes>
                    <postBuildHookScript>verify</postBuildHookScript>
                    <localRepositoryPath>${project.build.directory}/system</localRepositoryPath>
                    <settingsFile>${project.build.testOutputDirectory}/settings.xml</settingsFile>
                    <mergeUserSettings>true</mergeUserSettings>
                    <mavenOpts>${mvn.opts}</mavenOpts>
                    <skipInstallation>${invoker.skip}</skipInstallation>
                    <skipInvocation>${invoker.skip}</skipInvocation>
                    <goals>
                        <goal>package</goal>
                    </goals>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>install</goal>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-offline</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <invokerPropertiesFile>src/test/offline.properties</invokerPropertiesFile>
                            <pomExcludes>
			        <!-- The following IT may fail as the SNAPSHOT is not on a remote repo -->
                                <!-- So, it requires to skip test for the early first build to populate the local repo -->
                                <pomExclude>test-run/pom.xml</pomExclude>
                                <pomExclude>test-assembly/pom.xml</pomExclude>
                                <pomExclude>test-check-dependencies-failure/pom.xml</pomExclude>
                                <pomExclude>test-assembly-prop-edits/pom.xml</pomExclude>
                                <pomExclude>test-dockerfile/pom.xml</pomExclude>
                            </pomExcludes>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>xmlunit</groupId>
                        <artifactId>xmlunit</artifactId>
                        <version>1.3</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>default-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <maxmem>256M</maxmem>
                    <fork>${compiler.fork}</fork>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <rules>
                        <rule>
                            <element>CLASS</element>

                            <limits>
                                <limit>
                                    <counter>LINE</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>${jacoco-class-line-covered-ratio}</minimum>
                                </limit>
                                <limit>
                                    <counter>INSTRUCTION</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>${jacoco-class-instruction-covered-ratio}</minimum>
                                </limit>
                                <limit>
                                    <counter>CLASS</counter>
                                    <value>MISSEDCOUNT</value>
                                    <maximum>${jacoco-class-missed-count-maximum}</maximum>
                                </limit>
                            </limits>
                        </rule>
                    </rules>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <!--<outputDirectory>target/site</outputDirectory>-->
        <plugins>
            <plugin>
                <artifactId>maven-plugin-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
    <profiles>
        <profile>
            <id>skiptests</id>
            <properties>
                <invoker.skip>true</invoker.skip>
            </properties>
            <activation>
                <property>
                    <name>skipTests</name>
                </property>
            </activation>
        </profile>
        <profile>
            <id>skiptests2</id>
            <properties>
                <invoker.skip>true</invoker.skip>
            </properties>
            <activation>
                <property>
                    <name>maven.test.skip</name>
                    <value>true</value>
                </property>
            </activation>
        </profile>
        <profile>
            <id>java11</id>
            <activation>
                <jdk>[11,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>**/*RunMojoTest.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
