]> git.argeo.org Git - gpl/argeo-slc.git/blob - maven/plugins/maven-argeo-pde-plugin/src/main/scripts/argeo-pde.build.xml
Automated packaging with custom plugin
[gpl/argeo-slc.git] / maven / plugins / maven-argeo-pde-plugin / src / main / scripts / argeo-pde.build.xml
1 <project>
2 <!-- Defaults -->
3 <property name="projectDirectory" location="${basedir}" />
4 <property name="project.build.directory"
5 location="${projectDirectory}/target" />
6 <property name="dependencyDir"
7 location="${project.build.directory}/dependency" />
8 <property name="eclipseAntArgs" value="" />
9
10 <!-- Element build properties-->
11 <property name="elementBuildScript"
12 location="${projectDirectory}/build.xml" />
13 <property name="buildTempFolder"
14 location="${project.build.directory}/argeo-pde-temp" />
15 <property name="buildScriptProperties" value="" />
16
17 <available file="${projectDirectory}/plugin.xml"
18 property="elementType"
19 value="plugin" />
20 <available file="${projectDirectory}/feature.xml"
21 property="elementType"
22 value="feature" />
23
24 <property name="pluginDestination"
25 location="${project.build.directory}/plugins" />
26 <property name="featureDestination"
27 location="${project.build.directory}/features" />
28
29 <!-- Product build properties -->
30 <property name="buildConfiguration" value="buildConfiguration" />
31 <property name="buildConfiguration.dir"
32 location="${projectDirectory}/${buildConfiguration}" />
33
34 <!-- TARGET Build Element -->
35 <target name="buildElement"
36 depends="init,setPluginPath"
37 description="Builds an element (plugin or feature)">
38 <fail message="Property buildScriptTargets has to be set"
39 unless="buildScriptTargets" />
40
41 <mkdir dir="${pluginDestination}" />
42 <mkdir dir="${featureDestination}" />
43
44 <eclipseAnt antfile="${ant.file}"
45 antargs="eclipse.generateScripts -DpluginPath=${pluginPath} -DprojectDirectory=${projectDirectory} -DeclipseBuildDir=${eclipseBuildDir} -DelementId=${elementId}" />
46 <eclipseAnt antfile="${elementBuildScript}"
47 antargs="${buildScriptTargets} -Dplugin.destination=${pluginDestination} -Dfeature.destination=${featureDestination} -DelementId=${elementId} -DbuildTempFolder=${buildTempFolder} -Dtemp.folder=${buildTempFolder}/temp.folder -Dfeature.temp.folder=${buildTempFolder}/feature.temp.folder ${buildScriptProperties}" />
48
49 <copy todir="${project.build.directory}">
50 <fileset dir="${featureDestination}">
51 <include name="*.zip" />
52 </fileset>
53 <mergemapper to="${elementId}.zip" />
54 </copy>
55 </target>
56
57 <!-- TARGET Build Product -->
58 <target name="buildProduct"
59 depends="init,setPluginPath"
60 description="Builds a product">
61 <!-- Load provided build.properties to leave a chance to override -->
62 <property file="${buildConfiguration.dir}/build.properties" />
63 <!-- Set default properties -->
64 <property name="archivePrefix" value="${elementId}" />
65 <property name="buildId" value="${archivePrefix}" />
66 <property name="buildLabel" value="${archivePrefix}" />
67 <property name="collectingFolder" value="${archivePrefix}" />
68 <property name="skipFetch" value="true" />
69 <property name="skipMaps" value="true" />
70 <property name="runPackager" value="true" />
71
72 <!-- Find PDE build file -->
73 <pathconvert pathsep="" property="productBuildFile">
74 <path>
75 <fileset dir="${pdeBuilder}/plugins">
76 <include name="org.eclipse.pde.build_*/scripts/productBuild/productBuild.xml" />
77 </fileset>
78 </path>
79 </pathconvert>
80 <echo message="productBuildFile=${productBuildFile}" />
81
82 <!-- Copy sources -->
83 <property name="buildDirectory"
84 location="${project.build.directory}/productBuild" />
85 <mkdir dir="${buildDirectory}" />
86 <copy todir="${buildDirectory}" includeemptydirs="true" verbose="true">
87 <fileset dir="${projectDirectory}/../..">
88 <include name="plugins/**" />
89 <include name="features/**" />
90 <exclude name="**/.svn/**" />
91 <exclude name="**/target/**" />
92 </fileset>
93 </copy>
94
95 <!-- Execute -->
96 <eclipseAnt antfile="${productBuildFile}"
97 antargs="-Dbuilder=${buildConfiguration.dir} -DbuildDirectory=${buildDirectory} -DbaseLocation=${baseLocation} -Dbase=${base} -DpluginPath=${pluginPath} -DarchivePrefix=${archivePrefix} -DbuildLabel=${buildLabel} -DbuildId=${buildId} -DcollectingFolder=${collectingFolder} -DskipFetch=${skipFetch} -DskipMaps=${skipMaps} -DrunPackager=${runPackager}" />
98
99 <!-- Copy to target dir -->
100 <copy todir="${project.build.directory}">
101 <fileset dir="${buildDirectory}/${collectingFolder}">
102 <include name="*.zip" />
103 </fileset>
104 <globmapper from="${archivePrefix}-*" to="${elementId}-*" />
105 </copy>
106 </target>
107
108 <!-- TARGET Clean -->
109 <target name="clean"
110 depends="init,clean.elementBuildScript"
111 description="Cleans the generated resources">
112 <delete dir="${projectDirectory}/workspace" verbose="true" />
113 <delete file="${projectDirectory}/javaCompiler...args" verbose="true" />
114 <delete>
115 <fileset dir="${projectDirectory}/../..">
116 <include name="final*.properties" />
117 <include name="assemble*.xml" />
118 <include name="package*.xml" />
119 </fileset>
120 </delete>
121 </target>
122
123 <target name="clean.elementBuildScript" if="elementBuildScript.exists">
124 <ant antfile="${elementBuildScript}" target="clean" />
125 <delete file="${elementBuildScript}" verbose="true" />
126 </target>
127
128 <!-- COMMON UTILITIES -->
129 <target name="init">
130 <!-- Init Base -->
131 <property name="base" location="${eclipseBuildDir}" />
132 <property name="baseLocation" location="${base}/eclipse-SDK-DP-3.3.2" />
133 <property name="pdeBuilder"
134 location="${eclipseBuildDir}/argeo-slc-pde" />
135 <property name="pluginPathBase"
136 location="${eclipseBuildDir}/pluginPath" />
137
138 <path id="pdeBuilder.launcher.classpath">
139 <fileset dir="${pdeBuilder}/plugins">
140 <include name="org.eclipse.equinox.launcher_*.jar" />
141 </fileset>
142 </path>
143
144 <!-- Log properties -->
145 <echo message="basedir=${basedir}" />
146 <echo message="ant.file=${ant.file}" />
147 <echo message="projectDirectory=${projectDirectory}" />
148
149 <echo message="eclipseBuildDir=${eclipseBuildDir}" />
150 <echo message="base=${base}" />
151 <echo message="baseLocation=${baseLocation}" />
152 <echo message="pdeBuilder=${pdeBuilder}" />
153 <echo message="localBuildDir=${localBuildDir}" />
154 <echo message="pluginPathBase=${pluginPathBase}" />
155
156 <echo message="elementType=${elementType}" />
157 <echo message="elementId=${elementId}" />
158 <echo message="elementBuildScript=${elementBuildScript}" />
159 <echo message="buildScriptTargets=${buildScriptTargets}" />
160 <echo message="buildScriptProperties=${buildScriptProperties}" />
161
162 <echo message="eclipseAntArgs=${eclipseAntArgs}" />
163
164 <echo message="buildConfiguration.dir=${buildConfiguration.dir}" />
165
166 <available file="${elementBuildScript}"
167 property="elementBuildScript.exists"
168 value="true" />
169 </target>
170
171 <target name="setPluginPath">
172 <mkdir dir="${dependencyDir}" />
173 <pathconvert property="pluginPath">
174 <path>
175 <pathelement location="${dependencyDir}" />
176 <dirset dir="${pluginPathBase}">
177 <include name="*" />
178 </dirset>
179 </path>
180 </pathconvert>
181 <echo message="pluginPath=${pluginPath}" />
182 </target>
183
184 <!-- TARGETS TO BE CALLED WITH ANT ECLIPSE -->
185 <target name="eclipse.generateScripts" depends="init">
186 <fail message="Property elementType has to be set"
187 unless="elementType" />
188 <property name="buildDirectory" location="${projectDirectory}/../.." />
189 <eclipse.buildScript elements="${elementType}@${elementId}"
190 buildDirectory="${buildDirectory}"
191 baseLocation="${baseLocation}"
192 outputUpdateJars="true"
193 generateVersionsLists="true"
194 pluginPath="${pluginPath}" />
195 </target>
196
197 <!-- MACRODEFS -->
198 <macrodef name="eclipseAnt">
199 <attribute name="antfile" />
200 <attribute name="antargs" />
201 <sequential>
202 <echo message="Call Eclipse Ant for file @{antfile} with args ${eclipseAntArgs} @{antargs}" />
203 <java fork="true"
204 classname="org.eclipse.core.launcher.Main"
205 failonerror="true">
206 <classpath refid="pdeBuilder.launcher.classpath" />
207 <arg line="-data ${project.build.directory}/workspace" />
208 <arg line="-application org.eclipse.ant.core.antRunner" />
209 <arg line="-buildfile @{antfile}" />
210 <arg line="${eclipseAntArgs}" />
211 <arg line="@{antargs}" />
212 </java>
213 </sequential>
214 </macrodef>
215 </project>