You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/03/12 04:47:19 UTC

cvs commit: jakarta-turbine-maven/src/plugins-build/plexus sea-tar plugin.jelly

jvanzyl     2003/03/11 19:47:19

  Modified:    src/plugins-build/plexus plugin.jelly
  Added:       src/plugins-build/plexus sea-tar
  Log:
  o Using native commands to build the SEA as the ant tar requires too much
    fiddling to get perms right in arbitrarily included directories. Hopefully
    this will make SEAs work on each *NIX platform as expected. Only tested
    on linux.
  
  Revision  Changes    Path
  1.11      +85 -271   jakarta-turbine-maven/src/plugins-build/plexus/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/plexus/plugin.jelly,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- plugin.jelly	11 Mar 2003 17:32:04 -0000	1.10
  +++ plugin.jelly	12 Mar 2003 03:47:19 -0000	1.11
  @@ -1,291 +1,105 @@
  +<?xml version="1.0"?>
  +
   <project 
  -  xmlns:j="jelly:core" 
  -  xmlns:maven="jelly:maven"
  -  xmlns:util="jelly:util"
  +  xmlns:j="jelly:core"
     xmlns:define="jelly:define"
  -  xmlns:reactor="reactor"
  -  xmlns:deploy="deploy"
  -  xmlns:sea="sea"
  -  xmlns:velocity="jelly:org.apache.commons.jelly.tags.velocity.VelocityTagLibrary"
  -  xmlns:plexus="jelly:org.apache.maven.plexus.jelly.PlexusTagLibrary">
  +  xmlns:maven="jelly:maven">
  +
  +  <!-- ================================================================== -->
  +  <!-- S E L F  C O N T A I N E D  A R C H I V E                          -->
  +  <!-- ================================================================== -->
  +  <!-- Create a self contained archive for Unix systems which understand  -->
  +  <!-- the tar and gzip commands.                                         -->
  +  <!--                                                                    -->
  +  <!-- NOTE: This is a first attempt so I'm sure some adjustments will    -->
  +  <!-- have to be made for other Unices. I only use Linux.                -->
  +  <!-- ================================================================== -->
   
     <!--
      |
  -   | P L E X U S
  +   | Usage:
  +   |
  +   | <sea:create
  +   |   sourceDirectory="/path/to/contents"
  +   |   seaName="foo"
  +   | />
      |
  -   | o Create a plexus project.
  -   | o Create a runtime based on a configuration.
  -   | o Update the runtime based on an updated configuration.
  -   | o Generate a reactor for component builds.
  -   | o Generate a stub component with testing facilities.
  -   | o Leave hooks for processes to allow for things like insertion of webapps
  -   |   or other artifacts that are the product of another build.
  -   | o Generate reports on the state of the overall project.
  +   | This will produce a self extracting file called foo.sh in
  +   | ${maven.build.dir} which contains the contents of ${sourceDirectory}.
      |
      -->
   
  -  <!-- ===================================================================== -->
  -  <!-- D E P L O Y  P L E X U S                                              -->
  -  <!-- ===================================================================== -->
  -  <!-- Deploys Plexus into a self-contained directory that allows you        -->
  -  <!-- to run Plexus easily.                                                 -->
  -  <!-- ===================================================================== -->
  -
  -  <goal name="plexus:deploy" description="Deploys Plexus into a self-contained directory">
  -    
  -    <!-- Create the directory structure for the deployed application -->
  -    
  -    <delete dir="${maven.plexus.runtimeDirectory}"/>
  -    
  -    <mkdir dir="${maven.plexus.bin}"/>
  -    <mkdir dir="${maven.plexus.conf}"/>
  -    <mkdir dir="${maven.plexus.components}"/>
  -    <mkdir dir="${maven.plexus.lib}"/>
  -    <mkdir dir="${maven.plexus.appLib}"/>
  -    <mkdir dir="${maven.plexus.work}"/>
  -            
  -    <mkdir dir="${maven.plexus.components}"/>
  -
  +  <define:taglib uri="sea">
       <!--
        |
  -     | Create a project object from the Plexus POM so that we can glean
  -     | the required information about Plexus.
  +     | @sourceDirectory
  +     | @seaName
  +     | @workdir
  +     | @notice
        |
        -->
  +    <define:tag name="create">
       
  -    <maven:pom 
  -      projectDescriptor="${maven.plexus.pom}"
  -      var="plexusPom"/>
  -
  -    <j:set 
  -      var="plexusJar"
  -      value="${maven.repo.local}/plexus/jars/${plexusPom.artifactId}-${plexusPom.currentVersion}.jar"/>
  -
  -    <util:available file="${plexusJar}">
  -      <j:set var="plexusJarPresent" value="true"/>
  -      <copy file="${plexusJar}" todir="${maven.plexus.lib}"/>
  -    </util:available>
  -  
  -    <j:if test="${plexusJarPresent != 'true'}">
  -      <get 
  -        src="http://www.ibiblio.org/maven/plexus/jars/${plexusPom.artifactId}-${plexusPom.currentVersion}.jar"
  -        dest="${maven.plexus.lib}"/>
  -    </j:if>
  -
  -    <!--
  -     |
  -     | Now we need to pull down Plexus' dependencies to satisfy runtime
  -     |  requirements.
  -     |
  -     -->
  -    
  -    <echo>Retrieving any missing Plexus dependencies ... </echo>
  -    
  -    ${plexusPom.verifyDependencies()}
  -    
  -    <!-- Copy the plexus dependencies into the runtime lib/. -->
  -    
  -    <deploy:copy-deps 
  -      projectDescriptor="${maven.plexus.pom}"
  -      todir="${maven.plexus.lib}"
  -      excludes="junit"/>
  -    
  -    <!-- Create the classworlds configuration. -->
  -    <attainGoal name="classworlds-configuration"/>
  -    
  -    <!-- Create the startup shell script. -->
  -    <attainGoal name="startup-shell-script"/>
  -    
  -    <attainGoal name="plexus:find-components"/>
  -    
  -    <copy 
  -      file="${conf}" 
  -      tofile="${maven.plexus.conf}/plexus.conf" 
  -      overwrite="true"/>
  -    
  -    <delete>
  -      <fileset dir="${maven.plexus.appLib}">
  -        <include name="plexus-*.jar"/>
  -      </fileset>
  -    </delete>
  -
  -    <!--
  -     |
  -     | Include the JRE if specified. This is useful for applications
  -     | that need to be completely self-contained.
  -     |
  -     -->
  -     
  -    <j:if test="${jre == 'true'}">
  -      <exec 
  -        executable="cp">
  -        <arg value="-r"/>
  -        <arg value="${java.home}"/>
  -        <arg value="${maven.plexus.jre}"/>
  -      </exec>
  -    </j:if>
  -      
  -  </goal>
  -
  -  <!-- ===================================================================== -->
  -  <!-- F I N D  C O M P O N E N T S                                          -->
  -  <!-- ===================================================================== -->
  -  <!--                                                                       -->
  -  <!-- ===================================================================== -->
  -
  -  <goal name="plexus:find-components">
  -    <plexus:find-implementations var="implementations" configuration="${conf}"/>
  -
  -    <get 
  -      src="http://www.ibiblio.org/maven/plexus/plexus-component.manifest"
  -      dest="${plugin.dir}/plexus-component.manifest"/>
  -
  -    <util:properties 
  -      uri="file:${plugin.dir}/plexus-component.manifest" 
  -      var="components"/>
  -    
  -    <j:set var="pomDir" value="tmpPoms"/>
  -    <mkdir dir="${pomDir}"/>
  -     
  -    <j:forEach var="implementation" items="${implementations}">
  -    
  -      <echo> implementation = '${implementation}' </echo>
  -      
  -      <j:set var="component" value="${components.getProperty(implementation)}"/>
  -      <j:if test="${component.length() > 0}">
  -      
  -        <echo> component = '${component}' </echo>
  -
  -        <j:set 
  -          var="pom" 
  -          value="${maven.repo.local}/plexus/poms/${component}.pom"/>
  -      
  -        <j:set var="pomPresent" value="false"/>
  -        <util:available file="${pom}">
  -          <j:set var="pomPresent" value="true"/>
  -          <copy file="${pom}" todir="${pomDir}"/>
  -        </util:available>
  +      <mkdir dir="${maven.build.dir}"/>
         
  -        <j:if test="${pomPresent != 'true'}">
  -          <get 
  -            src="http://www.ibiblio.org/maven/plexus/poms/${component}.pom"
  -            dest="${pomDir}/${component}.pom"/>
  -        </j:if>
  -      </j:if>
  -    </j:forEach>
  -
  -    <!--
  -     |
  -     | Now we have the components. Let's get their dependencies.
  -     |
  -     -->
  -       
  -    <fileScanner var="poms">
  -      <fileset dir="${pomDir}"/>
  -    </fileScanner>
  -
  -    <j:forEach var="depPomFile" items="${poms.iterator()}">
  -      <maven:pom projectDescriptor="${depPomFile}" var="depPom"/>
  -      
  -      <echo>Verifying dependencies for ${depPom.artifactId} ...</echo>
  -      
  -      <j:set 
  -        var="artifact" 
  -        value="${maven.repo.local}/plexus/jars/${depPom.artifactId}-${depPom.currentVersion}.jar"/>
  +      <!-- 
  +       |
  +       | Work around for Ant requiring specifics on which files get
  +       | special perm treatment. When including the JRE the Ant tar task makes
  +       | it very difficult to get the perms correct in the include JRE
  +       | directory.
  +       |
  +       -->
  +      
  +      <chmod
  +        file="${pom.getPluginContext('maven-sea-plugin').getVariable('plugin.dir')}/sea-tar"
  +        perm="+x"/>
  +      
  +      <exec
  +        executable="${pom.getPluginContext('maven-sea-plugin').getVariable('plugin.dir')}/sea-tar">
  +        <arg value="${seaName}"/>
  +        <arg value="${sourceDirectory}"/>
  +        <arg value="${maven.build.dir}"/>
  +      </exec>
         
  -      <util:available file="${artifact}">
  -        <j:set var="depPresent" value="true"/>
  -        <copy file="${artifact}" todir="${maven.plexus.components}"/>
  -      </util:available>
  +      <filter token="NOTICE" value="${pom.name} v${pom.currentVersion} - starting installation... please wait"/>
  +      <filter token="WORK_DIR" value="${pom.artifactId}-${pom.currentVersion}"/>
         
  -      <j:if test="${depPresent != 'true'}">
  -        <get 
  -          src="http://www.ibiblio.org/maven/plexus/jars/${depPom.artifactId}-${depPom.currentVersion}.jar"
  -          dest="${maven.plexus.components}/${depPom.artifactId}-${depPom.currentVersion}.jar"/>
  -      </j:if>
  +      <copy 
  +        file="${pom.getPluginContext('maven-sea-plugin').getVariable('plugin.resources')}/sea-header"
  +        tofile="${maven.build.dir}/project-sea-header"
  +        overwrite="true"
  +        filtering="true"
  +      />
  +      
  +      <!--
  +       |
  +       | Concatenate the sea-header with the tarball we just made.
  +       |
  +       -->
  +      <maven:concat outputFile="${maven.build.dir}/${seaName}.sh">
  +        <maven:input file="${maven.build.dir}/project-sea-header"/>
  +        <maven:input file="${maven.build.dir}/${seaName}.tar.gz"/>
  +      </maven:concat>
  +      
  +      <!--
  +       |
  +       | Flip on the +x bit so all users have to do is run it!
  +       |
  +       -->
  +      <chmod file="${maven.build.dir}/${seaName}.sh" perm="+x"/>
  +      
  +      <!--
  +       |
  +       | The archive has been packaged up in a self-extracting ball
  +       | so we don't need the originals anymore.
  +       |
  +       -->
  +      <delete file="${maven.build.dir}/${seaName}.tar"/>
  +      <delete file="${maven.build.dir}/${seaName}.tar.gz"/>
  +      <delete file="${maven.build.dir}/project-sea-header"/>
   
  -      ${depPom.verifyDependencys()}
  -      
  -      <deploy:copy-deps 
  -        projectDescriptor="${depPomFile}"
  -        todir="${maven.plexus.appLib}"
  -        excludes="junit"/>
  -        
  -    </j:forEach>
  -    
  -    <delete dir="${pomDir}"/>
  -    
  -  </goal>
  +    </define:tag>
  +  </define:taglib>
     
  -
  -  <!-- ===================================================================== -->
  -  <!-- B U I L D  C O M P O N E N T S                                        -->
  -  <!-- ===================================================================== -->
  -
  -  <goal name="build-components" description="build components">
  -
  -    <maven:maven
  -      basedir="${basedir}/component-builds"
  -      descriptor="${basedir}/component-builds/project.xml"
  -      goals="build"
  -      ignoreFailures="false"
  -    />
  -
  -  </goal>
  -
  -  <!-- ===================================================================== -->
  -  <!-- G E N E R A T E  L A U N C H E R  C O N F I G U R A T I O N           -->
  -  <!-- ===================================================================== -->
  -
  -  <goal 
  -    name="classworlds-configuration" 
  -    description="Generate launcher configuration">
  -    
  -    <maven:pom 
  -      projectDescriptor="${maven.plexus.pom}" 
  -      var="project"/>
  -    
  -    <velocity:merge
  -      name="${maven.plexus.conf}/${maven.plexus.launcherConfiguration}"
  -      basedir="${maven.plexus.templatePath}"
  -      template="${maven.plexus.launcherConfigurationTemplate}"/>
  -
  -  </goal>
  -
  -  <!-- ===================================================================== -->
  -  <!-- G E N E R A T E  S T A R T E R  S C R I P T                           -->
  -  <!-- ===================================================================== -->
  -
  -  <goal 
  -    name="startup-shell-script" 
  -    description="Generate starter script">
  -
  -    <velocity:merge
  -      name="${maven.plexus.bin}/plexus.sh"
  -      basedir="${maven.plexus.templatePath}"
  -      template="plexus.vm"/>
  -
  -    <velocity:merge
  -      name="${maven.plexus.bin}/plexus.bat"
  -      basedir="${maven.plexus.templatePath}"
  -      template="plexus-bat.vm"/>
  -
  -    <chmod file="${maven.plexus.bin}/plexus.sh" perm="+x"/>
  -    
  -  </goal>
  -
  -  <!-- ===================================================================== -->
  -  <!-- G E N E R A T E  S E A                                                -->
  -  <!-- ===================================================================== -->
  -
  -  <goal name="plexus:sea">
  -    
  -    <attainGoal name="plexus:deploy"/>
  -    
  -    <sea:create
  -      sourceDirectory="${maven.plexus.runtimeDirectory}"
  -      seaName="plexus"
  -    />
  -  </goal>
  -
   </project>
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/plexus/sea-tar
  
  Index: sea-tar
  ===================================================================
  #!/bin/sh
  
  SEA_NAME=$1
  SOURCE_DIRECTORY=$2
  TARGET_DIR=$3
  
  tar -cvzf ${TARGET_DIR}/${SEA_NAME}.tar.gz -C ${SOURCE_DIRECTORY} `ls ${SOURCE_DIRECTORY}`