Coverage Report - com.aurea.maven.plugins.sonic.sdm.SdmPackageMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
SdmPackageMojo
0%
0/15
0%
0/2
4
 
 1  
 package com.aurea.maven.plugins.sonic.sdm;
 2  
 
 3  
 import java.io.File;
 4  
 
 5  
 import org.apache.maven.plugin.MojoExecutionException;
 6  
 import org.apache.maven.plugin.MojoFailureException;
 7  
 import org.codehaus.plexus.archiver.Archiver;
 8  
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 9  
 import org.codehaus.plexus.util.FileUtils;
 10  
 
 11  
 import com.aurea.maven.plugins.sonic.sdm.container.impl.DefaultContainerMap;
 12  
 
 13  
 /**
 14  
  * This Mojo is responsible for packaging the generated SDM Model.
 15  
  * 
 16  
  * @goal sdm-package
 17  
  */
 18  
 
 19  
 // TODO: Implement a SDM SDO ????
 20  0
 public class SdmPackageMojo extends AbstractSdmMojo {
 21  
   
 22  
         /**
 23  
          * Booelan to determine the extra generation of a properties file .....
 24  
          * 
 25  
          * @parameter property="sonicesb.forcePropertyGeneration" 
 26  
          *                           default-value="false"
 27  
          * @required
 28  
          */
 29  
         protected boolean forcePropertyGeneration ;
 30  
         
 31  
         
 32  
   /**
 33  
    * The Sonic ESB Container Definition.
 34  
    * 
 35  
    * @parameter default-value="src/main/sonicesb/ContainerProperties.xml"
 36  
    * @required
 37  
    */
 38  
   protected File                    containerPropFile;
 39  
   
 40  
   /**
 41  
    * Queue mappings file, to map queues to Queues elements in the model.
 42  
    * 
 43  
    * @parameter default-value="src/main/sonicesb/QueueMappings.xml"
 44  
    * @required
 45  
    */
 46  
   protected File                    queueMappingsFile;
 47  
   
 48  
   /**
 49  
    * To look up Archiver/UnArchiver implementations.
 50  
    * 
 51  
    * @component
 52  
    * @required
 53  
    */
 54  
   protected ArchiverManager         archiverManager;
 55  
   
 56  
   /**
 57  
    * @parameter
 58  
    * @required
 59  
    */
 60  
   protected DefaultContainerMap     containerMap;
 61  
   
 62  
   
 63  
   /**
 64  
    * This method is called from the framework to actually perform the work.
 65  
    * 
 66  
    * @throws MojoExecutionException
 67  
    *           MojoExecutionException
 68  
    * @throws MojoFailureException
 69  
    *           MojoFailureException
 70  
    */
 71  
   protected void doExecute() throws MojoExecutionException, MojoFailureException {
 72  
 
 73  
 //          String[] excludeFiles;
 74  0
           String[] excludeFiles = { getGeneratedPropertiesFile().getName() };
 75  0
           if(forcePropertyGeneration){        
 76  0
                    excludeFiles[0] = "";
 77  
           }
 78  
     try {
 79  
       
 80  
       // package everything up in one archive. That archive is THE maven artifact that will be deployed, installed etc.
 81  0
       File sdmFile = new File(getOutputDirectory(), getFinalAssemblyFileName());
 82  0
       Archiver archiver = archiverManager.getArchiver("zip");
 83  0
       archiver.setDestFile(sdmFile);
 84  0
       archiver.addDirectory(getTargetSDMDir(), null, excludeFiles);
 85  0
       archiver.createArchive();
 86  0
       project.getArtifact().setFile(sdmFile);
 87  
 
 88  0
       FileUtils.forceDelete ( new File("target" + File.separatorChar + "unzip"));
 89  0
     } catch (Exception e) {
 90  0
       throw new MojoExecutionException("Error creating SDM Model - " + e.getMessage(), e);
 91  0
     }
 92  
     
 93  
     //removing the unzip directory
 94  0
   }
 95  
   
 96  
 }