1 58 59 package net.sourceforge.cobertura.ant; 60 61 import java.io.File ; 62 import java.io.IOException ; 63 64 import net.sourceforge.cobertura.util.CommandLineBuilder; 65 66 import org.apache.tools.ant.BuildException; 67 import org.apache.tools.ant.Project; 68 69 73 public class ReportTask extends CommonMatchingTask 74 { 75 76 private String dataFile = null; 77 private String format = "html"; 78 private File destDir; 79 private String srcDir; 80 81 public ReportTask() { 82 super("net.sourceforge.cobertura.reporting.Main"); 83 } 84 85 public void execute() throws BuildException { 86 CommandLineBuilder builder = null; 87 try { 88 builder = new CommandLineBuilder(); 89 if (dataFile != null) 90 builder.addArg("--datafile", dataFile); 91 if (destDir != null) 92 builder.addArg("--destination", destDir.getAbsolutePath()); 93 if (format != null) 94 builder.addArg("--format", format); 95 if (srcDir != null) 96 builder.addArg(srcDir); 97 98 createArgumentsForFilesets(builder); 99 100 builder.saveArgs(); 101 } catch (IOException ioe) { 102 getProject().log("Error creating commands file.", Project.MSG_ERR); 103 throw new BuildException("Unable to create the commands file.", ioe); 104 } 105 106 getJava().createArg().setValue("--commandsfile"); 108 getJava().createArg().setValue(builder.getCommandLineFile()); 109 AntUtil.transferCoberturaDataFileProperty(getJava()); 110 if (getJava().executeJava() != 0) { 111 throw new BuildException( 112 "Error running reports. See messages above."); 113 } 114 115 builder.dispose(); 116 } 117 118 public void setDataFile(String dataFile) { 119 this.dataFile = dataFile; 120 } 121 122 public void setDestDir(File destDir) { 123 this.destDir = destDir; 124 } 125 126 public void setFormat(String format) { 127 this.format = format; 128 } 129 130 public void setSrcDir(String dir) { 131 srcDir = dir; 132 } 133 } 134 | Popular Tags |