Coverage Report - com.aurea.maven.plugins.sonic.esb.EsbDxsiPackageMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
EsbDxsiPackageMojo
0%
0/16
0%
0/2
1.333
 
 1  
 package com.aurea.maven.plugins.sonic.esb;
 2  
 
 3  
 import java.io.File;
 4  
 import java.util.List;
 5  
 
 6  
 import org.codehaus.plexus.util.FileUtils;
 7  
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 8  
 
 9  
 import com.aurea.maven.plugins.sonic.utils.FileUtilities;
 10  
 import com.aurea.maven.plugins.sonic.utils.ZipUtilities;
 11  
 
 12  
 /**
 13  
  * packages the results of a DXSI Maven Project build in a Sonic ESB .xar file in a .zip distributable.
 14  
  * 
 15  
  * @goal dxsi-package
 16  
  */
 17  
 
 18  0
 public class EsbDxsiPackageMojo extends EsbPackageMojo {
 19  
 
 20  
 
 21  
   /**
 22  
    * DXSI directory under target.
 23  
    * 
 24  
    * @parameter default-value="target/generated-resources/dxsi/deployable"
 25  
    * @readonly
 26  
    */
 27  
   protected File targetDxsiDir;
 28  
   
 29  
   /**
 30  
    * DXSI unpack directory under target.
 31  
    * 
 32  
    * @parameter default-value="target/generated-resources/dxsi/unpack"
 33  
    * @readonly
 34  
    */
 35  
   protected File unpackDxsiDir;
 36  
 
 37  
   @Override
 38  
   protected File createXarFile() throws Exception {
 39  
 
 40  
         //Need to find all the xar files in the deployable directory  
 41  
         // extract the xar files found. The reason for this is that the new DXSI Packager can create multiple .xar files.
 42  0
             String[] xarExtension = {
 43  
               "xar"
 44  
             };
 45  0
             String[] xarFiles = FileUtils.getFilesFromExtension(targetDxsiDir.getPath(), xarExtension);
 46  0
             for (String xarFilename : xarFiles) {
 47  0
               ZipUtilities.doUnzipAction(xarFilename, unpackDxsiDir.getPath());
 48  
             }
 49  
           
 50  0
           FileUtilities.copyFiles(unpackDxsiDir.getCanonicalPath(), getPackageXarDir() + "", "**/*",
 51  
                         getXarExcludePatterns(), "", false);
 52  
 //
 53  
 //    // now call the default behaviour
 54  0
     return super.createXarFile();
 55  
   }
 56  
 
 57  
   @Override
 58  
   protected void addArtifactReplaceRules(final List<Xpp3Dom> _replaceRules) {
 59  
 
 60  
     // there shouldn't be anything under /src/main, so we don't need the following
 61  
     // super.addArtifactReplaceRules(replaceRules);
 62  
 
 63  
    // String originalValue = "sonicfs:///workspace/" + getProjectName() + getTargetDxsiDirRelativeToBasedir();
 64  
    // String updatedValue = "sonicfs:///" + getSonicFSProjectDir();
 65  
     
 66  0
     String originalValue = "sonicfs:///DataXtend/" + getProjectName();
 67  0
     String updatedValue = "sonicfs:///"
 68  
                         + getSonicFSProjectRoot() + "/"
 69  
                         + getGroupId().replace(".", "/") + "/"
 70  
                         + getArtifactId() + "/"
 71  
                         + getVersion();
 72  
 
 73  0
     Xpp3Dom projectReplace = new Xpp3Dom("stringReplaceMap");
 74  0
     projectReplace.setAttribute("name", originalValue);
 75  0
     projectReplace.setAttribute("updatedName", updatedValue);
 76  0
     _replaceRules.add(projectReplace);
 77  0
     getLog().info("Adding stringReplaceMap: " + originalValue + " -> " + updatedValue);
 78  
 
 79  0
   }
 80  
 
 81  
   private String getTargetDxsiDirRelativeToBasedir() {
 82  
 
 83  0
     return targetDxsiDir.getAbsolutePath().replace(project.getBasedir().getAbsolutePath(), "").replace("\\", "/");
 84  
   }
 85  
 
 86  
 }