<?xml version="1.0"?>
<!--
    Copyright (c) 2018 Intel Corporation. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License"); you may
    not use this file except in compliance with the License. You may obtain
    a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 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
http://maven.apache.org/POM/4.0.0 ">
	<modelVersion>4.0.0</modelVersion>
	<packaging>pom</packaging>

	<parent>
		<groupId>org.onap.oparent</groupId>
		<artifactId>oparent-python</artifactId>
		<version>3.0.0</version>
	</parent>

	<groupId>org.onap.optf.osdf</groupId>
	<artifactId>optf-osdf</artifactId>
	<name>optf-osdf</name>
	<version>3.0.5-SNAPSHOT</version>
	<description>Optimization Service Design Framework</description>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<sonar.sources>.</sonar.sources>
		<sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath>
		<sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths>
		<sonar.language>py</sonar.language>
		<sonar.pluginname>python</sonar.pluginname>
		<sonar.inclusions>**/**.py,osdfapp.py</sonar.inclusions>
		<sonar.exclusions>test/**.py,docs/**.py</sonar.exclusions>
		<maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
		<osdf.build.timestamp>${maven.build.timestamp}</osdf.build.timestamp>
		<osdf.project.version>${project.version}</osdf.project.version>
		<osdf.docker.repository>nexus3.onap.org:10003</osdf.docker.repository>
		<osdf.base.image>osdf-base</osdf.base.image>
		<image.namespace>${osdf.docker.repository}/onap/optf-osdf</image.namespace>
		<opteng.namespace>${osdf.docker.repository}/onap/optf-opteng</opteng.namespace>
	</properties>

	<build>
		<plugins>
			<!-- triggers tox test for sonar -->
			<plugin>
				<artifactId>exec-maven-plugin</artifactId>
				<groupId>org.codehaus.mojo</groupId>
			</plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<appendAssemblyId>false</appendAssemblyId>
					<descriptors>
						<descriptor>assembly.xml</descriptor>
					</descriptors>
				</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-release-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-deploy-plugin</artifactId>
				<version>2.8</version>
				<configuration>
					<retryFailedDeploymentCount>2</retryFailedDeploymentCount>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.groovy.maven</groupId>
				<artifactId>gmaven-plugin</artifactId>
				<version>1.0</version>
				<executions>
					<execution>
						<phase>validate</phase>
						<goals>
							<goal>execute</goal>
						</goals>
						<configuration>
							<source>${project.basedir}/script/TagVersion.groovy</source>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>io.fabric8</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.26.0</version>
				<configuration>
					<verbose>true</verbose>
					<apiVersion>1.23</apiVersion>
					<images>
						<image>
							<name>${osdf.base.image}</name>
							<alias>optf-base</alias>
							<build>
								<cleanup>true</cleanup>
								<tags>
									<tag>latest</tag>
								</tags>

								<dockerFile>${project.basedir}/docker/osdf-lib-base/Dockerfile</dockerFile>
								<assembly>
									<descriptor>${project.basedir}/docker/osdf-lib-base/assembly/osdf-lib-files.xml</descriptor>
									<name>onap-osdf-tm</name>
								</assembly>
								<args>
									<MVN_ARTIFACT_VERSION>${project.version}</MVN_ARTIFACT_VERSION>
									<REPO>${project.repo}</REPO>
								</args>
							</build>
						</image>
						<image>
							<name>${image.namespace}</name>
							<alias>optf-osdf</alias>
							<build>
								<cleanup>true</cleanup>
								<tags>
									<tag>latest</tag>
									<tag>${project.docker.latesttagtimestamp.version}</tag>
									<tag>${project.docker.latesttag.version}</tag>
								</tags>

								<dockerFile>${project.basedir}/docker/osdf/Dockerfile</dockerFile>
								<assembly>
									<descriptor>${project.basedir}/docker/osdf/assembly/osdf-files.xml</descriptor>
									<name>onap-osdf-tm</name>
								</assembly>
								<args>
									<MVN_ARTIFACT_VERSION>${project.version}</MVN_ARTIFACT_VERSION>
									<REPO>${project.repo}</REPO>

									<!-- plugin cannot handle empty (no proxy) arguments
									<http_proxy_arg>${docker.http_proxy}</http_proxy_arg>
									<https_proxy_arg>${docker.https_proxy}</https_proxy_arg>
									-->
								</args>
							</build>
						</image>
						<image>
							<name>${opteng.namespace}</name>
							<alias>optf-opteng</alias>
							<build>
								<cleanup>true</cleanup>
								<tags>
									<tag>latest</tag>
									<tag>${project.docker.latesttagtimestamp.version}</tag>
									<tag>${project.docker.latesttag.version}</tag>
								</tags>

								<dockerFile>${project.basedir}/docker/opteng/Dockerfile</dockerFile>
								<assembly>
									<descriptor>${project.basedir}/docker/opteng/assembly/osdf-files.xml</descriptor>
									<name>onap-osdf-tm</name>
								</assembly>
								<args>
									<MVN_ARTIFACT_VERSION>${project.version}</MVN_ARTIFACT_VERSION>
									<REPO>${project.repo}</REPO>

									<!-- plugin cannot handle empty (no proxy) arguments
                                    <http_proxy_arg>${docker.http_proxy}</http_proxy_arg>
                                    <https_proxy_arg>${docker.https_proxy}</https_proxy_arg>
                                    -->
								</args>
							</build>
						</image>
					</images>
				</configuration>
				<executions>
					<execution>
						<id>generate-images</id>
						<phase>install</phase>
						<goals>
							<goal>build</goal>
						</goals>
					</execution>
					<execution>
						<id>push-images</id>
						<phase>deploy</phase>
						<goals>
							<goal>build</goal>
							<goal>push</goal>
						</goals>
						<configuration>
							<image>${image.namespace}:%l</image>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>