<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>com.talend.ai.test</groupId>
	<artifactId>mavenjavafirst</artifactId>
	<version>0.0.1</version>
	<packaging>war</packaging>

	<name>Maven CXF Java First Template</name>
	<description>Generate web services using java first approach in Maven</description>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

		<cxf.version>2.5.0</cxf.version>
		<slf4j-version>1.6.1</slf4j-version>
		<log4j-version>1.2.16</log4j-version>

		<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
		<exec-maven-plugin.version>1.2.1</exec-maven-plugin.version>
		<jetty.version>8.0.4.v20111024</jetty.version>
		<tomcat-maven-plugin.version>1.1</tomcat-maven-plugin.version>

		<cxf.eclipse.generated.sources>target/generated-sources</cxf.eclipse.generated.sources>
		<cxf.eclipse.generated.resources>target/generated-resources</cxf.eclipse.generated.resources>

	</properties>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.mortbay.jetty</groupId>
					<artifactId>jetty-maven-plugin</artifactId>
					<version>${jetty.version}</version>
				</plugin>
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>exec-maven-plugin</artifactId>
					<version>${exec-maven-plugin.version}</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-war-plugin</artifactId>
					<version>2.1.1</version>
				</plugin>
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>properties-maven-plugin</artifactId>
					<version>1.0-alpha-2</version>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>commonProjectProperties</id>
						<phase>initialize</phase>
						<goals>
							<goal>read-project-properties</goal>
						</goals>
						<configuration>
							<files>
								<file>${project.artifactId}.build.properties</file>
								<file>src/main/resources/${project.artifactId}.properties</file>
							</files>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<id>echoProcessSourcesProperties</id>
						<goals>
							<goal>run</goal>
						</goals>
						<phase>process-sources</phase>
						<inherited>false</inherited>
						<configuration>
							<tasks>
								<echo>***** PROCESS-SOURCES PHASE ***** </echo>
								<echo>***** container: ${container} *****</echo>
								<echo>***** contextPath: ${contextPath} *****</echo>
							</tasks>
						</configuration>
					</execution>
					<execution>
						<id>echoTestProperties</id>
						<goals>
							<goal>run</goal>
						</goals>
						<phase>test</phase>
						<inherited>false</inherited>
						<configuration>
							<tasks>
								<echo>***** TEST PHASE ***** </echo>
								<echo>***** container: ${container} *****</echo>
								<echo>***** contextPath: ${contextPath} *****</echo>
							</tasks>
						</configuration>
					</execution>
					<execution>
						<id>echoPackageProperties</id>
						<goals>
							<goal>run</goal>
						</goals>
						<phase>package</phase>
						<inherited>false</inherited>
						<configuration>
							<tasks>
								<echo>***** PACKAGE PHASE ***** </echo>
								<echo>***** container: ${container} *****</echo>
								<echo>***** contextPath: ${contextPath} *****</echo>
							</tasks>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven-compiler-plugin.version}</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>add-generated-sources</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>${cxf.eclipse.generated.sources}</source>
							</sources>
						</configuration>
					</execution>
					<execution>
						<id>add-generated-resources</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>add-resource</goal>
						</goals>
						<configuration>
							<resources>
								<resource>
									<directory>${cxf.eclipse.generated.resources}</directory>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-java2ws-plugin</artifactId>
				<version>${cxf.version}</version>
				<dependencies>
					<dependency>
						<groupId>org.apache.cxf</groupId>
						<artifactId>cxf-rt-frontend-jaxws</artifactId>
						<version>${cxf.version}</version>
					</dependency>
					<dependency>
						<groupId>org.apache.cxf</groupId>
						<artifactId>cxf-rt-transports-http</artifactId>
						<version>${cxf.version}</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>process-HelloWorld</id>
						<phase>process-classes</phase>
						<goals>
							<goal>java2ws</goal>
						</goals>
						<configuration>
							<className>com.talend.ai.demo.HelloWorld</className>
							<outputFile>${basedir}/${cxf.eclipse.generated.resources}/wsdl/HelloWorld.wsdl</outputFile>
							<frontend>jaxws</frontend>
							<genWsdl>true</genWsdl>
							<genWrapperbean>true</genWrapperbean>
							<genClient>false</genClient>
							<genServer>false</genServer>
							<verbose>true</verbose>
							<version>true</version>
							<!-- argline>-s ${basedir}/${cxf.eclipse.generated.sources} </argline -->
							<argline>-createxsdimports -s ${basedir}/${cxf.eclipse.generated.sources}</argline>
						</configuration>
					</execution>
					<execution>
						<id>process-CustomersRepo</id>
						<phase>process-classes</phase>
						<goals>
							<goal>java2ws</goal>
						</goals>
						<configuration>
							<className>com.talend.ai.demo.CustomerRepo</className>
							<outputFile>${basedir}/${cxf.eclipse.generated.resources}/wsdl/customers.wsdl</outputFile>
							<frontend>jaxws</frontend>
							<genWsdl>true</genWsdl>
							<genWrapperbean>true</genWrapperbean>
							<genClient>false</genClient>
							<genServer>false</genServer>
							<verbose>true</verbose>
							<version>true</version>
							<!-- argline>-s ${basedir}/${cxf.eclipse.generated.sources} </argline -->
							<argline>-createxsdimports -s ${basedir}/${cxf.eclipse.generated.sources}</argline>
						</configuration>
					</execution>
					<execution>
						<id>process-OrdersRepo</id>
						<phase>process-classes</phase>
						<goals>
							<goal>java2ws</goal>
						</goals>
						<configuration>
							<className>com.talend.ai.demo.OrderRepo</className>
							<outputFile>${basedir}/${cxf.eclipse.generated.resources}/wsdl/orders.wsdl</outputFile>
							<frontend>jaxws</frontend>
							<genWsdl>true</genWsdl>
							<genWrapperbean>true</genWrapperbean>
							<genClient>false</genClient>
							<genServer>false</genServer>
							<verbose>true</verbose>
							<version>true</version>
							<argline>-s ${basedir}/${cxf.eclipse.generated.sources} </argline>
							<!-- argline>-createxsdimports -s ${basedir}/${cxf.eclipse.generated.sources}</argline -->
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-frontend-jaxws</artifactId>
				<version>${cxf.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-transports-http</artifactId>
				<version>${cxf.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.cxf</groupId>
				<artifactId>cxf-rt-transports-http-jetty</artifactId>
				<version>${cxf.version}</version>
			</dependency>
			<dependency>
				<groupId>log4j</groupId>
				<artifactId>log4j</artifactId>
				<version>${log4j-version}</version>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-api</artifactId>
				<version>${slf4j-version}</version>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-log4j12</artifactId>
				<version>${slf4j-version}</version>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>jvm</id>
			<properties>
				<container>jvmContainer</container>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>properties-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>jvmContainerProperties</id>
								<phase>initialize</phase>
								<goals>
									<goal>read-project-properties</goal>
								</goals>
								<configuration>
									<files>
										<file>src/main/resources/jvmContainer.properties</file>
									</files>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<dependencies>
				<dependency>
					<groupId>org.apache.cxf</groupId>
					<artifactId>cxf-rt-transports-http-jetty</artifactId>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>spring</id>
			<properties>
				<container>springContainer</container>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>properties-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>springContainerProperties</id>
								<phase>initialize</phase>
								<goals>
									<goal>read-project-properties</goal>
								</goals>
								<configuration>
									<files>
										<file>src/main/resources/springContainer.properties</file>
									</files>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<dependencies>
				<dependency>
					<groupId>org.apache.cxf</groupId>
					<artifactId>cxf-rt-transports-http-jetty</artifactId>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>war</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-war-plugin</artifactId>
						<configuration>
							<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
							<webResources>
								<resource>
									<directory>${basedir}/src/main/resources</directory>
									<targetPath>WEB-INF</targetPath>
									<includes>
										<include>**/*.xml</include>
										<include>**/*.properties</include>
									</includes>
								</resource>
								<resource>
									<directory>${basedir}/src/main/resources/META-INF</directory>
									<targetPath>WEB-INF/META-INF</targetPath>
									<includes>
										<include>**/*.xml</include>
										<include>**/*.properties</include>
									</includes>
								</resource>
							</webResources>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>jetty</id>
			<properties>
				<container>jettyContainer</container>
				<server.id>jetty.local</server.id>
				<server.host>localhost</server.host>
				<server.url>http://${server.host}:${jetty.port}</server.url>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>properties-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>jettyContainerProperties</id>
								<phase>initialize</phase>
								<goals>
									<goal>read-project-properties</goal>
								</goals>
								<configuration>
									<files>
										<file>src/main/resources/jettyContainer.properties</file>
									</files>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<dependencies>
				<dependency>
					<groupId>org.apache.cxf</groupId>
					<artifactId>cxf-rt-transports-http-jetty</artifactId>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>jetty-server</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>echoJettyPackageProperties</id>
								<goals>
									<goal>run</goal>
								</goals>
								<phase>package</phase>
								<inherited>false</inherited>
								<configuration>
									<tasks>
										<echo>##### PACKAGE PHASE #####</echo>
										<echo>##### container: ${container} #####</echo>
										<echo>##### port: ${port} #####</echo>
										<echo>##### contextPath: ${contextPath} #####</echo>
										<echo>##### mySystemProperty: ${mySystemProperty} #####</echo>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.mortbay.jetty</groupId>
						<artifactId>jetty-maven-plugin</artifactId>
						<configuration>
							<webAppConfig>
								<!-- contextPath does not seem to resolve maven property -->
								<!-- contextPath>/${contextPath}</contextPath -->
								<contextPath>/mavenjavafirst</contextPath>
							</webAppConfig>
							<systemProperties>
								<!-- does not seem to want to substitute maven properties -->
								<systemProperty>
									<key>jetty.port</key>
									<value>${port}</value>
								</systemProperty>
								<systemProperty>
									<key>container</key>
									<value>${container}</value>
								</systemProperty>
								<systemProperty>
									<key>mySystemProperty</key>
									<value>mySystemProperty${port}</value>
								</systemProperty>
								<!-- systemProperty>
									<key>com.sun.management.jmxremote</key>
									<value></value>
								</systemProperty -->
							</systemProperties>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>tomcat</id>
			<properties>
				<container>tomcatContainer</container>
				<server.id>tomcat.local</server.id>
				<server.host>localhost</server.host>
				<server.url>http://${server.host}:${port}</server.url>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>properties-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>tomcatContainerProperties</id>
								<phase>initialize</phase>
								<goals>
									<goal>read-project-properties</goal>
								</goals>
								<configuration>
									<files>
										<file>src/main/resources/tomcatContainer.properties</file>
									</files>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>tomcat-server</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>echoTomcatPackageProperties</id>
								<goals>
									<goal>run</goal>
								</goals>
								<phase>package</phase>
								<inherited>false</inherited>
								<configuration>
									<tasks>
										<echo>##### PACKAGE PHASE #####</echo>
										<echo>##### container: ${container} #####</echo>
										<echo>##### port: ${port} #####</echo>
										<echo>##### contextPath: ${contextPath} #####</echo>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.tomcat.maven</groupId>
						<artifactId>tomcat6-maven-plugin</artifactId>
						<version>${tomcat-maven-plugin.version}</version>
						<configuration>
							<port>${port}</port>
							<path>/${contextPath}</path>
							<server>${server.id}</server>
							<url>${server.url}/manager/html</url>
							<systemProperties>
								<container>${container}</container>
							</systemProperties>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>spring-server</id>
			<build>
				<defaultGoal>test</defaultGoal>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>echoSpringPackageProperties</id>
								<goals>
									<goal>run</goal>
								</goals>
								<phase>package</phase>
								<inherited>false</inherited>
								<configuration>
									<tasks>
										<echo>##### PACKAGE PHASE #####</echo>
										<echo>##### container: ${container} #####</echo>
										<echo>##### port: ${port} #####</echo>
										<echo>##### contextPath: ${contextPath} #####</echo>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<phase>test</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>com.talend.ai.demo.SpringServer</mainClass>
									<!-- in order to pass system properties to the jvm, they have to 
										be passed on the command line arguments -->
									<systemProperties>
										<systemProperty>
											<key>container</key>
											<value>${container}</value>
										</systemProperty>
									</systemProperties>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>spring-client</id>
			<build>
				<defaultGoal>test</defaultGoal>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<phase>test</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>com.talend.ai.demo.SpringClient</mainClass>
									<systemProperties>
										<systemProperty>
											<key>container</key>
											<value>${container}</value>
										</systemProperty>
									</systemProperties>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>jvm-server</id>
			<build>
				<defaultGoal>test</defaultGoal>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>echoJvmPackageProperties</id>
								<goals>
									<goal>run</goal>
								</goals>
								<phase>package</phase>
								<inherited>false</inherited>
								<configuration>
									<tasks>
										<echo>##### PACKAGE PHASE #####</echo>
										<echo>##### container: ${container} #####</echo>
										<echo>##### port: ${port} #####</echo>
										<echo>##### contextPath: ${contextPath} #####</echo>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<phase>test</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>${serverMain}</mainClass>
									<arguments>
										<argument>${wsdlPath}</argument>
										<argument>${port}</argument>
										<argument>/${contextPath}</argument>
										<argument>${urlPath}</argument>
										<argument>${serviceNS}</argument>
										<argument>${serviceLocal}</argument>
										<argument>${portNS}</argument>
										<argument>${portLocal}</argument>
									</arguments>
									<systemProperties>
										<systemProperty>
											<key>container</key>
											<value>${container}</value>
										</systemProperty>
									</systemProperties>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>jvm-client</id>
			<build>
				<defaultGoal>test</defaultGoal>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<phase>test</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>${clientMain}</mainClass>
									<arguments>
										<argument>${wsdlPath}</argument>
										<argument>${port}</argument>
										<argument>/${contextPath}</argument>
										<argument>${urlPath}</argument>
										<argument>${serviceNS}</argument>
										<argument>${serviceLocal}</argument>
										<argument>${portNS}</argument>
										<argument>${portLocal}</argument>
									</arguments>
									<systemProperties>
										<systemProperty>
											<key>container</key>
											<value>${container}</value>
										</systemProperty>
									</systemProperties>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>helloWorld</id>
			<properties>
				<clientMain>com.talend.ai.demo.HelloWorldMyClient</clientMain>
				<serverMain>com.talend.ai.demo.HelloWorldMyServer</serverMain>
				<wsdlPath>file:/Users/EdwardOst/workspace/jee/mavenjavafirst/target/generated-resources/wsdl/HelloWorld.wsdl</wsdlPath>
				<urlPath>helloWorld</urlPath>
				<serviceNS>http://demo.ai.talend.com/</serviceNS>
				<serviceLocal>HelloWorldService</serviceLocal>
				<portNS>http://demo.ai.talend.com/</portNS>
				<portLocal>helloWorldEndpoint</portLocal>
			</properties>
		</profile>

		<profile>
			<id>customer</id>
			<properties>
				<clientMain>com.talend.ai.demo.CustomerRepoMyClient</clientMain>
				<serverMain>com.talend.ai.demo.CustomerRepoMyServer</serverMain>
				<wsdlPath>file:/Users/EdwardOst/workspace/jee/mavenjavafirst/target/generated-resources/wsdl/customers.wsdl</wsdlPath>
				<urlPath>customerRepo</urlPath>
				<serviceNS>http://demo.ai.talend.com/</serviceNS>
				<serviceLocal>CustomerRepoService</serviceLocal>
				<portNS>http://demo.ai.talend.com/</portNS>
				<portLocal>CustomerRepo</portLocal>
			</properties>
		</profile>

		<profile>
			<id>order</id>
			<properties>
				<clientMain>com.talend.ai.demo.OrderRepoMyClient</clientMain>
				<serverMain>com.talend.ai.demo.OrderRepoMyServer</serverMain>
				<wsdlPath>file:/Users/EdwardOst/workspace/jee/mavenjavafirst/target/generated-resources/wsdl/orders.wsdl</wsdlPath>
				<urlPath>orders</urlPath>
				<serviceNS>http://demo.ai.talend.com/</serviceNS>
				<serviceLocal>OrderRepoService</serviceLocal>
				<portNS>http://demo.ai.talend.com/</portNS>
				<portLocal>OrderRepo</portLocal>
			</properties>
		</profile>
	</profiles>


</project>