Coverage report

  %line %branch
net.sf.infrared.tools.ant.ApplicationType
0% 
0% 

 1  
 /*
 2  
  * Copyright 2005 Tavant Technologies and Contributors
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License")
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  *
 16  
  *
 17  
  *
 18  
  * Original Author:  binil.thomas (Tavant Technologies)
 19  
  * Contributor(s):   -;
 20  
  *
 21  
  */
 22  
 package net.sf.infrared.tools.ant;
 23  
 
 24  
 import java.io.File;
 25  
 import java.io.IOException;
 26  
 import net.sf.infrared.tools.util.JarHelper;
 27  
 import org.apache.commons.io.FileUtils;
 28  
 import org.apache.tools.ant.BuildException;
 29  
 import org.apache.tools.ant.Project;
 30  
 
 31  
 /**
 32  
  *
 33  
  * @author binil.thomas
 34  
  */
 35  
 public abstract class ApplicationType {
 36  
     private Project project;
 37  
     
 38  
     private InfraRedTask parent;
 39  
     
 40  
     private File src;
 41  
     
 42  
     private File dest;
 43  
     
 44  
     private File workDir;
 45  
     
 46  
     private File backup;
 47  
     
 48  0
     private JarHelper jarHelper = new JarHelper();
 49  
     
 50  
     private Logger log;
 51  
     
 52  
     public void setLogger(Logger log) {
 53  0
         this.log = log;
 54  0
     }
 55  
     
 56  
     public Logger getLogger() {
 57  0
         return this.log;
 58  
     }
 59  
     
 60  0
     public ApplicationType(Project project) {
 61  0
         this.project = project;
 62  0
     }
 63  
     
 64  
     public void setSrc(File f) {
 65  0
         this.src = f;
 66  0
     }
 67  
     
 68  
     public File getSrc() {
 69  0
         return this.src;
 70  
     }
 71  
     
 72  
     public void setDest(File f) {
 73  0
         this.dest = f;
 74  0
     }
 75  
     
 76  
     public File getDest() {
 77  0
         return this.dest;
 78  
     }
 79  
     
 80  
     void setWorkDir(File d) {
 81  0
         this.workDir = d;
 82  0
     }
 83  
     
 84  
     File getWorkDir() {
 85  0
         return this.workDir;
 86  
     }
 87  
     
 88  
     void setParentTask(InfraRedTask parent) {
 89  0
         this.parent = parent;                
 90  0
     }
 91  
     
 92  
     InfraRedTask getParentTask() {
 93  0
         return this.parent;
 94  
     }
 95  
     
 96  
     protected Project getProject() {
 97  0
         return this.project;
 98  
     }
 99  
     
 100  
     public abstract void setup();
 101  
     
 102  
     public abstract void cleanup();
 103  
     
 104  
     public abstract File[] getJarsToInstrument();
 105  
     
 106  
     public abstract File[] getClassesToInstrument();
 107  
     
 108  
     public abstract String[] getPackagesToInstrument();
 109  
     
 110  
     public abstract File[] getApplicationClassPath();
 111  
     
 112  
     void backupSrcToWorkDir() {
 113  0
         getProject().log(getParentTask(), 
 114  
                 "Work Dir is " + getWorkDir().getAbsolutePath(), Project.MSG_VERBOSE);
 115  0
         backup = new File(getWorkDir(), src.getName());
 116  0
         getProject().log(getParentTask(), 
 117  
                 "Backup is " + backup.getAbsolutePath(), Project.MSG_VERBOSE);        
 118  0
         if (src.isFile()) {
 119  0
             uncompressSrcToDir(backup);
 120  
         } else {
 121  0
             copySrcToDir(backup);
 122  
         }        
 123  0
     }
 124  
     
 125  
     void copyBackupToDest() {
 126  0
         if (src.isDirectory()) {
 127  0
             copyBackupToDestDir();
 128  
         } else {
 129  0
             compressBackupToDest();
 130  
         }
 131  0
     }
 132  
     
 133  
     File getBackupDir() {
 134  0
         return this.backup;
 135  
     }
 136  
     
 137  
     void setBackupDir(File d) {
 138  0
         this.backup = d;
 139  0
     }
 140  
     
 141  
     void uncompressSrcToDir(File backup) {        
 142  
         try {
 143  0
             jarHelper.unjarDir(src, backup);
 144  0
         } catch (IOException ex) {
 145  0
             throw new BuildException("Failed to unarchive " + src.getAbsolutePath()
 146  
             + " to directory " + backup.getAbsolutePath(), ex);
 147  0
         }        
 148  0
     }
 149  
     
 150  
     void copySrcToDir(File backup) {
 151  
         try {            
 152  0
             FileUtils.copyDirectory(src, backup);
 153  0
         } catch (IOException ex) {
 154  0
             throw new BuildException("Failed to copy directory " + src.getAbsolutePath()
 155  
             + " to directory " + backup.getAbsolutePath(), ex);
 156  0
         }
 157  0
     }
 158  
     
 159  
     void compressBackupToDest() {
 160  
         try {
 161  0
             jarHelper.jarDir(getBackupDir(), getDest());
 162  0
         } catch (IOException ex) {
 163  0
             throw new BuildException("Failed to archive " + getBackupDir().getAbsolutePath()
 164  
             + " to " + getDest().getAbsolutePath(), ex);
 165  0
         }
 166  0
     }
 167  
     
 168  
     void copyBackupToDestDir() {
 169  
         try {            
 170  0
             FileUtils.copyDirectory(getBackupDir(), getDest());
 171  0
         } catch (IOException ex) {
 172  0
             throw new BuildException("Failed to copy directory " + getBackupDir().getAbsolutePath()
 173  
             + " to " + getDest().getAbsolutePath(), ex);
 174  0
         }
 175  0
     }
 176  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.