test compilation of RAP examples against a local target platform

This is a second maven build that is meant to be run after the main
maven build with RAP profile.  It will try to compile our RAP examples
using a target platform pointing to the repository we built on the first
maven build.

Change-Id: I96d7548e7decce080be3994744daa3356eb94642
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/pom.xml b/examples/org.eclipse.emf.parsley.examples.rap.model/pom.xml
new file mode 100644
index 0000000..571a73f
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<relativePath>../../releng/org.eclipse.emf.parsley.rap.test.parent/pom.xml</relativePath>
+		<groupId>org.eclipse.emf.parsley</groupId>
+		<artifactId>org.eclipse.emf.parsley.rap.test.parent</artifactId>
+		<version>0.2.0-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>org.eclipse.emf.parsley.examples.rap.model</artifactId>
+	<packaging>eclipse-plugin</packaging>
+
+</project>
\ No newline at end of file
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.ui/pom.xml b/examples/org.eclipse.emf.parsley.examples.rap.ui/pom.xml
new file mode 100644
index 0000000..250c1e4
--- /dev/null
+++ b/examples/org.eclipse.emf.parsley.examples.rap.ui/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<relativePath>../../releng/org.eclipse.emf.parsley.rap.test.parent/pom.xml</relativePath>
+		<groupId>org.eclipse.emf.parsley</groupId>
+		<artifactId>org.eclipse.emf.parsley.rap.test.parent</artifactId>
+		<version>0.2.0-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>org.eclipse.emf.parsley.examples.rap.ui</artifactId>
+	<packaging>eclipse-plugin</packaging>
+
+</project>
\ No newline at end of file
diff --git a/releng/org.eclipse.emf.parsley.rap.repository/pom.xml b/releng/org.eclipse.emf.parsley.rap.repository/pom.xml
index 1c30676..11e47b1 100644
--- a/releng/org.eclipse.emf.parsley.rap.repository/pom.xml
+++ b/releng/org.eclipse.emf.parsley.rap.repository/pom.xml
@@ -46,6 +46,22 @@
 							<goal>run</goal>
 						</goals>
 					</execution>
+					<execution>
+						<!-- this will create a .target file pointing to the repository we've just built;
+							we'll use that during another maven build to test that we can compile
+							the our RAP examples (see org.eclipse.emf.parsley.rap.test.parent) -->
+						<id>prepare-target-platform-for-rap-tests</id>
+						<phase>package</phase>
+						<configuration>
+							<target>
+								<ant antfile="${basedir}/../../tests/org.eclipse.emf.parsley.rap.test.targetplatform/create_test_target.ant" 
+									target="create-target-file" />
+							</target>
+						</configuration>
+						<goals>
+							<goal>run</goal>
+						</goals>
+					</execution>
 				</executions>
 			</plugin>
 		</plugins>
