<?xml version="1.0"?>
<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>
  <groupId>eu.unicore</groupId>
  <artifactId>unicore-parent</artifactId>
  <version>4.1.0</version>
  <packaging>pom</packaging>
  <description>UNICORE parent POM</description>
  <inceptionYear>2010</inceptionYear>
  <organization>
    <name>UNICORE</name>
    <url>https://www.unicore.eu</url>
  </organization>
  <url>https://github.com/UNICORE-EU/tools/</url>
  <name>UNICORE parent POM</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.target.jdk>17</project.target.jdk>
    <exec.maven.plugin.version>3.5.0</exec.maven.plugin.version>
    <specification.version>${project.version}</specification.version>
    <automatic.module.name>${project.groupId}.${project.artifactId}</automatic.module.name>
  </properties>

  <developers>
    <developer>
      <name>The UNICORE Team</name>
      <organization>UNICORE</organization>
      <organizationUrl>https://github.com/UNICORE-EU</organizationUrl>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/UNICORE-EU/tools.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/UNICORE-EU/tools.git</developerConnection>
    <url>https://github.com/UNICORE-EU/tools</url>
  </scm>

  <licenses>
    <license>
      <name>BSD</name>
      <comments>License file is distributed with the binary and source packages.</comments>
    </license>
  </licenses>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.5.0</version>
        <executions>
          <execution>
            <id>enforce-maven</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>3.6.3</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.1</version>
        <inherited>true</inherited>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>verify</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
            <inherited>true</inherited>
          </execution>
        </executions>
        <configuration>
          <attach>true</attach>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.7.0</version>
        <executions>
       <execution>
          <id>attach-javadocs</id>
          <goals>
            <goal>jar</goal>
          </goals>
        </execution>
      </executions>
        <configuration>
          <additionalJOption>-Xdoclint:none</additionalJOption>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>3.2.8</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>0.9.0</version>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
	        <autoPublish>true</autoPublish>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.5.2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.13.0</version>
          <configuration>
	          <release>${project.target.jdk}</release>
            <maxmem>256M</maxmem>
            <encoding>UTF-8</encoding>
            <fork>${compiler.fork}</fork>
            <forceJavacCompilerUse>true</forceJavacCompilerUse>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.4.2</version>
          <configuration>
            <archive>
              <manifestEntries>
                <Specification-Title>${project.name}</Specification-Title>
                <Specification-Vendor>UNICORE</Specification-Vendor>
                <Specification-Version>${specification.version}</Specification-Version>
                <Implementation-Title>${project.name}</Implementation-Title>
                <Implementation-Vendor-Id>unicore.eu</Implementation-Vendor-Id>
                <Implementation-Vendor>UNICORE</Implementation-Vendor>
                <Implementation-Version>${project.version}</Implementation-Version>
                <Automatic-Module-Name>${automatic.module.name}</Automatic-Module-Name>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.14</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <!-- 'packman' profile for using the rpm/deb/tgz packaging tool -->
    <profile>
      <id>packman</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>${exec.maven.plugin.version}</version>
            <executions>
              <execution>
                <phase>package</phase>
                <configuration>
                  <executable>bash</executable>
                  <arguments>
                    <argument>-c</argument>
                    <argument>[ -d target/tools ] ||  git clone --depth 1 https://github.com/UNICORE-EU/tools.git target/tools</argument>
                  </arguments>
                </configuration>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <phase>package</phase>
                <configuration>
                  <target>
                    <ant antfile="${basedir}/target/tools/packman/main.xml">
                      <target name="main"/>
                    </ant>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
            <!-- TODO: required currently on Debian 6 (??) -->
            <dependencies>
              <dependency>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-http</artifactId>
                <version>2.0</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- Generate a code coverage report using JaCoCo -->
    <profile>
      <id>code-coverage</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.14</version>
            <executions>
              <execution>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
              <execution>
                <id>report</id>
                <phase>test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <argLine>@{argLine}</argLine>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
