[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-cvs-commits
Subject:    [jboss-cvs] jbossbuild/src/main/org/jboss/ant/tasks/build  ...
From:       Ruel Loehr <ruel.loehr () jboss ! com>
Date:       2005-10-31 20:12:53
Message-ID: E1EWg1V-0000Qb-JD () committer01 ! frg ! pub ! inap ! atl ! jboss ! com
[Download RAW message or body]

  User: rloehr  
  Date: 05/10/31 15:12:53

  Modified:    src/main/org/jboss/ant/tasks/build  Tag: BRANCH_JBBUILD_DEV
                        ReleaseDeploymentsTask.java
  Log:
  JBBUILD-175 - introduce notion of profiles
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +175 -72   \
jbossbuild/src/main/org/jboss/ant/tasks/build/Attic/ReleaseDeploymentsTask.java  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ReleaseDeploymentsTask.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossbuild/src/main/org/jboss/ant/tasks/build/Attic/ReleaseDeploymentsTask.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -b -r1.1.2.1 -r1.1.2.2
  --- ReleaseDeploymentsTask.java	26 Oct 2005 21:10:06 -0000	1.1.2.1
  +++ ReleaseDeploymentsTask.java	31 Oct 2005 20:12:53 -0000	1.1.2.2
  @@ -12,18 +12,19 @@
   import org.apache.tools.ant.taskdefs.Copy;
   import org.apache.tools.ant.taskdefs.Expand;
   import org.apache.tools.ant.taskdefs.Mkdir;
  +import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.util.JavaEnvUtils;
   import org.jboss.ant.types.build.Artifact;
   import org.jboss.ant.types.deployment.Deployment;
  -import org.jboss.ant.types.deployment.DeploymentProfile;
  +import org.jboss.ant.types.deployment.DeploymentType;
  +import org.jboss.ant.types.deployment.Profile;
   import org.jboss.ant.util.FileUtil;
   
  -
   /**
  - * A ReleaseDeploymentsTask.
  + * A Task which releases items to the appropriate locations.
    * 
    * @author <a href="ruel.loehr@jboss.com">Ruel Loehr</a>
  - * @version $Revision: 1.1.2.1 $
  + * @version $Revision: 1.1.2.2 $
    */
   public class ReleaseDeploymentsTask extends BuildTask
   {
  @@ -38,54 +39,140 @@
         super();
      }
      
  -   
  +   /**
  +    * Execute the task
  +    */
      public void execute()
      {
         this.setTaskName("ReleaseDeploymentsTask");
         
  +      if (log.isTraceEnabled())
  +         log.trace("Executing: " + this.getTaskName());
  +      
         if (this.getBuildInstance() != null)
         {
  -         for (int i=0; i<this.getBuildInstance().getDeploymentProfiles().size(); \
i++)  +         //for every profile in the build
  +         for (int i = 0; i < this.getBuildInstance().getProfiles().size(); i++)
            {
  -            DeploymentProfile currentDeploymentProfile = (DeploymentProfile) \
this.getBuildInstance().getDeploymentProfiles().elementAt(i);  +            Profile \
currentDeploymentProfile = (Profile) \
this.getBuildInstance().getProfiles().elementAt(i);  
               if (log.isTraceEnabled())
  -               log.trace("Deploying deploymentProfile with id: " + \
currentDeploymentProfile.getId());              +               log.trace("Deploying \
Profile with id: " + currentDeploymentProfile.getId());  +
  +            deployProfile(currentDeploymentProfile);
  +         }
  +
  +      }
  +      else
  +      {
  +         throw new BuildException("Build instance is null, unable to complete " + \
this.getTaskName());  +      }
  +   }
  +   
  +   /** Deploy a profile
  +    * 
  +    * @param profile
  +    */
  +   private void deployProfile(Profile profile)
  +   {
  +      File outputDir = FileUtil.resolve(this.getBuildInstance().getReleaseDir(), \
profile.getOutputPath());  
  -            for (int j=0; j<currentDeploymentProfile.getDeployments().size(); j++)
  +      //deploy all deployments in a profile
  +      for (int j = 0; j < profile.getDeployments().size(); j++)
               {
  -               Deployment currentDeployment = (Deployment) \
currentDeploymentProfile.getDeployments().elementAt(j);  +         Deployment \
currentDeployment = (Deployment) profile.getDeployments().elementAt(j);  +         
                  if (log.isTraceEnabled())
                     log.trace("Deploying deployment with artifact: " + \
currentDeployment.getArtifact());                 
  -               deployDeployment(currentDeployment);
  +         deployDeployment(currentDeployment, outputDir);
                                
               }
  +
  +      //deploy all deployment types
  +      for (int j = 0; j < profile.getDeploymentTypes().size(); j++)
  +      {
  +         DeploymentType currentDeploymentType = (DeploymentType) \
profile.getDeploymentTypes()  +               .elementAt(j);
  +         
  +         deployDeploymentType(currentDeploymentType, outputDir);
  +
            }        
            
         }
  -      else 
  +      
  +      
  +   /** Deploy a deploymentType to a given output directory
  +    * 
  +    * @param deploymentType
  +    * @param outputDir
  +    */
  +   private void deployDeploymentType(DeploymentType deploymentType, File \
outputDir)  {
  -         throw new BuildException("Build instance is null, unable to complete " + \
this.getTaskName());  +      //release these files only if the the jdkVersion matches \
  +      String version = JavaEnvUtils.getJavaVersion();
  +
  +      if ((!version.equalsIgnoreCase(deploymentType.getRequiredJDK()))
  +            && (!deploymentType.getRequiredJDK().equalsIgnoreCase("default")))
  +         return;
  +
  +      File typeOutputDir = FileUtil.resolve(outputDir, deploymentType.getType());
  +      
  +    
  +      if (log.isTraceEnabled())
  +         log.trace("Deploying deployment type: " + deploymentType.getType() + " to \
location " + outputDir.getAbsolutePath());  +      
  +      //deploy every deployment listed in the deployment type
  +      for (int k = 0; k < deploymentType.getDeployments().size(); k++)
  +      {
  +         Deployment currentDeployment = (Deployment) \
deploymentType.getDeployments()  +         .elementAt(k);
  +         
  +         if (log.isTraceEnabled())
  +            log.trace("Deploying deployment with artifact: " + \
currentDeployment.getArtifact());  +         
  +         deployDeployment(currentDeployment, typeOutputDir);
         }
  +      
  +       
  +      //deploy any additional deployment types
  +      for (int j = 0; j < deploymentType.getDeploymentTypes().size(); j++)
  +      {
  +         DeploymentType currentDeploymentType = (DeploymentType) \
deploymentType.getDeploymentTypes().elementAt(j);  +
  +         deployDeploymentType(currentDeploymentType, typeOutputDir);
  + 
      }   
      
  -   private void deployDeployment(Deployment deployment)
  +   }
  +
  +   /** Deploy a deployment to the given output location
  +    * 
  +    * @param deployment
  +    * @param outputDir
  +    */
  +   private void deployDeployment(Deployment deployment, File outputDir)
      {
         
  -      Artifact artifact=deployment.getArtifact();
  +      Artifact artifact = deployment.getArtifact();
               
  +      if (log.isTraceEnabled())
  +      {
  +         log.trace("Artifact retrieved from deployment has id: " + \
artifact.getId());  +         log.trace(artifact.getArtifactType().toString());
  +      }
         //release these files only if the the jdkVersion is match 
         String version = JavaEnvUtils.getJavaVersion();
         
  -      if ((version.equalsIgnoreCase(deployment.getRequiredJDK())) || \
(deployment.getRequiredJDK().equalsIgnoreCase("default")))  +      if \
((version.equalsIgnoreCase(deployment.getRequiredJDK()))  +            || \
(deployment.getRequiredJDK().equalsIgnoreCase("default")))  {
   
               //create the output directory 
               Mkdir mkdir = new Mkdir();
               mkdir.setTaskName("mkdir");
               mkdir.setProject(this.getProject());
  -            mkdir.setDir(FileUtil.resolve(this.getBuildInstance().getReleaseDir(), \
deployment.getOutputPath()));  +         mkdir.setDir(outputDir);
               mkdir.execute();
   
               //execute the exploded release
  @@ -95,7 +182,7 @@
                  Expand expand = new Expand();
                  expand.setTaskName("unzip");
                  expand.setProject(this.getProject());
  -               expand.setDest(FileUtil.resolve(this.getBuildInstance().getReleaseDir(), \
deployment.getOutputPath()));  +            expand.setDest(outputDir);
                  expand.setSrc(artifact.getOutput());
                  if (deployment.getOverwrite() != null)
                  {
  @@ -114,29 +201,45 @@
                  Copy copy = new Copy();
                  copy.setTaskName("copy");
                  copy.setProject(this.getProject());
  -               copy.setFile(artifact.getOutput());
  +            copy.setVerbose(true);
   
  +            //if we are copying a directory insert a fileset to perfrom the copy
  +            if (artifact.getArtifactType().type.equalsIgnoreCase("dir"))
  +            {
  +               FileSet f = new FileSet();
  +               f.setDir(artifact.getOutput());
  +               copy.addFileset(f);
                  if (deployment.getToName() != null)
                  {
                     File renameFile = \
FileUtil.resolve(this.getBuildInstance().getReleaseDir(), \
                deployment.getOutputPath());
                     renameFile = FileUtil.resolve(renameFile, \
                deployment.getToName());
  -                  copy.setTofile(renameFile);
  +                  copy.setTodir(renameFile);
                  }
                  else
                  {
  -                  File outputFileName = \
FileUtil.resolve(this.getBuildInstance().getReleaseDir(), \
                deployment.getOutputPath());
  -                  
  -                  copy.setTofile(FileUtil.resolve(outputFileName, \
artifact.getId()));  +                  copy.setTodir(FileUtil.resolve(outputDir, \
artifact.getId()));  }
   
  -
  +            }
  +            else    //we are just copying a single file
  +            {
  +            copy.setFile(artifact.getOutput());
  +            if (deployment.getToName() != null)
  +            {
  +               File renameFile = \
FileUtil.resolve(this.getBuildInstance().getReleaseDir(), \
deployment.getOutputPath());  +               renameFile = \
FileUtil.resolve(renameFile, deployment.getToName());  +               \
copy.setTofile(renameFile);  +            }
  +            else
  +            {
  +               copy.setTofile(FileUtil.resolve(outputDir, artifact.getId()));
  +            }
  +            }
                  copy.execute();
               }
           
         }      
         
  -      
      }
    
  -
   }
  
  
  


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic