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

<!--
 * Copyright (c) 2017 <AT&T>.  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">
  <modelVersion>4.0.0</modelVersion>
  
  <parent>
    <groupId>org.onap.modeling.toscaparsers</groupId>
    <artifactId>checker</artifactId>
    <version>1.2.0-SNAPSHOT</version>
  </parent>
  <artifactId>Service</artifactId>
  <packaging>jar</packaging>
  <name>Checker Service</name>

  <properties>
    <java.version>1.8</java.version>
    <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
		<docker.push.registry>${onap.nexus.dockerregistry.daily}</docker.push.registry>
    <docker.tag.version>${project.version}</docker.tag.version>
    <docker.tag.timestamp>${maven.build.timestamp}</docker.tag.timestamp>
		<skip.docker.build>true</skip.docker.build>
		<skip.docker.tag>true</skip.docker.tag>
		<skip.docker.push>true</skip.docker.push>
  </properties>

	<build>
		<sourceDirectory>src/main/java</sourceDirectory>
		<plugins>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.4.2</version>
				<configuration>
					<environmentVariables>
						<DOCKER_HOST>tcp://127.0.0.1:2375</DOCKER_HOST>
					</environmentVariables>
				</configuration>
			</plugin>

			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>${project.build.sourceEncoding}</encoding>
				</configuration>
			</plugin>

<!--
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.10</version>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/deps</outputDirectory>
							<overWriteReleases>false</overWriteReleases>
							<overWriteSnapshots>false</overWriteSnapshots>
							<overWriteIfNewer>true</overWriteIfNewer>
						</configuration>
					</execution>
				</executions>
			</plugin>
-->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>buildnumber-maven-plugin</artifactId>
				<version>1.4</version>
				<executions>
					<execution>
						<phase>validate</phase>
						<goals>
							<goal>create</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<doCheck>false</doCheck>
					<doUpdate>false</doUpdate>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<archive>
						<manifest>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
						</manifest>
						<manifestEntries>
							<Implementation-Build>${buildNumber}</Implementation-Build>
							<Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
						</manifestEntries>
					</archive>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>2.0.0.RELEASE</version>
				<configuration>
					<mainClass>org.onap.tosca.checker.service.CheckerEngine</mainClass>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>1.0.0</version>
				<configuration>
					<imageName>onap/modeling/javatoscachecker</imageName>
					<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
					<!-- <serverId>docker-daily</serverId> -->
					<!-- <serverId>ecomp-snapshots</serverId> -->
					<serverId>docker-hub</serverId>
          <noCache>true</noCache>
          <imageTags>
            <imageTag>latest</imageTag>
            <imageTag>${docker.tag.version}-${docker.tag.timestamp}</imageTag>
          </imageTags>
          <forceTags>true</forceTags>
					<resources>
						<resource>
							<targetPath>/</targetPath>
							<directory>${project.build.directory}</directory>
							<include>${project.build.finalName}.jar</include>
						</resource>
						<resource>
							<targetPath>/</targetPath>
							<directory>${project.basedir}</directory>
							<include>application.properties</include>
						</resource>
					</resources>
				</configuration>
				<executions>
          <execution>
            <id>build-image</id>
            <phase>package</phase>
            <goals>
              <goal>build</goal>
            </goals>
						<configuration>
							<skipDockerBuild>${skip.docker.build}</skipDockerBuild>
						</configuration>
          </execution>
          <execution>
            <id>tag-image-latest-timestamp</id>
            <phase>package</phase>
            <goals>
              <goal>tag</goal>
            </goals>
            <configuration>
              <image>onap/modeling/javatoscachecker:${docker.tag.version}-${docker.tag.timestamp}</image>
              <newName>${docker.push.registry}/onap/modeling/javatoscachecker:${docker.tag.version}-${docker.tag.timestamp}</newName>
							<skipDockerTag>${skip.docker.tag}</skipDockerTag>
            </configuration>
          </execution>
          <execution>
            <id>push-image-latest-timestamp</id>
            <phase>deploy</phase>
            <goals>
              <goal>push</goal>
            </goals>
            <configuration>
              <imageName>${docker.push.registry}/onap/modeling/javatoscachecker:${docker.tag.version}-${docker.tag.timestamp}</imageName>
							<skipDockerPush>${skip.docker.push}</skipDockerPush>
            </configuration>
          </execution>
          <execution>
            <id>tag-image-latest</id>
            <phase>package</phase>
            <goals>
              <goal>tag</goal>
            </goals>
            <configuration>
              <image>onap/modeling/javatoscachecker:latest</image>
              <newName>${docker.push.registry}/onap/modeling/javatoscachecker:latest</newName>
							<skipDockerTag>${skip.docker.tag}</skipDockerTag>
            </configuration>
          </execution>
          <execution>
            <id>push-image-latest</id>
            <phase>deploy</phase>
            <goals>
              <goal>push</goal>
            </goals>
            <configuration>
              <imageName>${docker.push.registry}/onap/modeling/javatoscachecker:latest</imageName>
							<skipDockerPush>${skip.docker.push}</skipDockerPush>
            </configuration>
          </execution>
        </executions>
			</plugin>
		</plugins>

	</build>
  	
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
		<dependency>
    	<groupId>org.assertj</groupId>
    	<artifactId>assertj-core</artifactId>
			<version>3.8.0</version>
    	<scope>test</scope>
		</dependency>
		<dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-test</artifactId>
    	<version>2.0.0.RELEASE</version>
    	<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>[2.7.8,)</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>[4.3.4.RELEASE,)</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>[4.3.4.RELEASE,)</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<version>2.0.0.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>[4.3.4.RELEASE,)</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-autoconfigure</artifactId>
			<version>[1.3.3.RELEASE,)</version>
		</dependency>
		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20160212</version>
		</dependency>
	 	  
		<dependency>
	   	<groupId>org.onap.modeling.toscaparsers</groupId>
 		  <artifactId>Checker</artifactId>
 	  	<version>1.2.0-SNAPSHOT</version>
 		</dependency>
 	</dependencies>
	
  <profiles>
    <profile>
      <id>docker</id>
      <properties>
        <skip.docker.build>false</skip.docker.build>
        <skip.docker.tag>false</skip.docker.tag>
        <skip.docker.push>false</skip.docker.push>
      </properties>
    </profile>
  </profiles>

</project>