<?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">
	<modelVersion>4.0.0</modelVersion>
	<groupId>de.dlr.gsoc.mcds</groupId>
	<artifactId>mosdl</artifactId>
	<version>0.1.1</version>
	<packaging>maven-plugin</packaging>

	<name>MOSDL</name>
	<description>Mission Operations Service Description Language</description>
	<url>https://github.com/DLR-RB/mosdl</url>
	<inceptionYear>2019</inceptionYear>
	
	<licenses>
		<license>
			<name>Apache License, Version 2.0</name>
			<url>https://github.com/DLR-RB/mosdl/LICENSE.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>
	
	<organization>
		<name>Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR, German Aerospace Center)</name>
		<url>https://www.dlr.de/</url>
	</organization>
	
	<developers>
		<developer>
			<name>Stefan Gärtner</name>
			<email>stefan.gaertner@dlr.de</email>
			<url>https://github.com/S-Gaertner</url>
			<organization>German Space Operations Center (GSOC), DLR</organization>
		</developer>
	</developers>
	
	<issueManagement>
		<system>GitHub</system>
		<url>https://github.com/DLR-RB/mosdl/issues</url>
	</issueManagement>
	
	<scm>
		<connection>scm:git:https://github.com/DLR-RB/mosdl.git</connection>
		<developerConnection>scm:git:https://github.com/DLR-RB/mosdl.git</developerConnection>
		<url>https://github.com/DLR-RB/mosdl</url>
	</scm>

	<distributionManagement>
		<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>
	
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<cli.classifier>cli</cli.classifier>
		<cli.mainClass>de.dlr.gsoc.mcds.mosdl.CliMain</cli.mainClass>
	</properties>

	<dependencies>
		<!-- ANTLR runtime needed by generated lexer/parser code for MOSDL grammar. -->
		<dependency>
			<groupId>org.antlr</groupId>
			<artifactId>antlr4-runtime</artifactId>
			<version>4.7.2</version>
		</dependency>
		<!-- Use SLF4J for logging - Maven provides an implementation when run as Maven plugin. -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.7.25</version>
		</dependency>
		<!-- slf4j-simple used as logging implementation when run from command line;
		optional, because if used as a library the user is expected to provide his own SLF4J implementation. -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>1.7.25</version>
			<optional>true</optional>
		</dependency>
		<!-- Maven dependencies will be provided by the Maven build system. -->
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-plugin-api</artifactId>
			<version>3.6.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.plugin-tools</groupId>
			<artifactId>maven-plugin-annotations</artifactId>
			<version>3.6.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-project</artifactId>
			<version>2.0.11</version>
			<scope>provided</scope>
		</dependency>

		<!-- Test dependencies -->
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<version>5.5.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.xmlunit</groupId>
			<artifactId>xmlunit-core</artifactId>
			<version>2.6.3</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<!-- Create descriptor in order to be able to use this project as Maven plugin. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-plugin-plugin</artifactId>
				<version>3.6.0</version>
				<configuration>
					<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
				</configuration>
				<executions>
					<execution>
						<id>default-descriptor</id>
						<phase>process-classes</phase>
						<goals>
							<goal>descriptor</goal>
						</goals>
					</execution>
				</executions>			
			</plugin>
			<!-- Generate Java code from XML Schemas. -->
			<plugin>
				<groupId>org.jvnet.jaxb2.maven2</groupId>
				<artifactId>maven-jaxb2-plugin</artifactId>
				<version>0.14.0</version>
				<executions>
					<execution>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<schemaDirectory>src/main/resources</schemaDirectory>
							<schemaIncludes>
								<include>**/*.xsd</include>
							</schemaIncludes>
							<bindingDirectory>src/main/resources</bindingDirectory>
							<bindingIncludes>
								<include>**/*.xjb</include>
							</bindingIncludes>
							<locale>en</locale>
							<!-- XML Elements Wrapper extension in order to prevent clumsy code generation like ProductDefinition.getFields().getFields().get(0) -->
							<extension>true</extension>
							<args>
								<arg>-Xxew</arg>
								<arg>-Xnamespace-prefix</arg>
							</args>
							<plugins>
								<!-- XML Elements Wrapper plugin -->
								<plugin>
									<groupId>com.github.jaxb-xew-plugin</groupId>
									<artifactId>jaxb-xew-plugin</artifactId>
									<version>1.10</version>
								</plugin>
								<!-- Plugin for controlling namespace prefix generation. -->
								<dependency>
									<groupId>org.jvnet.jaxb2_commons</groupId>
									<artifactId>jaxb2-namespace-prefix</artifactId>
									<version>1.3</version>
								</dependency>
							</plugins>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!-- Compile ANTLR grammar file to Java lexer/parser code. -->
			<plugin>
				<groupId>org.antlr</groupId>
				<artifactId>antlr4-maven-plugin</artifactId>
				<version>4.7.2</version>
				<executions>
					<execution>
						<goals>
							<goal>antlr4</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<listener>true</listener>
					<visitor>false</visitor>
				</configuration>
			</plugin>
			<!-- Perform unit tests. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>3.0.0-M4</version>
			</plugin>
			<!-- Perform integration tests. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<version>3.0.0-M4</version>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!-- Code coverage reporting. -->
			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>0.8.5</version>
				<configuration>
					<excludes>
						<!-- Exclude auto-generated classes by XJC and ANTLR. -->
						<exclude>org/ccsds/schema/**/*</exclude>
						<exclude>**/MOSDLBaseListener*</exclude>
						<exclude>**/MOSDLLexer*</exclude>
						<exclude>**/MOSDLListener*</exclude>
						<exclude>**/MOSDLParser*</exclude>
					</excludes>
				</configuration>
				<executions>
					<execution>
						<id>prepare-agent</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
					</execution>
					<execution>
						<id>report</id>
						<goals>
							<goal>report</goal>
						</goals>
					</execution>
				</executions>
			</plugin>			
			<!-- Add version information to manifest file for runtime inspection.  -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.2.0</version>
				<configuration>
					<archive>
						<manifest>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<!-- Create executable fat jar for command-line usage of this project. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.2.1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<createDependencyReducedPom>true</createDependencyReducedPom>
							<shadedArtifactAttached>true</shadedArtifactAttached>
							<shadedClassifierName>${cli.classifier}</shadedClassifierName>
							<transformers>
								<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>${cli.mainClass}</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!-- Create command line program distribution package. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.2.0</version>
				<executions>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<attach>false</attach>
							<appendAssemblyId>false</appendAssemblyId>
							<descriptors>
								<descriptor>cli-distribution.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	
	<profiles>
		<!-- Javadoc attachment, source attachment and artifact signing are only necessary when releasing. -->
		<profile>
			<id>release</id>
			<build>
				<plugins>
					<!-- Attach artifact containing project sources. -->
					<plugin>
						<artifactId>maven-source-plugin</artifactId>
						<version>3.2.0</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<goals>
									<goal>jar-no-fork</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<!-- Attach artifact containing project javadoc. -->
					<plugin>
						<artifactId>maven-javadoc-plugin</artifactId>
						<version>3.1.1</version>
						<executions>
							<execution>
								<id>attach-javadocs</id>
								<goals>
									<goal>jar</goal>
								</goals>
								<configuration>
									<!-- exclude auto-generated code that generates lots of Javadoc warnings -->
									<excludePackageNames>org.ccsds.schema.*</excludePackageNames>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- Sign artifacts for deployment to Maven Central; requires gpg executable. -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>1.6</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>