diff --git a/releng/org.eclipse.emf.parsley.rap.test.parent/.project b/releng/org.eclipse.emf.parsley.rap.test.parent/.project
new file mode 100644
index 0000000..1f0609e
--- /dev/null
+++ b/releng/org.eclipse.emf.parsley.rap.test.parent/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.emf.parsley.rap.test.parent</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
diff --git a/releng/org.eclipse.emf.parsley.rap.test.parent/README.txt b/releng/org.eclipse.emf.parsley.rap.test.parent/README.txt
new file mode 100644
index 0000000..8aad3d8
--- /dev/null
+++ b/releng/org.eclipse.emf.parsley.rap.test.parent/README.txt
@@ -0,0 +1,18 @@
+This will be used only to test that we can build the RAP examples, using the target platform
+example project that we provide, org.eclipse.emf.parsley.examples.rap.targetplatform.
+
+For this compilation test, we won't be using the actual .target file of
+org.eclipse.emf.parsley.examples.rap.targetplatform (since that refers to a released
+EMF Parsley update site with rap features, and we want to test the target platform resolution
+against what we've just built).
+
+So first the maven build to create the EMF Parsley repository with RAP features must be
+run; during that run, a .target file pointing to the repository we've just built will
+be created in the project org.eclipse.emf.parsley.examples.rap.test.targetplatform (note the
+.test), which is basically the one of org.eclipse.emf.parsley.examples.rap.targetplatform
+after replacing the URL http://download.eclipse.org/emf-parsley/rt with the local file
+system path where we built the repository). Note that for RAP features we still point to
+the original rap site.
+
+Then we can run the maven build from this parent project, which will compile
+our rap examples using the target platform that we created during the previous build.
\ No newline at end of file
diff --git a/releng/org.eclipse.emf.parsley.rap.test.parent/org.eclipse.emf.parsley.rap.test.parent RAP.launch b/releng/org.eclipse.emf.parsley.rap.test.parent/org.eclipse.emf.parsley.rap.test.parent RAP.launch
new file mode 100644
index 0000000..7023f07
--- /dev/null
+++ b/releng/org.eclipse.emf.parsley.rap.test.parent/org.eclipse.emf.parsley.rap.test.parent RAP.launch
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
+<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
+<stringAttribute key="M2_GOALS" value="clean verify"/>
+<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
+<booleanAttribute key="M2_OFFLINE" value="false"/>
+<stringAttribute key="M2_PROFILES" value=""/>
+<listAttribute key="M2_PROPERTIES"/>
+<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
+<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
+<intAttribute key="M2_THREADS" value="1"/>
+<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
+<stringAttribute key="M2_USER_SETTINGS" value=""/>
+<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/org.eclipse.emf.parsley.rap.test.parent}"/>
+</launchConfiguration>
diff --git a/releng/org.eclipse.emf.parsley.rap.test.parent/pom.xml b/releng/org.eclipse.emf.parsley.rap.test.parent/pom.xml
new file mode 100644
index 0000000..7fafad6
--- /dev/null
+++ b/releng/org.eclipse.emf.parsley.rap.test.parent/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.eclipse.emf.parsley</groupId>
+	<artifactId>org.eclipse.emf.parsley.rap.test.parent</artifactId>
+	<version>0.2.0-SNAPSHOT</version>
+	<packaging>pom</packaging>
+
+	<properties>
+		<tycho-version>0.22.0</tycho-version>
+		<tycho-extras-version>0.22.0</tycho-extras-version>
+	</properties>
+	
+	<modules>
+		<module>../../tests/org.eclipse.emf.parsley.rap.test.targetplatform</module>
+		<module>../../examples/org.eclipse.emf.parsley.examples.rap.model</module>
+		<module>../../examples/org.eclipse.emf.parsley.examples.rap.ui</module>
+	</modules>
+
+	<build>
+		
+		<plugins>
+			<plugin>
+				<groupId>org.eclipse.tycho</groupId>
+				<artifactId>tycho-maven-plugin</artifactId>
+				<version>${tycho-version}</version>
+				<extensions>true</extensions>
+			</plugin>
+			
+			<plugin>
+				<groupId>org.eclipse.tycho</groupId>
+				<artifactId>target-platform-configuration</artifactId>
+				<version>${tycho-version}</version>
+				<configuration>
+					<target>
+						<artifact>
+							<groupId>org.eclipse.emf.parsley</groupId>
+							<artifactId>org.eclipse.emf.parsley.rap.test.targetplatform</artifactId>
+							<version>${project.version}</version>
+						</artifact>
+					</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>
diff --git a/tests/org.eclipse.emf.parsley.rap.test.targetplatform/.gitignore b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/.gitignore
new file mode 100644
index 0000000..ee9ff03
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/.gitignore
@@ -0,0 +1 @@
+/org.eclipse.emf.parsley.rap.test.targetplatform.target
diff --git a/tests/org.eclipse.emf.parsley.rap.test.targetplatform/.project b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/.project
new file mode 100644
index 0000000..65e9045
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.emf.parsley.rap.test.targetplatform</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
diff --git a/tests/org.eclipse.emf.parsley.rap.test.targetplatform/README.txt b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/README.txt
new file mode 100644
index 0000000..9f84a61
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/README.txt
@@ -0,0 +1,7 @@
+This will be used only to test that we can build the RAP examples, using the target platform
+example project that we provide, org.eclipse.emf.parsley.examples.rap.targetplatform.
+In this project we create a test .target file that points to the p2 repository that has
+been created during the Tycho build (using the rap profile).
+
+The .target file in this project will be created during the Tycho build and will not be
+put in the git repository.
diff --git a/tests/org.eclipse.emf.parsley.rap.test.targetplatform/create_test_target.ant b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/create_test_target.ant
new file mode 100644
index 0000000..1bcdb7c
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/create_test_target.ant
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="CreateTestTargetDefinitionFile" basedir="." default="create-target-file" >
+
+	<property name="local.target.name" value="org.eclipse.emf.parsley.rap.test.targetplatform.target"/>
+	<property name="local.target" location="${ant.file}/../${local.target.name}"/>
+	<property name="orig.target" location="../../examples/org.eclipse.emf.parsley.examples.rap.targetplatform/emf-parsely-rap-2.3.target"/>
+	<property name="local.mirror.path.input" location="../../target/repository/"/>
+	<property name="local.mirror.url.input" value="file:${local.mirror.path}"/>
+	
+	<macrodef name="replace_win_slashes">
+	    <attribute name="property.to.process" />
+	    <attribute name="output.property" />
+	    <sequential>
+	    	<loadresource property="@{output.property}">
+    	        <string value="@{property.to.process}"/>
+    	        <filterchain>
+    	        	<replaceregex pattern="\\" replace="/" flags="gi"/>
+    	        </filterchain>
+	    	</loadresource>
+	        <echo message="property.to.process: @{property.to.process}" />
+	    	<echo message="output.property    : ${@{output.property}}" />
+	    </sequential>
+	</macrodef>
+
+	<replace_win_slashes property.to.process="${local.mirror.path.input}" output.property="local.mirror.path" />
+	<replace_win_slashes property.to.process="${local.mirror.url.input}" output.property="local.mirror.url" />
+	
+    <target name="copy-target-file" description="Copy the .target definition file into the local.target">
+		<echo message="local.target: ${local.target}" />
+		<echo message="orig.target : ${orig.target}" />
+
+    	<copy file="${orig.target}" tofile="${local.target}" overwrite="true" verbose="true"/>
+    </target>
+
+	
+	<target name="create-target-file" depends="copy-target-file" description="Creates a .target file from the original one, pointing to a local mirror">
+		<echo message="local.mirror.path: ${local.mirror.path}" />
+		<echo message="local.mirror.url : ${local.mirror.url}" />
+		
+		<replaceregexp>
+			<regexp pattern="target name=&quot;(\S+)&quot;(\.*)" />
+			<substitution expression="target name=&quot;local&quot;\2" />
+			<fileset id="path.target" dir="${ant.file}/../">
+				<include name="${local.target.name}" />
+			</fileset>
+		</replaceregexp>
+
+		<replaceregexp byline="true">
+			<regexp pattern="&lt;repository location=&quot;(http://download.eclipse.org/emf-parsley/rt)&quot;(\.*)/&gt;" />
+			<substitution expression="&lt;repository location=&quot;${local.mirror.url}&quot;\2/&gt;" />
+			<fileset id="path.target" dir="${ant.file}/../">
+				<include name="${local.target.name}" />
+			</fileset>
+		</replaceregexp>
+	</target>
+
+</project>
diff --git a/tests/org.eclipse.emf.parsley.rap.test.targetplatform/pom.xml b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/pom.xml
new file mode 100644
index 0000000..0583e24
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.rap.test.targetplatform/pom.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<relativePath>../../releng/org.eclipse.emf.parsley.rap.test.parent/pom.xml</relativePath>
+		<groupId>org.eclipse.emf.parsley</groupId>
+		<artifactId>org.eclipse.emf.parsley.rap.test.parent</artifactId>
+		<version>0.2.0-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>org.eclipse.emf.parsley.rap.test.targetplatform</artifactId>
+	<packaging>eclipse-target-definition</packaging>
+</project>