Author: nickboldt
Date: 2010-04-20 23:19:19 -0400 (Tue, 20 Apr 2010)
New Revision: 21564
Modified:
branches/modular_build/genpom.xml
Log:
add support for getArtifactOsWsArch to add platform dep values into pom.xml; add support
for overwrite.existing.pom.xml (default false) so if pom.xml already exists, don't
simply regenerate it
Modified: branches/modular_build/genpom.xml
===================================================================
--- branches/modular_build/genpom.xml 2010-04-21 02:15:52 UTC (rev 21563)
+++ branches/modular_build/genpom.xml 2010-04-21 03:19:19 UTC (rev 21564)
@@ -7,6 +7,7 @@
<property name="dirsToExclude"
value="**/*.sdk.*, **/doc*, **/download.jboss.org, **/util/**, **/test,
**/builders, **/contrib, **/releng/**, ."
/>
+ <property name="overwrite.existing.pom.xml" value="false" />
<!-- Configuration Ends -->
<!-- To run this script in Eclipse:
@@ -97,7 +98,15 @@
override="true"
/>
<echo level="verbose"> Agg dir: ${activeDir}, artifactType:
${artifactType}, artifactId: ${artifactId}, artifactVersion: ${artifactVersion},
parentpom: @{parentpom}</echo>
- <echo file="(a){dir}/pom.xml">&lt;project
+ <if>
+ <or>
+ <not>
+ <available file="(a){dir}/pom.xml" type="file" />
+ </not>
+ <istrue value="${overwrite.existing.pom.xml}" />
+ </or>
+ <then>
+ <echo file="(a){dir}/pom.xml">&lt;project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -112,23 +121,25 @@
<packaging>${artifactType}</packaging>
<modules>
</echo>
- <var name="artifactId" unset="true" />
- <var name="artifactVersion" unset="true" />
- <for param="subdir" delimiter=",
+ <var name="artifactId" unset="true" />
+ <var name="artifactVersion" unset="true" />
+ <for param="subdir" delimiter=",
">
- <path>
- <dirset dir="@{dir}" excludes="${dirsToExclude}"
includes="*" />
- </path>
- <sequential>
- <basename property="subdirSuffix" file="@{subdir}" />
- <echo file="(a){dir}/pom.xml"
append="true"> <module>${subdirSuffix}</module>
+ <path>
+ <dirset dir="@{dir}" excludes="${dirsToExclude}"
includes="*" />
+ </path>
+ <sequential>
+ <basename property="subdirSuffix" file="@{subdir}" />
+ <echo file="(a){dir}/pom.xml"
append="true"> <module>${subdirSuffix}</module>
</echo>
- <var name="subdirSuffix" unset="true" />
- </sequential>
- </for>
- <echo file="(a){dir}/pom.xml"
append="true"> </modules>
+ <var name="subdirSuffix" unset="true" />
+ </sequential>
+ </for>
+ <echo file="(a){dir}/pom.xml"
append="true"> </modules>
</project>
</echo>
+ </then>
+ </if>
</sequential>
</macrodef>
@@ -160,6 +171,12 @@
<antcallback target="getArtifactVersion"
return="artifactVersion">
<property name="dir" value="@{dir}" />
</antcallback>
+ <var name="artifactOs" unset="true" />
+ <var name="artifactWs" unset="true" />
+ <var name="artifactArch" unset="true" />
+ <antcallback target="getArtifactOsWsArch" return="artifactOs,
artifactWs, artifactArch">
+ <property name="artifactId" value="${artifactId}" />
+ </antcallback>
</else>
</if>
<propertyregex property="activeDir"
@@ -171,7 +188,15 @@
override="true"
/>
<echo level="verbose"> Mod dir: ${activeDir}, artifactType:
${artifactType}, artifactId: ${artifactId}, artifactVersion: ${artifactVersion},
parentpom: @{parentpom}</echo>
- <echo file="(a){dir}/pom.xml">&lt;project
+ <if>
+ <or>
+ <not>
+ <available file="(a){dir}/pom.xml" type="file" />
+ </not>
+ <istrue value="${overwrite.existing.pom.xml}" />
+ </or>
+ <then>
+ <echo file="(a){dir}/pom.xml">&lt;project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -180,16 +205,65 @@
<artifactId>${projectName}.parent.pom</artifactId>
<version>${pomVersion}</version>
</parent>
- <groupId>${projectName}</groupId>
+ <groupId>${projectName}</groupId>
<artifactId>${artifactId}</artifactId>
- <version>${artifactVersion}</version>
- <packaging>${artifactType}</packaging>
-</project>
- </echo>
- <!-- TODO: if generating module pom for a given platform, add in platform-specific
stuff (see xulrunner) -->
+ <version>${artifactVersion}</version>
+ <packaging>${artifactType}</packaging>
+</echo>
+ <if>
+ <or>
+ <and>
+ <isset property="artifactOs" />
+ <not>
+ <equals arg1="" arg2="${artifactOs}" />
+ </not>
+ </and>
+ <and>
+ <isset property="artifactWs" />
+ <not>
+ <equals arg1="" arg2="${artifactWs}" />
+ </not>
+ </and>
+ <and>
+ <isset property="artifactArch" />
+ <not>
+ <equals arg1="" arg2="${artifactArch}" />
+ </not>
+ </and>
+ </or>
+ <then>
+ <echo file="(a){dir}/pom.xml"
append="true"> <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tychoVersion}</version>
+ <configuration>
+ <resolver>p2</resolver>
+ <environments>
+ <environment>
+ <os>${artifactOs}</os>
+ <ws>${artifactWs}</ws>
+ <arch>${artifactArch}</arch>
+ </environment>
+ </environments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</echo>
+ </then>
+ </if>
+ <echo file="(a){dir}/pom.xml"
append="true"></project>
+</echo>
+ </then>
+ </if>
<var name="artifactId" unset="true" />
<var name="artifactVersion" unset="true" />
<var name="artifactType" unset="true" />
+ <var name="artifactOs" unset="true" />
+ <var name="artifactWs" unset="true" />
+ <var name="artifactArch" unset="true" />
<var name="modulecountstring" value="${modulecountstring}1"
/>
</sequential>
</macrodef>
@@ -570,6 +644,42 @@
<var name="parent.dir" unset="true" />
</target>
+ <!-- supports only the following platforms:
+ org.mozilla.xulrunner.carbon.macosx
+ org.mozilla.xulrunner.cocoa.macosx
+ org.mozilla.xulrunner.gtk.linux.x86
+ org.mozilla.xulrunner.gtk.linux.x86_64
+ org.mozilla.xulrunner.win32.win32.x86
+ -->
+ <target name="getArtifactOsWsArch">
+ <property name="artifactId"
value="org.mozilla.xulrunner.cocoa.macosx" />
+ <propertyregex property="artifactOs"
+ input="${artifactId}"
+ defaultvalue=""
+ regexp="(macosx|linux|win32)"
+ select="\1"
+ casesensitive="true"
+ override="true"
+ />
+ <propertyregex property="artifactWs"
+ input="${artifactId}"
+ defaultvalue=""
+ regexp="(carbon|cocoa|win32|gtk)"
+ select="\1"
+ casesensitive="true"
+ override="true"
+ />
+ <propertyregex property="artifactArch"
+ input="${artifactId}"
+ defaultvalue=""
+ regexp="\.(x86|x86_64)$"
+ select="\1"
+ casesensitive="true"
+ override="true"
+ />
+
+ </target>
+
<target name="getArtifactId">
<property name="dir" value="." />
<!-- echo>${dir}</echo -->
@@ -672,6 +782,31 @@
<property
name="artifactType.portlet/features/org.jboss.tools.portlet.test.feature"
value="eclipse-feature" />
<property name="artifactType.jst/features/org.jboss.tools.jst.feature"
value="eclipse-feature" />
<property
name="artifactType.jst/features/org.jboss.tools.jst.web.tiles.feature"
value="eclipse-feature" />
+
+ <!-- expected values for artifactOsWsArch tests -->
+ <property name="artifactOsWsArch.org.mozilla.xpcom.os" value=""
/>
+ <property name="artifactOsWsArch.org.mozilla.xpcom.ws" value=""
/>
+ <property name="artifactOsWsArch.org.mozilla.xpcom.arch"
value="" />
+
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.carbon.macosx.os"
value="macosx" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.carbon.macosx.ws"
value="carbon" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.carbon.macosx.arch"
value="" />
+
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.cocoa.macosx.os"
value="macosx" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.cocoa.macosx.ws"
value="cocoa" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.cocoa.macosx.arch"
value="" />
+
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.gtk.linux.x86.os"
value="linux" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.gtk.linux.x86.ws"
value="gtk" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.gtk.linux.x86.arch"
value="x86" />
+
+ <property
name="artifactOsWsArch.org.mozilla.xulrunner.gtk.linux.x86_64.os"
value="linux" />
+ <property
name="artifactOsWsArch.org.mozilla.xulrunner.gtk.linux.x86_64.ws"
value="gtk" />
+ <property
name="artifactOsWsArch.org.mozilla.xulrunner.gtk.linux.x86_64.arch"
value="x86_64" />
+
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.win32.win32.x86.os"
value="win32" />
+ <property name="artifactOsWsArch.org.mozilla.xulrunner.win32.win32.x86.ws"
value="win32" />
+ <property
name="artifactOsWsArch.org.mozilla.xulrunner.win32.win32.x86.arch"
value="x86" />
</target>
<target name="test.all">
@@ -694,6 +829,7 @@
<antcall target="test.getArtifactVersion" />
<antcall target="test.getArtifactId" />
<antcall target="test.getArtifactType" />
+ <antcall target="test.getArtifactOsWsArch" />
</target>
<target name="test.getArtifactVersion" depends="init,
test.expected.values">
@@ -773,6 +909,56 @@
</for>
</target>
+ <target name="test.getArtifactOsWsArch" depends="init,
test.expected.values">
+ <property name="artifactIds"
+ value="
+ org.mozilla.xpcom
+ org.mozilla.xulrunner.carbon.macosx
+ org.mozilla.xulrunner.cocoa.macosx
+ org.mozilla.xulrunner.gtk.linux.x86
+ org.mozilla.xulrunner.gtk.linux.x86_64
+ org.mozilla.xulrunner.win32.win32.x86
+ "
+ />
+ <for param="artifactId" list="${artifactIds}" delimiter=",
+ ">
+ <sequential>
+ <echo level="debug">artifactId = @{artifactId}</echo>
+ <antcallback target="getArtifactOsWsArch" return="artifactOs,
artifactWs, artifactArch">
+ <property name="artifactId" value="@{artifactId}" />
+ </antcallback>
+ <propertycopy name="expected.value.os"
from="artifactOsWsArch.(a){artifactId}.os" />
+ <propertycopy name="expected.value.ws"
from="artifactOsWsArch.(a){artifactId}.ws" />
+ <propertycopy name="expected.value.arch"
from="artifactOsWsArch.(a){artifactId}.arch" />
+ <assert failonerror="false"
+ message="For @{artifactId}, artifactOs = ${artifactOs}; expected
${expected.value.os}"
+ >
+ <bool>
+ <equals arg1="${expected.value.os}" arg2="${artifactOs}"
/>
+ </bool>
+ </assert>
+ <assert failonerror="false"
+ message="For @{artifactId}, artifactWs = ${artifactWs}; expected
${expected.value.ws}"
+ >
+ <bool>
+ <equals arg1="${expected.value.ws}" arg2="${artifactWs}"
/>
+ </bool>
+ </assert>
+ <assert failonerror="false"
+ message="For @{artifactId}, artifactArch = ${artifactArch}; expected
${expected.value.arch}"
+ >
+ <bool>
+ <equals arg1="${expected.value.arch}" arg2="${artifactArch}"
/>
+ </bool>
+ </assert>
+ <var name="expected.value.os" unset="true" />
+ <var name="expected.value.ws" unset="true" />
+ <var name="expected.value.arch" unset="true" />
+ </sequential>
+ </for>
+
+ </target>
+
<target name="test.getArtifactType" depends="init,
test.expected.values">
<property name="dirs"
value="