<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.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>

    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-maven-parent</artifactId>
    <version>4.0.5</version>
    <packaging>pom</packaging>

    <name>DataNucleus Maven parent project</name>
    <description>
        Provides common configuration for DataNucleus projects.
    </description>

    <!-- Use a URL fragment so the child URLs are valid when the artifact ID is appended -->
    <url>http://www.datanucleus.org/#</url>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <scm>
        <!-- The inheritance model will append the artifact-id to the child 
            definitions and apparently, currently there's no way to suppress this (see 
            http://jira.codehaus.org/browse/MRELEASE-331) hence we need to redefine the 
            scm section for all child POM's. Alternatively we can use a "connectionUrl" 
            property for some of the plugins e.g. maven-release-plugin and maven-scm-plugin, 
            however some functionality like site generation relies on the scm section 
            declaration and it will display wrong URLs (inherited from oss-parent) -->
        <connection>scm:git:git@github.com:datanucleus/${project.artifactId}.git</connection>
        <developerConnection>scm:git:git@github.com:datanucleus/${project.artifactId}.git</developerConnection>
        <url>https://github.com/datanucleus/</url>
    </scm>

    <developers>
        <developer>
            <id>andy</id>
            <name>Andy</name>
            <organization>DataNucleus</organization>
        </developer>
    </developers>

    <properties>
        <encoding>UTF-8</encoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <skipCoverage>true</skipCoverage>
        <jacoco.version>0.7.0.201403182114</jacoco.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${basedir}</directory>
                            <includes>
                                <include>*.log</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <skip>${skipCoverage}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <!-- 2.4 has an issue with m2e see -> https://bugs.eclipse.org/bugs/show_bug.cgi?id=406507 -->
                <version>2.3.2</version>
                <configuration>
                    <!-- Pick the MANIFEST generated by the bundle plugin -->
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.3.1</version>
            </plugin>
        </plugins>

        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh-external</artifactId>
                <version>2.2</version>
            </extension>
        </extensions>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.4.0</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <!-- Need to have MANIFEST.MF in place before 
                                packaging, so unit-tests will work -->
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-enforcer-plugin</artifactId>
                                        <versionRange>[1.0.0,)</versionRange>
                                        <goals><goal>enforce</goal></goals>
                                    </pluginExecutionFilter>
                                    <action><ignore /></action>
                                </pluginExecution>
                                <pluginExecution>
                                	<pluginExecutionFilter>
                                		<groupId>org.jacoco</groupId>
                                		<artifactId>jacoco-maven-plugin</artifactId>
                                		<versionRange>[0.6.5.201403032054,)</versionRange>
                                		<goals><goal>prepare-agent</goal></goals>
                                	</pluginExecutionFilter>
                                	<action><ignore /></action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <!-- Test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.1</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
        <profile>
            <id>JDK7-warning</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-enforcer-plugin</artifactId>
                            <version>1.3.1</version>
                            <executions>
                                <execution>
                                    <id>check-cross-compile</id>
                                    <goals>
                                        <goal>enforce</goal>
                                    </goals>
                                    <configuration>
                                        <fail>false</fail>
                                        <rules>
                                            <requireEnvironmentVariable>
                                                <variableName>JAVA7_HOME</variableName>
                                                <message>
                                            <![CDATA[
#########################################################################################################
#### To ensure JDK7 compatibility please set JAVA7_HOME environment variable to a JDK7 installation! ####
#########################################################################################################
                                            ]]>
                                                </message>
                                            </requireEnvironmentVariable>
                                        </rules>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </build>
        </profile>

        <profile>
            <!-- When JAVA7 is setup we use it to cross compile -->
            <id>JDK7</id>
            <activation>
                <property>
                    <name>env.JAVA7_HOME</name>
                </property>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <artifactId>maven-compiler-plugin</artifactId>
                            <configuration>
                                <compilerArguments>
                                    <bootclasspath>${JAVA7_HOME}/jre/lib/rt.jar:${JAVA7_HOME}/jre/lib/jce.jar</bootclasspath>
                                </compilerArguments>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>sonar</id>
            <properties>
                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.jacoco.itReportPath>${project.build.directory}/jacoco-intg.exec</sonar.jacoco.itReportPath>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${jacoco.version}</version>
                        <executions>
                            <execution>
                                <id>merge-integration-tests-coverage</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>merge</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco-intg.exec</destFile>
                                    <fileSets>
                                      <fileSet>
                                        <directory>intg-coverage</directory>
                                        <includes>
                                          <include>**/*.exec</include>
                                        </includes>
                                      </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <distributionManagement>
        <!-- For nightly build process -->
        <snapshotRepository>
            <id>datanucleus-nightly</id>
            <name>DataNucleus Nightly</name>
            <url>file:${user.home}/htdocs/downloads/maven2-nightly/</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>
</project>
