<?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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>de.dfki.cos.basys</groupId>
		<artifactId>pom</artifactId>
		<version>0.5.0</version>
<!--		<relativePath>..</relativePath>-->
	</parent>

	<groupId>de.dfki.cos.basys.pom</groupId>
	<artifactId>starter-parent</artifactId>
	<packaging>pom</packaging>

	<name>BaSys Starter POM</name>
	<description>This is the Starter POM for individual Java modules</description>

	<properties>
		<docker.maven.plugin.version>0.40.1</docker.maven.plugin.version>
		<docker.image.name>${project.artifactId}</docker.image.name>
		<docker.image.version>${project.version}</docker.image.version>
		<docker.pull.registry>docker.io</docker.pull.registry>
		<docker.target.platforms>linux/amd64,linux/arm64</docker.target.platforms>

		<!-- dependency versions -->

		<avro.version>1.11.0</avro.version>
		<basyx.version>[1.0.0,2.0.0)</basyx.version>
		<basys-aasregistry.version>0.4.2-SNAPSHOT</basys-aasregistry.version>
		<camunda-platform.version>7.19.0</camunda-platform.version>
		<camunda-community.version>7.19.0</camunda-community.version>
		<commons-cli.version>1.4</commons-cli.version>
		<commons-io.version>2.8.0</commons-io.version>
		<commons-jexl3.version>3.1</commons-jexl3.version>
		<guava.version>30.1-jre</guava.version>
		<jaxrs.version>2.1.1</jaxrs.version>
		<kafka-avro-serializer.version>6.2.2</kafka-avro-serializer.version>
		<milo.version>0.6.3</milo.version>
		<paho.version>1.2.5</paho.version>
		<spring-cloud.version>2020.0.4</spring-cloud.version>
		<testcontainers.version>1.17.3</testcontainers.version>
	</properties>

	<repositories>
		<repository>
			<id>confluent</id>
			<name>Confluent</name>
			<url>https://packages.confluent.io/maven/</url>
		</repository>
	</repositories>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-logging</artifactId>
		</dependency>

		<!-- https://mvnrepository.com/artifact/junit/junit/4.12 -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.google.guava</groupId>
				<artifactId>guava</artifactId>
				<version>${guava.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.commons</groupId>
				<artifactId>commons-jexl3</artifactId>
				<version>${commons-jexl3.version}</version>
			</dependency>
			<dependency>
				<groupId>javax.ws.rs</groupId>
				<artifactId>javax.ws.rs-api</artifactId>
				<version>${jaxrs.version}</version>
			</dependency>
			<dependency>
				<groupId>org.eclipse.paho</groupId>
				<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
				<version>${paho.version}</version>
			</dependency>
			<dependency>
				<groupId>commons-cli</groupId>
				<artifactId>commons-cli</artifactId>
				<version>${commons-cli.version}</version>
			</dependency>
			<dependency>
				<groupId>commons-io</groupId>
				<artifactId>commons-io</artifactId>
				<version>${commons-io.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.avro</groupId>
				<artifactId>avro</artifactId>
				<version>${avro.version}</version>
			</dependency>
			<dependency>
				<groupId>io.confluent</groupId>
				<artifactId>kafka-avro-serializer</artifactId>
				<version>${kafka-avro-serializer.version}</version>
			</dependency>

			<dependency>
				<groupId>org.camunda.community</groupId>
				<artifactId>camunda-engine-rest-client-openapi-java</artifactId>
				<version>${camunda-community.version}</version>
			</dependency>
			<!--			<dependency>-->
			<!--				<groupId>org.springframework.cloud</groupId>-->
			<!--				<artifactId>spring-cloud-dependencies</artifactId>-->
			<!--				<version>${spring-cloud.version}</version>-->
			<!--				<type>pom</type>-->
			<!--				<scope>import</scope>-->
			<!--			</dependency>-->

			<dependency>
				<groupId>org.testcontainers</groupId>
				<artifactId>testcontainers</artifactId>
				<version>${testcontainers.version}</version>
			</dependency>
			<dependency>
				<groupId>org.testcontainers</groupId>
				<artifactId>kafka</artifactId>
				<version>${testcontainers.version}</version>
			</dependency>
			<dependency>
				<groupId>org.eclipse.milo</groupId>
				<artifactId>sdk-client</artifactId>
				<version>${milo.version}</version>
			</dependency>
			<dependency>
				<groupId>org.eclipse.milo</groupId>
				<artifactId>sdk-server</artifactId>
				<version>${milo.version}</version>
			</dependency>
			<dependency>
				<groupId>org.eclipse.milo</groupId>
				<artifactId>dictionary-manager</artifactId>
				<version>${milo.version}</version>
			</dependency>
			<dependency>
				<groupId>org.eclipse.basyx</groupId>
				<artifactId>basyx.sdk</artifactId>
				<version>${basyx.version}</version>
				<exclusions>
					<exclusion>
						<groupId>org.apache.tomcat</groupId>
						<artifactId>tomcat-catalina</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.eclipse.milo</groupId>
						<artifactId>sdk-client</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.eclipse.milo</groupId>
						<artifactId>sdk-server</artifactId>
					</exclusion>
					<exclusion>
						<groupId>ch.qos.logback</groupId>
						<artifactId>logback-classic</artifactId>
					</exclusion>
				</exclusions>
			</dependency>
			<dependency>
				<groupId>de.dfki.cos.basys.aas.registry</groupId>
				<artifactId>aas-registry-compatibility</artifactId>
				<version>${basys-aasregistry.version}</version>
			</dependency>
			<dependency>
				<groupId>de.dfki.cos.basys.aas.registry</groupId>
				<artifactId>aas-registry-client</artifactId>
				<version>${basys-aasregistry.version}</version>
			</dependency>
			<dependency>
				<groupId>de.dfki.cos.basys.aas.registry</groupId>
				<artifactId>aas-registry-paths</artifactId>
				<version>${basys-aasregistry.version}</version>
			</dependency>
			<dependency>
				<groupId>de.dfki.cos.basys.aas.registry</groupId>
				<artifactId>aas-registry-events</artifactId>
				<version>${basys-aasregistry.version}</version>
			</dependency>


		</dependencies>
	</dependencyManagement>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>io.fabric8</groupId>
					<artifactId>docker-maven-plugin</artifactId>
					<version>${docker.maven.plugin.version}</version>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
	<profiles>
		<profile>
			<id>bundlebuild</id>
			<activation>
				<file>
					<exists>osgi.bnd</exists>
				</file>
			</activation>
			<build>
				<pluginManagement>
					<plugins>
						<plugin>
							<groupId>org.ops4j</groupId>
							<artifactId>maven-pax-plugin</artifactId>
							<!-- | enable improved OSGi compilation support for the bundle life-cycle.
										   | to switch back to the standard bundle life-cycle, move this setting
										   | down to the maven-bundle-plugin section -->
							<extensions>true</extensions>
						</plugin>
						<plugin>
							<groupId>org.apache.felix</groupId>
							<artifactId>maven-bundle-plugin</artifactId>
							<version>${maven-bundle-plugin.version}</version>
							<extensions>true</extensions>
							<executions>
								<!-- Configure extra execution of 'manifest' in process-classes phase to make sure SCR metadata is generated before unit test runs -->
								<execution>
									<id>scr-metadata</id>
									<goals>
										<goal>manifest</goal>
									</goals>
									<configuration>
										<supportIncrementalBuild>true</supportIncrementalBuild>
									</configuration>
								</execution>
							</executions>
							<configuration>
								<manifestLocation>META-INF</manifestLocation>
								<archive>
									<addMavenDescriptor>false</addMavenDescriptor>
								</archive>
								<instructions>
									<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
									<Bundle-Version>${project.version}</Bundle-Version>
									<!--
									 | assume public classes are in the top package, and private classes are under ".internal"
									-->
									<!--
									<Export-Package>!${bundle.namespace}.internal.*,!*.impl,${bundle.namespace}.*;version="${project.version}"</Export-Package>
									<Private-Package>${bundle.namespace}.internal.*,*.impl</Private-Package>
									-->
									<!--
									 | each module can override these defaults in their osgi.bnd file
									-->
									<!--
									<Import-Package>!*.impl,*</Import-Package>
									-->
									<Export-Package>!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${project.version}"</Export-Package>
									<_include>-osgi.bnd</_include>
									<!-- Enable processing of OSGI DS component annotations -->
									<_dsannotations>*</_dsannotations>
									<!-- Enable processing of OSGI metatype annotations -->
									<_metatypeannotations>*</_metatypeannotations>
									<_removeheaders>Bnd-LastModified, Built-By, Build-Jdk, Require-Capability</_removeheaders>
									<!-- Support parsing of maven-scr-plugin annotations through the felix.scr.bnd plugin -->
									<!--
									<_plugin>org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=${project.build.outputDirectory};</_plugin>
									-->
								</instructions>
							</configuration>
						</plugin>
					</plugins>
				</pluginManagement>

				<plugins>
					<plugin>
						<groupId>org.apache.felix</groupId>
						<artifactId>maven-bundle-plugin</artifactId>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>dockerbuild</id>
			<activation>
				<!-- This profile is always active if there is a Dockerfile and a user 
					name is given -->
				<file>
					<exists>src/main/docker/Dockerfile</exists>
				</file>
				<property>
					<name>docker.username</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-deploy-plugin</artifactId>
						<configuration>
							<skip>true</skip>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.springframework.boot</groupId>
						<artifactId>spring-boot-maven-plugin</artifactId>
						<configuration>
							<layers>
								<enabled>true</enabled>
								<includeLayerTools>true</includeLayerTools>
							</layers>
							<excludes>
								<exclude>
									<groupId>org.projectlombok</groupId>
									<artifactId>lombok</artifactId>
								</exclude>
							</excludes>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>repackage</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>io.fabric8</groupId>
						<artifactId>docker-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>build-docker</id>
								<phase>package</phase>
								<goals>
									<goal>build</goal>
								</goals>
								<configuration>
									<images>
										<image>
											<name>${docker.username}/${docker.image.name}</name>
											<build>
												<assembly>
													<descriptorRef>artifact</descriptorRef>
												</assembly>
												<tags>
													<tag>${docker.image.version}</tag>
												</tags>
												<dockerFile>Dockerfile</dockerFile>
												<contextDir>${project.basedir}/src/main/docker</contextDir>
												<!-- building non buildx image here to speed up build -->
											</build>
										</image>
									</images>
								</configuration>
							</execution>
							<execution>
								<id>push-docker</id>
								<phase>deploy</phase>
								<goals>
									<goal>build</goal>
									<goal>push</goal>
								</goals>
								<configuration>
									<images>
										<image>
											<name>${docker.username}/${docker.image.name}</name>
											<!-- needs to be set to this registry https://github.com/fabric8io/docker-maven-plugin/pull/1578 -->
											<registry>https://index.docker.io/v1/</registry>
											<build>
												<assembly>
													<descriptorRef>artifact</descriptorRef>
												</assembly>
												<tags>
													<tag>${docker.image.version}</tag>
												</tags>
												<dockerFile>Dockerfile</dockerFile>
												<contextDir>${project.basedir}/src/main/docker</contextDir>
												<buildx>
													<platforms>${docker.target.platforms}</platforms>
												</buildx>
											</build>
										</image>
									</images>
								</configuration>
							</execution>
						</executions>
						
						
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
