<?xml version="1.0" encoding="UTF-8"?>

<!--
    Licensed under the European Space Agency Public License, Version 2.0
    You may not use this file except in compliance with the License.

    Except as expressly set forth in this License, the Software is provided to
    You on an "as is" basis and without warranties of any kind, including without
    limitation merchantability, fitness for a particular purpose, absence of
    defects or errors, accuracy or non-infringement of intellectual property rights.
 
    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>
    <groupId>int.esa.ccsds.mo</groupId>
    <artifactId>parent</artifactId>
    <version>14.2</version>
    <packaging>pom</packaging>
  
    <name>ESA MO POM</name>
    <description>ESA top level POM for CCSDS MO based artifacts</description>
    <url>http://www.esa.int</url>
  
    <organization>
        <name>ESA</name>
        <url>http://www.esa.int</url>
    </organization>
  
    <licenses>
        <license>
            <name>The European Space Agency Public License, Version 2.0</name>
            <url>https://raw.githubusercontent.com/esa/mo-services-java/master/LICENCE.md</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:esa/mo-services-java.git</connection>
        <developerConnection>scm:git:git@github.com:esa/mo-services-java.git</developerConnection>
        <url>https://github.com/esa/mo-services-java</url>
    </scm>
  
    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/esa/mo-services-java/issues</url>
    </issueManagement>
  
    <distributionManagement>
        <site>
            <id>Sonatype</id>
            <url>https://oss.sonatype.org/</url>
        </site>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <developers>
        <developer>
            <id>CesarCoelho</id>
            <name>Cesar Coelho</name>
            <url>https://github.com/CesarCoelho</url>
        </developer>
    </developers>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <esa.mo.version>14.2</esa.mo.version>
        <ccsds.specification.version>${esa.mo.version}</ccsds.specification.version>
        <extra.specification.version>${esa.mo.version}</extra.specification.version>
    
        <ccsds.specification.download.skip>true</ccsds.specification.download.skip>
        <ccsds.specification.download.group>int.esa.ccsds.mo</ccsds.specification.download.group>
        <ccsds.specification.download.artifact>xml-ccsds-mo-prototypes</ccsds.specification.download.artifact>
        <ccsds.specification.download.version>${ccsds.specification.version}</ccsds.specification.download.version>
        <ccsds.specification.download.directory>${project.build.directory}/xml</ccsds.specification.download.directory>
        <ccsds.specification.download.filter></ccsds.specification.download.filter>
        <ccsds.specification.download.ref-skip>true</ccsds.specification.download.ref-skip>
        <ccsds.specification.download.ref-group>int.esa.ccsds.mo</ccsds.specification.download.ref-group>
        <ccsds.specification.download.ref-artifact>xml-ccsds-mo-prototypes</ccsds.specification.download.ref-artifact>
        <ccsds.specification.download.ref-version>${ccsds.specification.version}</ccsds.specification.download.ref-version>
        <ccsds.specification.download.ref-directory>${project.build.directory}/xml-ref</ccsds.specification.download.ref-directory>
        <ccsds.specification.download.ref-filter>**/area001-v003-MAL.xml</ccsds.specification.download.ref-filter>
        <esa.stubgen.xmlDirectory>${project.build.directory}/xml</esa.stubgen.xmlDirectory>
        <esa.stubgen.xmlRefDirectory>${project.build.directory}/xml-ref/xml</esa.stubgen.xmlRefDirectory>
        <!--
            Which generator builds the APIs. "Java" is the existing one and is what every
            build uses; "Java2" is api-generator-lib, reached through the adapter in the
            plugin. Selecting it for the whole build is what -Pnew-generator does, and
            overriding this property in one module is how a single module is tried.
            Flipping the default is the v15.0 cut-over - see
            api-generator/api-generator-lib/DESIGN.md, section 10.9.
        -->
        <esa.stubgen.generator>Java</esa.stubgen.generator>
    </properties>
  
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>mal-impl</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <!-- MO API Generator -->
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>generator-interfaces</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>generator-docs</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>generator-java</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>api-generator-lib</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <!-- APIs -->
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>api-area001-v003-mal</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>api-area002-v001-com</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>api-area003-v001-common</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>api-area004-v002-mc</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>api-area009-v001-mpd</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <!-- MO services implementations -->
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>services-area003-v001-common</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>services-area004-v002-mc</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>services-area009-v001-mpd</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <!-- Encoders/Decoders -->
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>encoding-string</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>encoding-binary</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>encoding-xml</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <!-- Transports -->
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>transport-generic</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>transport-rmi</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>transport-tcpip</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>transport-http</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>transport-zmtp</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <dependency>
                <groupId>int.esa.ccsds.mo</groupId>
                <artifactId>transport-spp</artifactId>
                <version>${esa.mo.version}</version>
            </dependency>
            <!-- External dependencies -->
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.4.0-b180830.0359</version>
            </dependency>
            <dependency>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-plugin-api</artifactId>
                <version>3.8.6</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>3.0.2</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-core</artifactId>
                <version>2.3.0</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>2.4.0-b180830.0438</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
  
    <build>
        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${basedir}</directory>
                <includes>
                    <include>LICENCE.md</include>
                </includes>
            </resource>
        </resources>
    
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.4.1</version>
                    <executions>
                        <execution>
                            <id>enforce</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <DependencyConvergence/>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                    <executions>
                        <execution>
                            <id>download-xml</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <skip>${ccsds.specification.download.skip}</skip>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>${ccsds.specification.download.group}</groupId>
                                        <artifactId>${ccsds.specification.download.artifact}</artifactId>
                                        <version>${ccsds.specification.download.version}</version>
                                        <type>jar</type>
                                        <overWrite>false</overWrite>
                                        <outputDirectory>${ccsds.specification.download.directory}</outputDirectory>
                                        <includes>${ccsds.specification.download.filter}</includes>
                                    </artifactItem>
                                </artifactItems>
                                <overWriteSnapshots>true</overWriteSnapshots>
                            </configuration>
                        </execution>
                        <execution>
                            <id>download-ref-xml</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <skip>${ccsds.specification.download.ref-skip}</skip>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>${ccsds.specification.download.ref-group}</groupId>
                                        <artifactId>${ccsds.specification.download.ref-artifact}</artifactId>
                                        <version>${ccsds.specification.download.ref-version}</version>
                                        <type>jar</type>
                                        <overWrite>false</overWrite>
                                        <outputDirectory>${ccsds.specification.download.ref-directory}</outputDirectory>
                                        <includes>${ccsds.specification.download.ref-filter}</includes>
                                    </artifactItem>
                                </artifactItems>
                                <overWriteSnapshots>true</overWriteSnapshots>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.3.0</version>
                    <executions>
                        <execution>
                            <id>add-source</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>add-source</goal>
                            </goals>
                            <configuration>
                                <sources>
                                    <source>${project.build.directory}/generated-sources/stub</source>
                                </sources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>int.esa.ccsds.mo</groupId>
                    <artifactId>api-generator-maven-plugin</artifactId>
                    <version>${esa.mo.version}</version>
                    <executions>
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <targetLanguages>
                                    <targetLanguage>${esa.stubgen.generator}</targetLanguage>
                                </targetLanguages>
                                <xmlDirectory>${esa.stubgen.xmlDirectory}</xmlDirectory>
                                <xmlRefDirectory>${esa.stubgen.xmlRefDirectory}</xmlRefDirectory>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>int.esa.ccsds.mo</groupId>
                            <artifactId>generator-java</artifactId>
                            <version>${esa.mo.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <source>1.8</source>
                        <target>1.8</target>
                        <!--            <compilerArgument>-Xlint:unchecked</compilerArgument>-->
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.6.0</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>${assembly.mainClass}</mainClass>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <finalName>${project.artifactId}</finalName>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.12.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxb2-maven-plugin</artifactId>
                    <version>2.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.2.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals> 
                        </execution>
                    </executions>
                </plugin>
                <plugin> 
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId> 
                    <version>3.4.0</version>
                    <executions> 
                        <execution> 
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin> 
                    <!-- explicitly define maven-deploy-plugin after other to force exec order -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId> 
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>default-deploy</id>
                            <phase>deploy</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals> 
                        </execution> 
                    </executions> 
                    <!-- Skip the Deploy by default, in favour of Nexus Deploy Plugin -->
                    <configuration>
                        <skip>true</skip>
                    </configuration>                    
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                            <configuration>
                                <keyname>${gpg.keyname}</keyname>
                                <passphraseServerId>${gpg.keyname}</passphraseServerId>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <extensions>true</extensions>
                    <version>1.6.13</version>
                    <executions>
                        <execution>
                            <id>default-deploy</id>
                            <phase>deploy</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <serverId>ossrh</serverId>
                        <nexusUrl>https://ossrh-staging-api.central.sonatype.com</nexusUrl>
                        <autoReleaseAfterClose>false</autoReleaseAfterClose>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.4.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.4.0</version>
            </plugin>
        </plugins>
    </reporting>
    <profiles>
        <profile>
            <!-- Builds every API with api-generator-lib instead of the existing
                 generator. Nothing else changes; see DESIGN.md section 3. -->
            <id>new-generator</id>
            <properties>
                <esa.stubgen.generator>Java2</esa.stubgen.generator>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin> 
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId> 
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                    </plugin>                    
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
