From: Eric G. <ri...@us...> - 2005-05-12 19:49:20
|
rikgig 05/05/12 12:49:13 Modified: uberdist plugin.jelly Log: Add a new tag to get filtered project dependencies. Make fallback on dist plugin work. Removed useless goals. Simplified some code in there. Deprecated the register-deregister mechanism. Now uberdist works only for one project at a time. Revision Changes Path 1.2 +107 -104 maven-plugins/uberdist/plugin.jelly Index: plugin.jelly =================================================================== RCS file: /cvsroot/maven-plugins/maven-plugins/uberdist/plugin.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- plugin.jelly 2 Mar 2005 17:45:38 -0000 1.1 +++ plugin.jelly 12 May 2005 19:49:13 -0000 1.2 @@ -16,26 +16,26 @@ * limitations under the License. */ --> - <project xmlns:define="jelly:define" xmlns:j="jelly:core" xmlns:util="jelly:util" xmlns:ant="jelly:ant" - xmlns:maven="jelly:maven"> + xmlns:maven="jelly:maven" + xmlns:uber-dist="uber-dist"> <!-- Variable that will hold the list of projects that are part of the distribution to be built --> <j:new var="projects" className="java.util.ArrayList"/> <!-- Tag lib for the plugin --> <define:taglib uri="uber-dist"> +<!-- This Tag is deprecated. Do not use it anymore --> <define:tag name="deregisterProject"> - <!-- @name : Project to deregister, must be same as name used to register --> - + <!-- + @name : Project to deregister, must be same as name used to register + --> <maven:pluginVar var="projects" plugin="maven-uberdist-plugin" property="projects" /> - - <j:set var="removeProject" value="null"/> <j:forEach var="proj" items="${projects}"> <j:if test="${proj.get('name').equals(name)}"> @@ -46,7 +46,7 @@ <j:set var="dummy" value="${projects.remove(removeProject)}"/> </j:if> </define:tag> - +<!-- This Tag is deprecated. Do not use it anymore --> <define:tag name="registerProject"> <!-- @name the name of this project. @@ -81,30 +81,66 @@ <attainGoal name="uber-dist:copy-scripts"/> </define:tag> - + <define:tag name="getArtifacts"> + <!-- + @depArtifacts : Map of artifacts to deploy. Supplied by the caller + --> + <ant:echo message="Getting project dependencies to be deployed..."/> + <j:if test="${pom.getProperty('jar.dependency.dist.dir')!=null}"> + <j:set var="projectDepDeployDir" value="${pom.getProperty('jar.dependency.dist.dir')}${'/'}"/> + </j:if> + <j:set var="projectId" value="${pom.artifactId}.deploy"/> + <j:forEach var="lib" items="${pom.artifacts}"> + <j:if test="${lib.dependency.getProperty(projectId)=='true'}"> + <j:set var="depDeployDir" value="${projectDepDeployDir}"/> + <!-- Check to see if the jar.dependency.deploy.dir was overriden at the dependency level --> + <j:if test="${dep.dependency.getProperty('jar.dependency.dist.dir')!=null}"> + <j:set var="depDeployDir" value="${dep.dependency.getProperty('jar.dependency.dist.dir')}${'/'}"/> + </j:if> + <!-- Here check if the deploy name for the dependency must be overriden to satisfy + either plateform requirement or libraries manifest sepecifications --> + <j:choose> + <j:when test="${dep.dependency.getProperty('jar.dependency.dist.name')!=null}"> + <j:set var="depDeployName" value="${dep.dependency.getProperty('jar.dependency.dist.name')}"/> + <echo message="Deploying dependency: ${dep.file.name} under overriden name: ${depDeployName}"/> + </j:when> + <j:otherwise> + <j:set var="depDeployName" value="${lib.file.name}"/> + </j:otherwise> + </j:choose> + <j:set var="fname" value="${depDeployDir}${depDeployName}"/> + <j:set var="dummy"> + ${depArtifacts.put(lib,fname)} + </j:set> + </j:if> + </j:forEach> + </define:tag> + </define:taglib> <goal name="uber-dist:init" - description="This goal is provided to give a hook on project developpers to add a preGoal so that - the project registers itself with the plugin. It also checks for os and set a property - if it is found to be running on Solaris to customize tar call on Unix (to keep - right on the files in the tarball)"> - + description="Checks for os and set properties for OS specific tasks."> <condition property="isOnUnix"> <or> <os family="unix"/> <os name="SunOS"/> </or> </condition> - <j:if test="${isOnUnix == 'true'}"> + <j:choose> + <j:when test="${isOnUnix == 'true'}"> + <j:set var="osCPSeparator" value=":"/> <echo message="Building distribution from a Unix based box"/> - </j:if> + </j:when> + <j:otherwise> + <j:set var="osCPSeparator" value=";"/> + </j:otherwise> + </j:choose> </goal> <goal name="uber-dist:clean-dist-filesystem" description="Delete existing distribution directories to build a new distribution" - prereqs="uber-dist:dist-setup"> + prereqs="uber-dist:init"> <j:choose> <j:when test="${maven.uber.dist.assembly.dir.length()!=0}"> @@ -131,7 +167,8 @@ <!-- Create a tar.gz file and zip distribution --> - <goal name="uber-dist:create-distrib"> + <goal name="uber-dist:create-distrib" + prereqs="uber-dist:init"> <ant:echo>Creating tarball on dir:${maven.uber.dist.assembly.dir}</ant:echo> <j:choose> @@ -159,56 +196,32 @@ </j:otherwise> </j:choose> </goal> - - - <goal name="uber-dist:dist-setup" - description="This goal checks for registered projects. If none are found then we fail the build"> - - <j:if test="${projects.isEmpty()}"> - <fail>No projects registered with uber-dist</fail> - </j:if> - </goal> - - <goal name="uber-dist:clean-dist" - description="Goal that cleans the distributions and dist-assembly directory for the project" - prereqs="uber-dist:init"> - - <attainGoal name="uber-dist:clean-dist-filesystem"/> - </goal> - - + <goal name="uber-dist:prepare-dist-filesystem" prereqs="uber-dist:init"> - <ant:mkdir dir="${maven.uber.dist.assembly.dir}" /> - <ant:mkdir dir="${maven.uber.dist.dir}" /> - - <j:if test="${!projects.isEmpty()}"> - <j:forEach var="project" items="${projects}"> - <j:set var="goalName" value="${project.get('name')}:prepare-dist-filesystem"/> - <j:catch var="ex"> - <echo message="calling goal : ${goalName}"/> - <attainGoal name="${goalName}"/> - </j:catch> - <j:if test="${ex != null}"> - <j:if test="${ex.getMessage().indexOf('No goal') == (1) }"> - <echo message="The goal : ${goalName} is not defined in your project"/> - </j:if> - <!-- TODO: Replace this fail command with a fallback on the maven-dist-plugin --> - <fail>Exception caught while running goal [${goalName}] Details: ${ex}</fail> - </j:if> + <ant:mkdir dir="${maven.uber.dist.assembly.dir}" /> + <ant:mkdir dir="${maven.uber.dist.dir}" /> - </j:forEach> - + <j:set var="goalName" value="${pom.artifactId}:prepare-dist-filesystem"/> + <j:catch var="ex"> + <echo message="calling goal : ${goalName}"/> + <attainGoal name="${goalName}"/> + </j:catch> + <j:choose> + <j:when test="${ex != null}"> + <echo message="Exception caught: ${ex.getMessage()}"/> + <echo message="The goal : ${goalName} is not defined in your project, using maven-dist-plugin fallback!"/> + <maven:set plugin="maven-dist-plugin" property="maven.dist.bin.assembly.dir" value="${maven.uber.dist.assembly.dir}"/> + <maven:set plugin="maven-dist-plugin" property="maven.dist.dir" value="${maven.uber.dist.dir}"/> + <attainGoal name="dist:build-bin"/> + </j:when> + <j:otherwise> <attainGoal name="uber-dist:copy-deps"/> <attainGoal name="uber-dist:copy-scripts"/> <attainGoal name="uber-dist:make-executable"/> - </j:if> - - - <j:if test="${projects.isEmpty()}"> - <echo>No projects registered with uber-dist</echo> - </j:if> + </j:otherwise> + </j:choose> </goal> <goal name="uber-dist:build" @@ -234,50 +247,19 @@ <goal name="uber-dist:copy-deps" description="To copy only the specially marked dependencies of a sub-project, ones with an attribute - name like the pom.artifactId-deploy and with a value 'true'"> + name like the pom.artifactId-deploy and with a value 'true'" + prereqs="uber-dist:init"> + <!-- Go get all dependencies that are marked by the project id (way to exclude master project's dependencies --> - <j:new var="deps" className="java.util.Vector"/> - <j:set var="projectId" value="${pom.artifactId}.deploy"/> - <j:forEach var="lib" items="${pom.artifacts}"> - <j:if test="${lib.dependency.getProperty(projectId)=='true'}"> - <echo>adding dep: ${lib.file.name}</echo> - <j:set var="dummy"> - ${deps.add(lib)} - </j:set> - </j:if> - </j:forEach> + <j:new var="projArtifacts" className="java.util.HashMap"/> + <uber-dist:getArtifacts depArtifacts="${projArtifacts}"/> <!-- Copy child dependencies if there is at least one entry because an empty ant:copy generates an error if no files are in the copy definition --> - <j:if test="${!deps.isEmpty()}"> - - <!-- Get the project level deployment sub-directory if it exists --> - <j:if test="${pom.getProperty('jar.dependency.dist.dir')!=null}"> - <j:set var="projectDepDeployDir" value="${pom.getProperty('jar.dependency.dist.dir')}${'/'}"/> - </j:if> - - <j:forEach var="dep" items="${deps}"> - <!-- Set default deploy sub-dir for dependencies to project level property value --> - <j:set var="depDeployDir" value="${projectDepDeployDir}"/> - <!-- Check to see if the jar.dependency.deploy.dir was overriden at the dependency level --> - <j:if test="${dep.dependency.getProperty('jar.dependency.dist.dir')!=null}"> - <j:set var="depDeployDir" value="${dep.dependency.getProperty('jar.dependency.dist.dir')}${'/'}"/> - </j:if> - - <!-- Here check if the deploy name for the dependency must be overriden to satisfy - either plateform requirement or libraries manifest sepecifications --> - <j:choose> - <j:when test="${dep.dependency.getProperty('jar.dependency.dist.name')!=null}"> - <j:set var="depDeployName" value="${dep.dependency.getProperty('jar.dependency.dist.name')}"/> - <echo message="Deploying dependency: ${dep.file.name} under overriden name: ${depDeployName}"/> - </j:when> - <j:otherwise> - <j:set var="depDeployName" value="${dep.file.name}"/> - </j:otherwise> - </j:choose> - - <ant:copy tofile="${maven.uber.dist.assembly.dir}/${depDeployDir}/${depDeployName}"> - <ant:fileset dir="${dep.file.parent}"> - <ant:include name="${dep.file.name}"/> + <j:if test="${!projArtifacts.isEmpty()}"> + <j:forEach var="dep" items="${projArtifacts}"> + <ant:copy tofile="${maven.uber.dist.assembly.dir}/${dep.getValue()}" verbose="true"> + <ant:fileset dir="${dep.getKey().file.parent}"> + <ant:include name="${dep.getKey().file.name}"/> </ant:fileset> </ant:copy> </j:forEach> @@ -304,7 +286,8 @@ <goal name="uber-dist:copy-scripts" description="This goal copies batch command scripts (*.cmd, *.bat, *.sh, and so on...) using a filter. - The default filtering criteria is artifact_id. This token will be replaced by the ant:copy tag automatically"> + The default filtering criteria is artifact_id. This token will be replaced by the ant:copy tag automatically" + prereqs="uber-dist:init"> <maven:get var="scripts_dir" plugin="maven-uberdist-plugin" property="maven.uber.dist.scripts.dir"/> <maven:get var="dest_dir" plugin="maven-uberdist-plugin" property="maven.uber.dist.assembly.dir"/> @@ -330,10 +313,30 @@ Copying filtered launch scripts using pattern: ${maven.uber.dist.launch.scripts} From dir: ${scripts_dir} To dir: ${maven.uber.dist.assembly.dir} - </echo> - <ant:copy todir="${maven.uber.dist.assembly.dir}" filtering="true" verbose="true" > + </echo> + +<!-- Here, we build the classpath entry from all the deployed dependencies. --> + <!-- get dependencies to deploy --> + <j:new var="myartifacts" className="java.util.HashMap"/> + <uber-dist:getArtifacts depArtifacts="${myartifacts}"/> + + <j:set var="completecp" value=""/> + <j:if test="${!myartifacts.isEmpty()}"> + <j:forEach var="dep" items="${myartifacts}"> + <j:if test="${completecp.length() gt 0}"> + <j:set var="completecp" value="${completecp}${osCPSeparator}${dep.getValue()}"/> + </j:if> + <j:if test="${completecp.length() == 0}"> + <j:set var="completecp" value="${dep.getValue()}"/> + </j:if> + </j:forEach> + </j:if> + <ant:echo message="Complete classpath is:[${completecp}]"/> + + <ant:copy todir="${maven.uber.dist.assembly.dir}" filtering="true" > <ant:filterset id="arifact_id.filter"> <ant:filter token="artifact_id" value="${maven.final.name}.jar"/> + <ant:filter token="pom-artifacts" value="${completecp}"/> </ant:filterset> <ant:fileset dir="${scripts_dir}" includes="${maven.uber.dist.launch.scripts}"> <exclude name="target/**,${maven.src.dir}/**"/> |