<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>it.maggioli.suite</groupId>
		<artifactId>CTL-web</artifactId>
		<version>1.0.14.0000</version>
		<relativePath>../</relativePath>
	</parent>
	<groupId>it.maggioli.suite</groupId>
	<artifactId>ctl-ng</artifactId>
	<packaging>pom</packaging>
	<!-- evita di creare il file jar -->
	<profiles>
		<profile>
			<id>jenkins-release</id>
			<activation>
				<file>
					<exists>/home/jenkins/.m2/settings.xml</exists>
				</file>
				<property>
					<name>release</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>com.github.eirslett</groupId>
						<artifactId>frontend-maven-plugin</artifactId>
						<version>1.6</version>
						<!-- ${frontend-maven-plugin.version} -->
						<configuration>
							<installDirectory>${build.ng.config.directory.install}</installDirectory>
							<!-- definito in settings.xml -->
						</configuration>
						<executions>
							<execution>
								<id>yarn release jenkins</id>
								<goals>
									<goal>yarn</goal>
								</goals>
								<configuration>
									<!-- eseguire solo da jenkins -->
									<arguments>_jenkins</arguments>
								</configuration>
							</execution>
							<execution>
								<id>yarn release nexus</id>	
								<goals>
									<goal>yarn</goal>
								</goals>
								<configuration>
									<!-- eseguire solo da jenkins -->
									<arguments>_nexus</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<build>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>3.0.0</version>
				<executions>
					<execution>
						<id>properties-to-lowercase</id>
						<goals>
							<goal>regex-property</goal>
						</goals>
						<configuration>
							<name>appPrefixLower</name>
							<regex>.*</regex>
							<value>${appPrefix}</value>
							<replacement>$0</replacement>
							<failIfNoMatch>false</failIfNoMatch>
							<toLowerCase>true</toLowerCase>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<version>1.0.0</version>
				<executions>
					<execution>
						<id>setting properties</id>	
						<phase>generate-resources</phase>
						<goals>
							<goal>set-system-properties</goal>
						</goals>
						<configuration>
							<properties>
								<property>
									<name>it.maggioli.suite.configuration.version</name>
									<value>${it.maggioli.suite.configuration.version}</value>
								</property>
								<property>
									<name>it.maggioli.suite.vendor.version</name>
									<value>${it.maggioli.suite.vendor.version}</value>
								</property>
								<property>
									<name>it.maggioli.suite.common.version</name>
									<value>${it.maggioli.suite.common.version}</value>
								</property>
							</properties>
						</configuration>
					</execution>				
					<execution>
						<id>generating env.properties</id>	
						<phase>generate-resources</phase>
						<goals>
							<goal>write-project-properties</goal>
						</goals>
						<configuration>
							<outputFile>
								${project.build.directory}/env.properties
							</outputFile>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<!-- questo plugin e' necessario per normalizzare i path in windows creati nel file env.properties -->
				<groupId>com.google.code.maven-replacer-plugin</groupId>
				<artifactId>replacer</artifactId>
				<version>1.5.2</version>
				<executions>
					<execution>
						<id>replacing invalid chars in env.properties</id>	
						<phase>generate-resources</phase>
						<goals>
							<goal>replace</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<file>${project.build.directory}/env.properties</file>
					<replacements>
						<replacement>
							<token>\\:</token>
							<value>:</value>
						</replacement>
					</replacements>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.github.eirslett</groupId>
				<artifactId>frontend-maven-plugin</artifactId>
				<version>1.6</version>
				<!-- ${frontend-maven-plugin.version} -->
				<configuration>
					<installDirectory>${build.ng.config.directory.install}</installDirectory>
					<!-- definito in settings.xml -->
				</configuration>
				<executions>
					<execution>
						<id>install node ${build.ng.config.node.version} and yarn ${build.ng.config.yarn.version}</id>
						<goals>
							<goal>install-node-and-yarn</goal>
						</goals>
						<configuration>
							<nodeVersion>${build.ng.config.node.version}</nodeVersion>
							<!-- definito in produzione-web -->
							<yarnVersion>${build.ng.config.yarn.version}</yarnVersion>
							<!-- definito in produzione-web -->
						</configuration>
					</execution>
					<execution>
						<id>yarn install</id>
						<goals>
							<goal>yarn</goal>
						</goals>
						<configuration>
							<arguments>_install --cache-folder ${build.ng.config.directory.cache}</arguments>
							<!-- definito nel settings.xml -->
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>