<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>org.flexiblepower.defpi</groupId>
	<artifactId>master</artifactId>
	<version>22.01</version>
	<packaging>pom</packaging>

	<name>dEF-Pi master POM</name>
	<description>Distributed Electricity Flexibility Platform and Interface</description>
	<url>https://flexible-energy.eu/defpi</url>
	<inceptionYear>2017</inceptionYear>
	<organization>
		<name>Flexible Power Alliance Network</name>
		<url>http://flexible-energy.eu</url>
	</organization>

	<developers>
		<developer>
			<name>Maarten Kollenstart</name>
			<organization>TNO</organization>
			<organizationUrl>https://tno.nl</organizationUrl>
		</developer>

		<developer>
			<name>Wilco Wijbrandi</name>
			<organization>TNO</organization>
			<organizationUrl>https://tno.nl</organizationUrl>
		</developer>

		<developer>
			<name>Arun Subramanian</name>
			<organization>TNO</organization>
			<organizationUrl>https://tno.nl</organizationUrl>
		</developer>

		<developer>
			<name>Coen van Leeuwen</name>
			<organization>TNO</organization>
			<organizationUrl>https://tno.nl</organizationUrl>
		</developer>
	</developers>

	<scm>
		<connection>scm:git:git://github.com/flexiblepower/defpi-core.git</connection>
		<developerConnection>scm:git:ssh://github.com:flexiblepower/defpi-core.git</developerConnection>
		<url>http://github.com/flexiblepower/defpi-core</url>
	</scm>

	<licenses>
		<license>
			<name>Apache License, Version 2.0</name>
			<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.source>1.8</java.source>
		<java.target>1.8</java.target>

		<!-- The plugin needs the protobuf version to obtain the compiler from 
			maven central explicitly -->
		<protobuf.version>3.19.3</protobuf.version>
		<jackson.databind.version>2.13.1</jackson.databind.version>
		<json.version>20211205</json.version>
		<mongodb.version>3.12.10</mongodb.version>
		<log4j.version>2.17.1</log4j.version>
		<swagger.version>1.6.4</swagger.version>
		<junit.version>5.8.2</junit.version>
	</properties>

	<prerequisites>
		<maven>3.0.5</maven>
	</prerequisites>

	<modules>
		<module>service-parent</module>
		<module>service-parent/defpi-service</module>
		<module>../api</module>
		<module>../commons</module>
		<module>../codegen-common</module>
		<module>../maven-plugin</module>
		<module>../orchestrator</module>
		<module>../python-codegen</module>
		<module>../raml-service</module>
		<module>../service</module>
	</modules>

	<!-- Where to push the maven compiled jars -->
	<distributionManagement>
		<repository>
			<id>hesi</id>
			<name>HESI artifactory</name>
			<url>https://ci.hesi.energy/artifactory/libs-release-local</url>
		</repository>
	
		<snapshotRepository>
			<id>ossrh</id>
			<name>Sonatype snapshot repository</name>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
	</distributionManagement>

	<!-- Where to find dependencies -->
	<repositories>
		<repository>
			<id>sonatype-snapshot</id>
			<name>Sonatype snapshot repository</name>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>
	
	<pluginRepositories>
		<pluginRepository>
			<id>sonatype-snapshot</id>
			<name>Sonatype snapshot repository</name>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.projectlombok</groupId>
				<artifactId>lombok</artifactId>
				<version>1.18.22</version>
				<scope>provided</scope>
			</dependency>

			<dependency>
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-databind</artifactId>
				<version>${jackson.databind.version}</version>
			</dependency>

			<dependency>
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-annotations</artifactId>
				<version>${jackson.databind.version}</version>
			</dependency>

			<dependency>
				<groupId>org.mongodb</groupId>
				<artifactId>bson</artifactId>
				<version>${mongodb.version}</version>
			</dependency>

			<dependency>
				<groupId>org.mongodb</groupId>
				<artifactId>mongodb-driver</artifactId>
				<version>${mongodb.version}</version>
			</dependency>

			<dependency>
				<groupId>org.json</groupId>
				<artifactId>json</artifactId>
				<version>${json.version}</version>
			</dependency>

			<dependency>
				<groupId>org.mongodb.morphia</groupId>
				<artifactId>morphia</artifactId>
				<version>1.3.2</version>
			</dependency>

			<dependency>
				<groupId>com.google.protobuf</groupId>
				<artifactId>protobuf-java</artifactId>
				<version>${protobuf.version}</version>
			</dependency>

			<dependency>
				<groupId>org.flexiblepower.defpi</groupId>
				<artifactId>api</artifactId>
				<version>${project.version}</version>
			</dependency>

			<dependency>
				<groupId>org.flexiblepower.defpi</groupId>
				<artifactId>commons</artifactId>
				<version>${project.version}</version>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.7.33</version>
		</dependency>

		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-slf4j-impl</artifactId>
			<version>${log4j.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-api</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.9.0</version>
					<configuration>
						<source>${java.source}</source>
						<target>${java.target}</target>
					</configuration>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>3.0.0-M5</version>
					<configuration>
						<systemProperties>
							<property>
								<name>log4j.configurationFile</name>
								<value>src/test/resources/log4j2.xml</value>
							</property>
						</systemProperties>
						<rerunFailingTestsCount>2</rerunFailingTestsCount>
					</configuration>
				</plugin>

				<!-- These are just to set the version -->
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-clean-plugin</artifactId>
					<version>3.1.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-source-plugin</artifactId>
					<version>3.2.1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-deploy-plugin</artifactId>
					<version>3.0.0-M1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-install-plugin</artifactId>
					<version>3.0.0-M1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-jar-plugin</artifactId>
					<version>3.2.2</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<version>3.2.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-javadoc-plugin</artifactId>
					<version>3.3.1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-site-plugin</artifactId>
					<version>3.10.0</version>
				</plugin>

				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>license-maven-plugin</artifactId>
					<version>2.0.0</version>
				</plugin>

				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>versions-maven-plugin</artifactId>
					<version>2.8.1</version>
					<configuration>
						<rulesUri>https://raw.githubusercontent.com/defpi/configuration/master/version-rules.xml</rulesUri>
					</configuration>
				</plugin>

				<!-- The assembly plugin puts all java code in one jar -->
				<plugin>
					<artifactId>maven-assembly-plugin</artifactId>
					<version>3.3.0</version>
					<configuration>
						<archive>
							<manifest>
								<mainClass>${mainClass}</mainClass>
							</manifest>
						</archive>
						<descriptorRefs>
							<descriptorRef>jar-with-dependencies</descriptorRef>
						</descriptorRefs>
						<includeProjectBuildFilters>true</includeProjectBuildFilters>
					</configuration>
					<executions>
						<execution>
							<id>make-assembly</id>
							<phase>package</phase>
							<goals>
								<goal>single</goal>
							</goals>
						</execution>
					</executions>
				</plugin>

				<!-- Spotify's docker plugin builds, tags and pushed docker images -->
				<plugin>
					<groupId>com.spotify</groupId>
					<artifactId>docker-maven-plugin</artifactId>
					<version>1.2.2</version>

					<configuration>
						<registryUrl>${docker.registry}</registryUrl>
						<serverId>defpi-registry</serverId>
					</configuration>

					<executions>
						<execution>
							<!-- Build x86_64 image -->
							<id>build-image</id>
							<phase>package</phase>
							<goals>
								<goal>build</goal>
							</goals>
							<configuration>
								<dockerDirectory>${project.build.directory}/docker</dockerDirectory>
								<resources>
									<resource>
										<directory>${project.build.directory}</directory>
										<include>${project.artifactId}-${project.version}-jar-with-dependencies.jar</include>
									</resource>
								</resources>
								<imageName>${docker.imageName}:latest</imageName>
								<imageTags>
									<imageTag>${project.version}</imageTag>
								</imageTags>
							</configuration>
						</execution>
						<execution>
							<!-- Push latest image -->
							<id>push-latest-image</id>
							<phase>deploy</phase>
							<goals>
								<goal>push</goal>
							</goals>
							<configuration>
								<imageName>${docker.imageName}:latest</imageName>
							</configuration>
						</execution>
						<execution>
							<!-- Push versioned image -->
							<id>push-versioned-image</id>
							<phase>deploy</phase>
							<goals>
								<goal>push</goal>
							</goals>
							<configuration>
								<imageName>${docker.imageName}:${project.version}</imageName>
							</configuration>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</pluginManagement>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>license-maven-plugin</artifactId>
				<configuration>
					<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
					<emptyLineAfterHeader>true</emptyLineAfterHeader>
					<licenseName>apache_v2</licenseName>
					<failOnMissingHeader>true</failOnMissingHeader>
					<failOnNotUptodateHeader>true</failOnNotUptodateHeader>
					<roots>
						<root>${project.basedir}/src/main/java</root>
						<root>${project.basedir}/src/test/java</root>
					</roots>
				</configuration>
				<executions>
					<execution>
						<id>check-file-header</id>
						<phase>validate</phase>
						<goals>
							<goal>check-file-header</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<configuration>
      						<source>8</source>
							<quiet>true</quiet>
							<!-- additionalOptions>-html5</additionalOptions -->
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>release</id>

			<distributionManagement>
				<repository>
					<id>ossrh</id>
					<name>Sonatype deployment repository</name>
					<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
				</repository>
			</distributionManagement>

			<build>
				<pluginManagement>
					<plugins>
						<plugin>
							<groupId>com.spotify</groupId>
							<artifactId>docker-maven-plugin</artifactId>

							<configuration>
								<registryUrl>docker.io</registryUrl>
								<serverId>docker.io</serverId>
							</configuration>
						</plugin>
					</plugins>
				</pluginManagement>

				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>license-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>add-third-party</id>
								<goals>
									<goal>add-third-party</goal>
								</goals>
								<phase>generate-sources</phase>
							</execution>
						</executions>
					</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>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
