From: Eric G. <ri...@us...> - 2005-03-02 17:45:47
|
rikgig 05/03/02 09:45:39 Added: uberdist plugin.jelly plugin.properties project.xml Log: First commit. Moved from uber-dist sf project and adapted as a sub project Revision Changes Path 1.1 maven-plugins/uberdist/plugin.jelly Index: plugin.jelly =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <!-- /* * Copyright 2004-2005 Eric Giguere * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * 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"> <!-- 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"> <define:tag name="deregisterProject"> <!-- @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)}"> <j:set var="removeProject" value="${proj}"/> </j:if> </j:forEach> <j:if test="${removeProject != null}"> <j:set var="dummy" value="${projects.remove(removeProject)}"/> </j:if> </define:tag> <define:tag name="registerProject"> <!-- @name the name of this project. @description text description of project --> <maven:pluginVar var="projects" plugin="maven-uberdist-plugin" property="projects" /> <!-- check if the given name is in the list already --> <j:set var="add" value="true"/> <j:forEach var="proj" items="${projects}"> <j:if test="${proj.get('name').equals(name)}"> <j:set var="add" value="false"/> </j:if> </j:forEach> <j:if test="${add.equals('true')}"> <echo>Registering project: ${name}</echo> <j:new var="project" className="java.util.HashMap"/> <j:set var="dummy"> ${project.put('name', name)} ${project.put('description', description)} ${projects.add(project)} </j:set> </j:if> </define:tag> <define:tag name="copyScripts"> <!-- @scriptsDirectory : Directory where to look for scripts --> <echo message="installScripts from: ${scriptsDirectory}"/> <maven:set property="maven.uber.dist.scripts.dir" plugin="maven-uberdist-plugin" value="${scriptsDirectory}"/> <attainGoal name="uber-dist:copy-scripts"/> </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)"> <condition property="isOnUnix"> <or> <os family="unix"/> <os name="SunOS"/> </or> </condition> <j:if test="${isOnUnix == 'true'}"> <echo message="Building distribution from a Unix based box"/> </j:if> </goal> <goal name="uber-dist:clean-dist-filesystem" description="Delete existing distribution directories to build a new distribution" prereqs="uber-dist:dist-setup"> <j:choose> <j:when test="${maven.uber.dist.assembly.dir.length()!=0}"> <ant:echo>Deleting distribution directory : ${maven.uber.dist.assembly.dir}</ant:echo> <ant:delete dir="${maven.uber.dist.assembly.dir}"/> </j:when> <j:otherwise> <fail>maven.uber.dist.assembly.dir empty. Abort</fail> </j:otherwise> </j:choose> <j:choose> <echo message="Deleting distribution..."/> <j:when test="${isOnUnix == 'true'}"> <ant:delete file="${maven.uber.dist.dir}/${maven.final.name}.tar.gzip"/> </j:when> <j:otherwise> <ant:delete file="${maven.uber.dist.dir}/${maven.final.name}.zip"/> </j:otherwise> </j:choose> </goal> <!-- Create a tar.gz file and zip distribution --> <goal name="uber-dist:create-distrib"> <ant:echo>Creating tarball on dir:${maven.uber.dist.assembly.dir}</ant:echo> <j:choose> <j:when test="${isOnUnix == 'true'}"> <echo message="Tar on Unix box..."/> <!-- Create a gzipped tarball for Unix systems --> <ant:exec executable="tar"> <arg line=" -vcf ${maven.uber.dist.dir}/${maven.final.name}.tar -C ${maven.uber.dist.assembly.dir} ."/> </ant:exec> <ant:gzip zipfile="${maven.uber.dist.dir}/${maven.final.name}.tar.gz" src="${maven.uber.dist.dir}/${maven.final.name}.tar"/> <ant:delete file="${maven.uber.dist.dir}/${maven.final.name}.tar"/> </j:when> <j:otherwise> <echo message="Non-Unix box, zipping distribution"/> <!-- Create a zip file --> <ant:zip zipfile="${maven.uber.dist.dir}/${maven.final.name}.zip"> <ant:zipfileset dir="${maven.uber.dist.assembly.dir}"/> </ant:zip> </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> </j:forEach> <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> </goal> <goal name="uber-dist:build" description="This goal is used to create from scratch a binary distribution. Like make, it will build the distribution assembly in the dist-assembly dir (under target) but unlike uber-dist:make, this goal calls the goal clean before any other"> <attainGoal name="clean"/> <attainGoal name="uber-dist:init"/> <attainGoal name="uber-dist:prepare-dist-filesystem"/> <attainGoal name="uber-dist:create-distrib"/> </goal> <goal name="uber-dist:make" description="This goal is used to create a binary distribution. Difference between this one and uber-dist:build is that the make will not destroy the target directory but will remove the dist-assembly directory of the project to rebuild it" prereqs="uber-dist:init"> <attainGoal name="uber-dist:prepare-dist-filesystem"/> <attainGoal name="uber-dist:create-distrib"/> </goal> <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'"> <!-- 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> <!-- 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}"/> </ant:fileset> </ant:copy> </j:forEach> </j:if> </goal> <goal name="uber-dist:make-executable" prereqs="uber-dist:init" description="This goal is used to change file permission in a distribution assembly when its created on Unix based systems. By default, only the *.sh and *.so files are changed. We add, by default, x permissions on group and user only. The default values can be overriden by plugin properties NOTE: Only executed when the build is done on a Unix based system."> <j:set var="permission" value="${maven.uber.dist.executable.permission}"/> <j:if test="${persmission=='' or permission==null}"> <j:set var="permission" value="gu+x"/> </j:if> <j:set var="includes" value="${maven.uber.dist.executable.includes}"/> <echo message="Using permissions: ${permission} and includes: ${includes}"/> <ant:chmod dir="${maven.uber.dist.assembly.dir}" perm="${permission}" includes="${includes}"/> </goal> <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"> <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"/> <maven:get var="scripts_pattern" plugin="maven-uberdist-plugin" property="maven.uber.dist.launch.scripts"/> <j:set var="isOkToGo" value="true"/> <j:if test="${scripts_dir==null or scripts_dir==''}"> <ant:echo message="No maven.uber.dist.scripts.dir specified, skipping copy-scripts"/> <j:set var="isOkToGo" value="false"/> </j:if> <j:if test="${scripts_pattern==null or scripts_pattern==''}"> <ant:echo message="File pattern for launch scripts empty, skipping copy-scripts"/> <j:set var="isOkToGo" value="false"/> </j:if> <j:if test="${dest_dir==null or dest_dir==''}"> <ant:echo message="Destination path not set, skipping copy-scripts"/> <j:set var="isOkToGo" value="false"/> </j:if> <j:if test="${isOkToGo == 'true'}"> <echo> 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" > <ant:filterset id="arifact_id.filter"> <ant:filter token="artifact_id" value="${maven.final.name}.jar"/> </ant:filterset> <ant:fileset dir="${scripts_dir}" includes="${maven.uber.dist.launch.scripts}"> <exclude name="target/**,${maven.src.dir}/**"/> </ant:fileset> </ant:copy> </j:if> </goal> </project> 1.1 maven-plugins/uberdist/plugin.properties Index: plugin.properties =================================================================== # ------------------------------------------------------------------- # Copyright 2004-2005 Eric Giguere # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ------------------------------------------------------------------- # ------------------------------------------------------------------- # P L U G I N P R O P E R I E S # ------------------------------------------------------------------- maven.uber.dist.assembly.root=${maven.build.dir}/dist-assembly maven.uber.dist.dir=${maven.build.dir}/distributions maven.uber.dist.proj.subdir= maven.uber.dist.assembly.dep.subdir= maven.uber.dist.assembly.dir=${maven.uber.dist.assembly.root}/${maven.uber.dist.proj.subdir} maven.uber.dist.executable.permission=gu+x maven.uber.dist.executable.includes=**/*.sh,**/*.so maven.uber.dist.launch.scripts=*.sh,*.cmd,*.bat 1.1 maven-plugins/uberdist/project.xml Index: project.xml =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <!-- /* * Copyright 2004-2005 Eric Giguere. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <!-- The master project file all subprojects inherit this project.xml file. --> <project> <extend>${basedir}/../plugin-project.xml</extend> <id>maven-uberdist-plugin</id> <name>Maven UberDist Plugin</name> <!-- groupId is in parent --> <currentVersion>1.0.10</currentVersion> <!-- organization is in parent --> <!-- logo is in parent. no gumpRepositoryId --> <inceptionYear>2004</inceptionYear> <shortDescription>Distribution plugin for multiple projects</shortDescription> <siteDirectory> /home/groups/m/ma/maven-plugins/htdocs/maven-transform-plugin/ </siteDirectory> <distributionDirectory> /home/groups/m/ma/maven-plugins/htdocs/maven-transform-plugin/distributions/ </distributionDirectory> <repository> <connection> scm:cvs:pserver:ano...@cv...:/cvsroot/maven-plugins:maven-plugins/transform </connection> <developerConnection> scm:cvs:ext:${maven.username}@cvs.sourceforge.net:/cvsroot/maven-plugins:maven-plugins/transform </developerConnection> <url> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/maven-plugins/maven-plugins/transform/ </url> </repository> <!-- mailingLists is in parent --> <developers> <developer> <name>Eric Giguere</name> <id>rikgig</id> <email>ri...@us...</email> </developer> </developers> <dependencies/> <versions> <version> <id>1.0.10</id> <name>1.0.10</name> <tag>UBER-DIST-1_0_10</tag> </version> </versions> <!-- build is in the parent --> <!-- <build> <sourceDirectory>src/java</sourceDirectory> <unitTestSourceDirectory>test/java</unitTestSourceDirectory> <resources> <resource> <directory>${basedir}/src/plugin-resources</directory> <targetPath>plugin-resources</targetPath> </resource> <resource> <directory>${basedir}</directory> <includes> <include>plugin.jelly</include> <include>plugin.properties</include> <include>project.properties</include> <include>project.xml</include> </includes> </resource> </resources> </build> --> <reports> <report>maven-changes-plugin</report> <report>maven-linkcheck-plugin</report> <report>maven-faq-plugin</report> </reports> </project> |