1 58 59 package net.sourceforge.cobertura.ant; 60 61 import java.io.IOException ; 62 63 import net.sourceforge.cobertura.util.CommandLineBuilder; 64 65 import org.apache.tools.ant.BuildException; 66 import org.apache.tools.ant.Project; 67 68 public class MergeTask extends CommonMatchingTask 69 { 70 71 private String dataFile = null; 72 73 public MergeTask() 74 { 75 super("net.sourceforge.cobertura.merge.Main"); 76 } 77 78 public void execute() throws BuildException { 79 CommandLineBuilder builder = null; 80 try { 81 builder = new CommandLineBuilder(); 82 if (dataFile != null) 83 builder.addArg("--datafile", dataFile); 84 85 createArgumentsForFilesets(builder); 86 87 builder.saveArgs(); 88 } catch (IOException ioe) { 89 getProject().log("Error creating commands file.", Project.MSG_ERR); 90 throw new BuildException("Unable to create the commands file.", ioe); 91 } 92 93 getJava().createArg().setValue("--commandsfile"); 95 getJava().createArg().setValue(builder.getCommandLineFile()); 96 AntUtil.transferCoberturaDataFileProperty(getJava()); 97 if (getJava().executeJava() != 0) { 98 throw new BuildException( 99 "Error running reports. See messages above."); 100 } 101 102 builder.dispose(); 103 } 104 105 public void setDataFile(String dataFile) 106 { 107 this.dataFile = dataFile; 108 } 109 110 } 111 | Popular Tags |