awips2/edexOsgi/build.edex/deploy-common/plugin-methods.xml
Steve Harris 745f2c6409 13.1.2-2 baseline
Former-commit-id: e8f4a2f031 [formerly 51208e5515] [formerly c0c1d56f3a] [formerly e8f4a2f031 [formerly 51208e5515] [formerly c0c1d56f3a] [formerly 4ba416aeb3 [formerly c0c1d56f3a [formerly 221d0aaf0e19a054387134e72a76a278159bf4d0]]]]
Former-commit-id: 4ba416aeb3
Former-commit-id: 82cdde8491 [formerly cd4185ef5c] [formerly 413d9d9811179a10639f756b8b4f690d86be7a6a [formerly 941337c553]]
Former-commit-id: c69e1900269e630aefc061c2464bc8fea1c9776a [formerly b6fa9b4858]
Former-commit-id: f52ec0b0a0
2013-01-06 14:32:24 -06:00

290 lines
8 KiB
XML

<project>
<macrodef name="processPlugins">
<attribute name="includes.file" />
<attribute name="plugin.type" />
<attribute name="plugin.directories" />
<attribute name="destination.directory" />
<sequential>
<loadfile property="includefile.@{plugin.type}"
srcfile="@{includes.file}" />
<var name="index" value="1" />
<for param="line" list="${includefile.@{plugin.type}}"
delimiter="${line.separator}">
<sequential>
<!-- skip the first line -->
<if>
<not>
<equals arg1="${index}" arg2="1" />
</not>
<then>
<if>
<!-- TODO: we need our own ant plugin so this
becomes unnecessary [SPECIAL CASE]. -->
<equals arg1="@{plugin.type}" arg2="cots" />
<then>
<propertyregex property="plugin.name"
override="true"
input="@{line}"
regexp="(.+)/(.+)"
select="\1"
casesensitive="true" />
</then>
<else>
<propertyregex property="plugin.name"
override="true"
input="@{line}"
regexp="(.+)/component-deploy.xml"
select="\1"
casesensitive="true" />
</else>
</if>
<deployPlugins
plugin.name="${plugin.name}"
original.pattern="@{line}"
plugin.type="@{plugin.type}"
plugin.directories="@{plugin.directories}"
destination.directory="@{destination.directory}" />
</then>
</if>
<math result="index"
operand1="${index}"
operation="+"
operand2="1"
datatype="int" />
</sequential>
</for>
</sequential>
</macrodef>
<macrodef name="deployPlugins">
<attribute name="plugin.name" />
<attribute name="original.pattern" />
<attribute name="plugin.type" />
<attribute name="plugin.directories" />
<attribute name="destination.directory" />
<sequential>
<var name="plugin.path" value="" />
<!-- first we need to find the plugin -->
<for list="${basedirectories}" param="directory"
delimiter=";">
<sequential>
<if>
<available file="@{directory}/@{plugin.name}" />
<then>
<var name="plugin.path"
value="@{directory}" />
</then>
</if>
</sequential>
</for>
<if>
<equals arg1="${plugin.path}" arg2="" />
<then>
<fail message="Failed to find plugin: @{plugin.name}" />
</then>
</if>
<var name="plugin.base" value="${plugin.path}/@{plugin.name}" />
<var name="plugin.bin" value="${plugin.base}/bin" />
<var name="jar.destfile"
value="${destination.directory}/@{plugin.name}.jar" />
<!-- deploy the plugin - cots plugins are deployed differently -->
<if>
<equals arg1="@{plugin.type}" arg2="cots" />
<then>
<!-- copy the cots jars to the destination -->
<copyFOSS
plugin.directory323="${plugin.base}"
jar.file323="${jar.destfile}"
destination.directory323="${destination.directory}/@{plugin.name}" />
<!-- jar any compiled cots source -->
<if>
<available file="${plugin.bin}" type="dir" />
<then>
<jar destfile="${jar.destfile}">
<fileset dir="${plugin.bin}"
includes="**/*.class" />
</jar>
</then>
</if>
</then>
<else>
<jarPlugin
plugin.directory323="${plugin.base}"
jar.file323="${jar.destfile}" />
</else>
</if>
<ant antfile="${basedir}/deploy-common/external-rules.xml"
inheritAll="false">
<property name="plugin._directory"
value="${plugin.base}" />
<property name="deployment._root"
value="${edex.root.directory}" />
</ant>
</sequential>
</macrodef>
<macrodef name="jarPlugin">
<!--
random character suffixes added to
maintain uniqueness of variable names
-->
<attribute name="plugin.directory323" />
<attribute name="jar.file323" />
<sequential>
<!--
initial jar file: currently we make the assumption
every plugin has a manifest file.
-->
<jar destfile="@{jar.file323}"
manifest="@{plugin.directory323}/META-INF/MANIFEST.MF" />
<!-- scan build.properties -->
<var file="@{plugin.directory323}/build.properties" />
<!--
* iterate through bin.includes
* '.' is seen as the ${output..} directory, itself
* artifacts are only deployed if they are present
-->
<for list="${bin.includes}" param="include"
delimiter="," trim="true">
<sequential>
<if>
<available file="@{plugin.directory323}/@{include}"
type="dir" />
<then>
<!-- deploy a directory -->
<!-- is this the output directory? -->
<if>
<equals arg1="@{include}" arg2="." />
<then>
<jar destfile="@{jar.file323}" update="true">
<fileset
dir="@{plugin.directory323}/${output..}"
includes="**" />
</jar>
</then>
<else>
<jar destfile="@{jar.file323}" update="true">
<fileset
dir="@{plugin.directory323}"
includes="@{include}/**" />
</jar>
</else>
</if>
</then>
<else>
<!-- are we deploying a file? -->
<if>
<available file="@{plugin.directory323}/@{include}"
type="file" />
<then>
<jar destfile="@{jar.file323}" update="true">
<fileset
file="@{plugin.directory323}/@{include}" />
</jar>
</then>
<else>
<!-- fail: unknown deployment artifact -->
<fail
message="Unable to deploy '@{include}' specified in @{plugin.directory323}/build.properties; unable to find the file / directory." />
</else>
</if>
</else>
</if>
</sequential>
</for>
</sequential>
</macrodef>
<macrodef name="copyFOSS">
<!--
random character suffixes added to
maintain uniqueness of variable names
-->
<attribute name="plugin.directory323" />
<attribute name="jar.file323" />
<attribute name="destination.directory323" />
<sequential>
<mkdir dir="@{destination.directory323}" />
<!-- scan build.properties -->
<var file="@{plugin.directory323}/build.properties" />
<!--
* iterate through bin.includes
* '.' is seen as the ${output..} directory, itself
* artifacts are only deployed if they are present
-->
<for list="${bin.includes}" param="include"
delimiter="," trim="true">
<sequential>
<if>
<available file="@{plugin.directory323}/@{include}"
type="dir" />
<then>
<!-- deploy a directory -->
<!-- is this the output directory? -->
<if>
<equals arg1="@{include}" arg2="." />
<then>
<if>
<available file="@{plugin.directory323}/${output..}"
type="dir" />
<then>
<jar destfile="@{jar.file323}" update="true">
<fileset
dir="@{plugin.directory323}/${output..}"
includes="**" />
</jar>
</then>
</if>
</then>
<else>
<copy todir="@{destination.directory323}"
overwrite="true" verbose="true">
<fileset dir="@{plugin.directory323}"
includes="@{include}/**" />
</copy>
</else>
</if>
</then>
<else>
<!-- are we deploying a file? -->
<if>
<available file="@{plugin.directory323}/@{include}"
type="file" />
<then>
<copy todir="@{destination.directory323}"
overwrite="true" verbose="true">
<fileset dir="@{plugin.directory323}"
includes="@{include}" />
</copy>
</then>
<else>
<!-- fail: unknown deployment artifact -->
<fail
message="Unable to deploy '@{include}' specified in @{plugin.directory323}/build.properties; unable to find the file / directory." />
</else>
</if>
</else>
</if>
</sequential>
</for>
</sequential>
</macrodef>
</project>