git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270480 13f79535-47bb-0310-9956-ffa450edef68master
@@ -10,11 +10,9 @@ package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import java.io.File; | |||
import java.io.FileWriter; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.io.PrintWriter; | |||
import java.io.StringWriter; | |||
import java.util.ArrayList; | |||
import java.util.Random; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.taskdefs.exec.Execute; | |||
@@ -23,7 +21,6 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||
import org.apache.tools.ant.types.Argument; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -38,68 +35,32 @@ import org.apache.tools.ant.types.Path; | |||
* | |||
* @author <a href="sbailliez@imediation.com">Stephane Bailliez</a> | |||
*/ | |||
public class Coverage extends Task | |||
public class Coverage | |||
extends Task | |||
{ | |||
protected Commandline cmdl = new Commandline(); | |||
protected CommandlineJava cmdlJava = new CommandlineJava(); | |||
protected String function = "coverage"; | |||
protected boolean applet = false; | |||
/** | |||
* this is a somewhat annoying thing, set it to never | |||
*/ | |||
protected String exitPrompt = "never"; | |||
protected Filters filters = new Filters(); | |||
protected String finalSnapshot = "coverage"; | |||
protected String recordFromStart = "coverage"; | |||
protected boolean trackNatives = false; | |||
protected int warnLevel = 0; | |||
protected ArrayList filesets = new ArrayList(); | |||
protected File home; | |||
protected File inputFile; | |||
protected File javaExe; | |||
protected String seedName; | |||
protected File snapshotDir; | |||
protected Socket socket; | |||
protected Triggers triggers; | |||
protected String vm; | |||
protected File workingDir; | |||
//---------------- the tedious job begins here | |||
public Coverage() | |||
{ | |||
} | |||
/** | |||
* default to false unless file is htm or html | |||
* | |||
* @param value The new Applet value | |||
*/ | |||
public void setApplet( boolean value ) | |||
{ | |||
applet = value; | |||
} | |||
private String m_exitPrompt = "never"; | |||
private Filters m_filters = new Filters(); | |||
private String m_finalSnapshot = "coverage"; | |||
private String m_recordFromStart = "coverage"; | |||
private boolean m_trackNatives; | |||
private int m_warnLevel = 0; | |||
private ArrayList m_filesets = new ArrayList(); | |||
private File m_home; | |||
private File m_inputFile; | |||
private File m_javaExe; | |||
private String m_seedName; | |||
private File m_snapshotDir; | |||
private Socket m_socket; | |||
private Triggers m_triggers; | |||
private String m_vm; | |||
private File m_workingDir; | |||
/** | |||
* classname to run as standalone or runner for filesets | |||
@@ -118,7 +79,7 @@ public class Coverage extends Task | |||
*/ | |||
public void setExitprompt( String value ) | |||
{ | |||
exitPrompt = value; | |||
m_exitPrompt = value; | |||
} | |||
/** | |||
@@ -128,11 +89,9 @@ public class Coverage extends Task | |||
*/ | |||
public void setFinalsnapshot( String value ) | |||
{ | |||
finalSnapshot = value; | |||
m_finalSnapshot = value; | |||
} | |||
//--------- setters used via reflection -- | |||
/** | |||
* set the coverage home directory where are libraries, jars and jplauncher | |||
* | |||
@@ -140,17 +99,17 @@ public class Coverage extends Task | |||
*/ | |||
public void setHome( File value ) | |||
{ | |||
home = value; | |||
m_home = value; | |||
} | |||
public void setInputfile( File value ) | |||
{ | |||
inputFile = value; | |||
m_inputFile = value; | |||
} | |||
public void setJavaexe( File value ) | |||
{ | |||
javaExe = value; | |||
m_javaExe = value; | |||
} | |||
/** | |||
@@ -160,7 +119,7 @@ public class Coverage extends Task | |||
*/ | |||
public void setRecordfromstart( Recordfromstart value ) | |||
{ | |||
recordFromStart = value.getValue(); | |||
m_recordFromStart = value.getValue(); | |||
} | |||
/** | |||
@@ -170,17 +129,17 @@ public class Coverage extends Task | |||
*/ | |||
public void setSeedname( String value ) | |||
{ | |||
seedName = value; | |||
m_seedName = value; | |||
} | |||
public void setSnapshotdir( File value ) | |||
{ | |||
snapshotDir = value; | |||
m_snapshotDir = value; | |||
} | |||
public void setTracknatives( boolean value ) | |||
{ | |||
trackNatives = value; | |||
m_trackNatives = value; | |||
} | |||
/** | |||
@@ -190,17 +149,17 @@ public class Coverage extends Task | |||
*/ | |||
public void setVm( Javavm value ) | |||
{ | |||
vm = value.getValue(); | |||
m_vm = value.getValue(); | |||
} | |||
public void setWarnlevel( Integer value ) | |||
{ | |||
warnLevel = value.intValue(); | |||
m_warnLevel = value.intValue(); | |||
} | |||
public void setWorkingdir( File value ) | |||
{ | |||
workingDir = value; | |||
m_workingDir = value; | |||
} | |||
/** | |||
@@ -210,7 +169,7 @@ public class Coverage extends Task | |||
*/ | |||
public void addFileset( FileSet fs ) | |||
{ | |||
filesets.add( fs ); | |||
m_filesets.add( fs ); | |||
} | |||
/** | |||
@@ -235,11 +194,9 @@ public class Coverage extends Task | |||
public Filters createFilters() | |||
{ | |||
return filters; | |||
return m_filters; | |||
} | |||
// | |||
/** | |||
* the jvm arguments | |||
* | |||
@@ -252,20 +209,20 @@ public class Coverage extends Task | |||
public Socket createSocket() | |||
{ | |||
if( socket == null ) | |||
if( m_socket == null ) | |||
{ | |||
socket = new Socket(); | |||
m_socket = new Socket(); | |||
} | |||
return socket; | |||
return m_socket; | |||
} | |||
public Triggers createTriggers() | |||
{ | |||
if( triggers == null ) | |||
if( m_triggers == null ) | |||
{ | |||
triggers = new Triggers(); | |||
m_triggers = new Triggers(); | |||
} | |||
return triggers; | |||
return m_triggers; | |||
} | |||
/** | |||
@@ -278,19 +235,19 @@ public class Coverage extends Task | |||
{ | |||
File paramfile = null; | |||
// if an input file is used, all other options are ignored... | |||
if( inputFile == null ) | |||
if( m_inputFile == null ) | |||
{ | |||
checkOptions(); | |||
paramfile = createParamFile(); | |||
} | |||
else | |||
{ | |||
paramfile = inputFile; | |||
paramfile = m_inputFile; | |||
} | |||
try | |||
{ | |||
// we need to run Coverage from his directory due to dll/jar issues | |||
cmdl.setExecutable( new File( home, "jplauncher" ).getAbsolutePath() ); | |||
cmdl.setExecutable( new File( m_home, "jplauncher" ).getAbsolutePath() ); | |||
cmdl.createArgument().setValue( "-jp_input=" + paramfile.getAbsolutePath() ); | |||
// use the custom handler for stdin issues | |||
@@ -313,7 +270,7 @@ public class Coverage extends Task | |||
finally | |||
{ | |||
//@todo should be removed once switched to JDK1.2 | |||
if( inputFile == null && paramfile != null ) | |||
if( m_inputFile == null && paramfile != null ) | |||
{ | |||
paramfile.delete(); | |||
} | |||
@@ -331,35 +288,35 @@ public class Coverage extends Task | |||
throws TaskException | |||
{ | |||
ArrayList params = new ArrayList(); | |||
params.add( "-jp_function=" + function ); | |||
if( vm != null ) | |||
params.add( "-jp_function=coverage" ); | |||
if( m_vm != null ) | |||
{ | |||
params.add( "-jp_vm=" + vm ); | |||
params.add( "-jp_vm=" + m_vm ); | |||
} | |||
if( javaExe != null ) | |||
if( m_javaExe != null ) | |||
{ | |||
params.add( "-jp_java_exe=" + resolveFile( javaExe.getPath() ) ); | |||
params.add( "-jp_java_exe=" + resolveFile( m_javaExe.getPath() ) ); | |||
} | |||
params.add( "-jp_working_dir=" + workingDir.getPath() ); | |||
params.add( "-jp_snapshot_dir=" + snapshotDir.getPath() ); | |||
params.add( "-jp_record_from_start=" + recordFromStart ); | |||
params.add( "-jp_warn=" + warnLevel ); | |||
if( seedName != null ) | |||
params.add( "-jp_working_dir=" + m_workingDir.getPath() ); | |||
params.add( "-jp_snapshot_dir=" + m_snapshotDir.getPath() ); | |||
params.add( "-jp_record_from_start=" + m_recordFromStart ); | |||
params.add( "-jp_warn=" + m_warnLevel ); | |||
if( m_seedName != null ) | |||
{ | |||
params.add( "-jp_output_file=" + seedName ); | |||
params.add( "-jp_output_file=" + m_seedName ); | |||
} | |||
params.add( "-jp_filter=" + filters.toString() ); | |||
if( triggers != null ) | |||
params.add( "-jp_filter=" + m_filters.toString() ); | |||
if( m_triggers != null ) | |||
{ | |||
params.add( "-jp_trigger=" + triggers.toString() ); | |||
params.add( "-jp_trigger=" + m_triggers.toString() ); | |||
} | |||
if( finalSnapshot != null ) | |||
if( m_finalSnapshot != null ) | |||
{ | |||
params.add( "-jp_final_snapshot=" + finalSnapshot ); | |||
params.add( "-jp_final_snapshot=" + m_finalSnapshot ); | |||
} | |||
params.add( "-jp_exit_prompt=" + exitPrompt ); | |||
params.add( "-jp_exit_prompt=" + m_exitPrompt ); | |||
//params.add("-jp_append=" + append); | |||
params.add( "-jp_track_natives=" + trackNatives ); | |||
params.add( "-jp_track_natives=" + m_trackNatives ); | |||
//.... now the jvm | |||
// arguments | |||
String[] vmargs = cmdlJava.getVmCommand().getArguments(); | |||
@@ -397,50 +354,50 @@ public class Coverage extends Task | |||
throws TaskException | |||
{ | |||
// check coverage home | |||
if( home == null || !home.isDirectory() ) | |||
if( m_home == null || !m_home.isDirectory() ) | |||
{ | |||
throw new TaskException( "Invalid home directory. Must point to JProbe home directory" ); | |||
} | |||
home = new File( home, "coverage" ); | |||
File jar = new File( home, "coverage.jar" ); | |||
m_home = new File( m_home, "coverage" ); | |||
File jar = new File( m_home, "coverage.jar" ); | |||
if( !jar.exists() ) | |||
{ | |||
throw new TaskException( "Cannot find Coverage directory: " + home ); | |||
throw new TaskException( "Cannot find Coverage directory: " + m_home ); | |||
} | |||
// make sure snapshot dir exists and is resolved | |||
if( snapshotDir == null ) | |||
if( m_snapshotDir == null ) | |||
{ | |||
snapshotDir = new File( "." ); | |||
m_snapshotDir = new File( "." ); | |||
} | |||
snapshotDir = resolveFile( snapshotDir.getPath() ); | |||
if( !snapshotDir.isDirectory() || !snapshotDir.exists() ) | |||
m_snapshotDir = resolveFile( m_snapshotDir.getPath() ); | |||
if( !m_snapshotDir.isDirectory() || !m_snapshotDir.exists() ) | |||
{ | |||
throw new TaskException( "Snapshot directory does not exists :" + snapshotDir ); | |||
throw new TaskException( "Snapshot directory does not exists :" + m_snapshotDir ); | |||
} | |||
if( workingDir == null ) | |||
if( m_workingDir == null ) | |||
{ | |||
workingDir = new File( "." ); | |||
m_workingDir = new File( "." ); | |||
} | |||
workingDir = resolveFile( workingDir.getPath() ); | |||
m_workingDir = resolveFile( m_workingDir.getPath() ); | |||
// check for info, do your best to select the java executable. | |||
// JProbe 3.0 fails if there is no javaexe option. So | |||
if( javaExe == null && ( vm == null || "java2".equals( vm ) ) ) | |||
if( m_javaExe == null && ( m_vm == null || "java2".equals( m_vm ) ) ) | |||
{ | |||
String version = System.getProperty( "java.version" ); | |||
// make we are using 1.2+, if it is, then do your best to | |||
// get a javaexe | |||
if( !version.startsWith( "1.1" ) ) | |||
{ | |||
if( vm == null ) | |||
if( m_vm == null ) | |||
{ | |||
vm = "java2"; | |||
m_vm = "java2"; | |||
} | |||
// if we are here obviously it is java2 | |||
String home = System.getProperty( "java.home" ); | |||
boolean isUnix = File.separatorChar == '/'; | |||
javaExe = isUnix ? new File( home, "bin/java" ) : new File( home, "/bin/java.exe" ); | |||
m_javaExe = isUnix ? new File( home, "bin/java" ) : new File( home, "/bin/java.exe" ); | |||
} | |||
} | |||
} | |||
@@ -458,7 +415,7 @@ public class Coverage extends Task | |||
throws TaskException | |||
{ | |||
//@todo change this when switching to JDK 1.2 and use File.createTmpFile() | |||
File file = createTmpFile(); | |||
File file = File.createTempFile( "jpcoverage", "tmp" ); | |||
getLogger().debug( "Creating parameter file: " + file ); | |||
// options need to be one per line in the parameter file | |||
@@ -500,72 +457,4 @@ public class Coverage extends Task | |||
} | |||
return file; | |||
} | |||
/** | |||
* create a temporary file in the current dir (For JDK1.1 support) | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
protected File createTmpFile() | |||
{ | |||
final long rand = ( new Random( System.currentTimeMillis() ) ).nextLong(); | |||
File file = new File( "jpcoverage" + rand + ".tmp" ); | |||
return file; | |||
} | |||
public static class Finalsnapshot extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} | |||
public static class Javavm extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"java2", "jdk118", "jdk117"}; | |||
} | |||
} | |||
public static class Recordfromstart extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} | |||
/** | |||
* specific pumper to avoid those nasty stdin issues | |||
*/ | |||
static class CoverageStreamHandler | |||
extends LogStreamHandler | |||
{ | |||
CoverageStreamHandler( OutputStream output, OutputStream error ) | |||
{ | |||
super( output, error ); | |||
} | |||
/** | |||
* there are some issues concerning all JProbe executable In our case a | |||
* 'Press ENTER to close this window..." will be displayed in the | |||
* current window waiting for enter. So I'm closing the stream right | |||
* away to avoid problems. | |||
* | |||
* @param os The new ProcessInputStream value | |||
*/ | |||
public void setProcessInputStream( OutputStream os ) | |||
{ | |||
try | |||
{ | |||
os.close(); | |||
} | |||
catch( IOException ignored ) | |||
{ | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||
import java.io.OutputStream; | |||
import java.io.IOException; | |||
/** | |||
* specific pumper to avoid those nasty stdin issues | |||
*/ | |||
class CoverageStreamHandler | |||
extends LogStreamHandler | |||
{ | |||
CoverageStreamHandler( OutputStream output, OutputStream error ) | |||
{ | |||
super( output, error ); | |||
} | |||
/** | |||
* there are some issues concerning all JProbe executable In our case a | |||
* 'Press ENTER to close this window..." will be displayed in the | |||
* current window waiting for enter. So I'm closing the stream right | |||
* away to avoid problems. | |||
* | |||
* @param os The new ProcessInputStream value | |||
*/ | |||
public void setProcessInputStream( OutputStream os ) | |||
{ | |||
try | |||
{ | |||
os.close(); | |||
} | |||
catch( IOException ignored ) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
public class Finalsnapshot | |||
extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
public class Javavm | |||
extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"java2", "jdk118", "jdk117"}; | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
public class Recordfromstart | |||
extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} |
@@ -10,11 +10,9 @@ package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import java.io.File; | |||
import java.io.FileWriter; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.io.PrintWriter; | |||
import java.io.StringWriter; | |||
import java.util.ArrayList; | |||
import java.util.Random; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.taskdefs.exec.Execute; | |||
@@ -23,7 +21,6 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||
import org.apache.tools.ant.types.Argument; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.CommandlineJava; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -38,68 +35,32 @@ import org.apache.tools.ant.types.Path; | |||
* | |||
* @author <a href="sbailliez@imediation.com">Stephane Bailliez</a> | |||
*/ | |||
public class Coverage extends Task | |||
public class Coverage | |||
extends Task | |||
{ | |||
protected Commandline cmdl = new Commandline(); | |||
protected CommandlineJava cmdlJava = new CommandlineJava(); | |||
protected String function = "coverage"; | |||
protected boolean applet = false; | |||
/** | |||
* this is a somewhat annoying thing, set it to never | |||
*/ | |||
protected String exitPrompt = "never"; | |||
protected Filters filters = new Filters(); | |||
protected String finalSnapshot = "coverage"; | |||
protected String recordFromStart = "coverage"; | |||
protected boolean trackNatives = false; | |||
protected int warnLevel = 0; | |||
protected ArrayList filesets = new ArrayList(); | |||
protected File home; | |||
protected File inputFile; | |||
protected File javaExe; | |||
protected String seedName; | |||
protected File snapshotDir; | |||
protected Socket socket; | |||
protected Triggers triggers; | |||
protected String vm; | |||
protected File workingDir; | |||
//---------------- the tedious job begins here | |||
public Coverage() | |||
{ | |||
} | |||
/** | |||
* default to false unless file is htm or html | |||
* | |||
* @param value The new Applet value | |||
*/ | |||
public void setApplet( boolean value ) | |||
{ | |||
applet = value; | |||
} | |||
private String m_exitPrompt = "never"; | |||
private Filters m_filters = new Filters(); | |||
private String m_finalSnapshot = "coverage"; | |||
private String m_recordFromStart = "coverage"; | |||
private boolean m_trackNatives; | |||
private int m_warnLevel = 0; | |||
private ArrayList m_filesets = new ArrayList(); | |||
private File m_home; | |||
private File m_inputFile; | |||
private File m_javaExe; | |||
private String m_seedName; | |||
private File m_snapshotDir; | |||
private Socket m_socket; | |||
private Triggers m_triggers; | |||
private String m_vm; | |||
private File m_workingDir; | |||
/** | |||
* classname to run as standalone or runner for filesets | |||
@@ -118,7 +79,7 @@ public class Coverage extends Task | |||
*/ | |||
public void setExitprompt( String value ) | |||
{ | |||
exitPrompt = value; | |||
m_exitPrompt = value; | |||
} | |||
/** | |||
@@ -128,11 +89,9 @@ public class Coverage extends Task | |||
*/ | |||
public void setFinalsnapshot( String value ) | |||
{ | |||
finalSnapshot = value; | |||
m_finalSnapshot = value; | |||
} | |||
//--------- setters used via reflection -- | |||
/** | |||
* set the coverage home directory where are libraries, jars and jplauncher | |||
* | |||
@@ -140,17 +99,17 @@ public class Coverage extends Task | |||
*/ | |||
public void setHome( File value ) | |||
{ | |||
home = value; | |||
m_home = value; | |||
} | |||
public void setInputfile( File value ) | |||
{ | |||
inputFile = value; | |||
m_inputFile = value; | |||
} | |||
public void setJavaexe( File value ) | |||
{ | |||
javaExe = value; | |||
m_javaExe = value; | |||
} | |||
/** | |||
@@ -160,7 +119,7 @@ public class Coverage extends Task | |||
*/ | |||
public void setRecordfromstart( Recordfromstart value ) | |||
{ | |||
recordFromStart = value.getValue(); | |||
m_recordFromStart = value.getValue(); | |||
} | |||
/** | |||
@@ -170,17 +129,17 @@ public class Coverage extends Task | |||
*/ | |||
public void setSeedname( String value ) | |||
{ | |||
seedName = value; | |||
m_seedName = value; | |||
} | |||
public void setSnapshotdir( File value ) | |||
{ | |||
snapshotDir = value; | |||
m_snapshotDir = value; | |||
} | |||
public void setTracknatives( boolean value ) | |||
{ | |||
trackNatives = value; | |||
m_trackNatives = value; | |||
} | |||
/** | |||
@@ -190,17 +149,17 @@ public class Coverage extends Task | |||
*/ | |||
public void setVm( Javavm value ) | |||
{ | |||
vm = value.getValue(); | |||
m_vm = value.getValue(); | |||
} | |||
public void setWarnlevel( Integer value ) | |||
{ | |||
warnLevel = value.intValue(); | |||
m_warnLevel = value.intValue(); | |||
} | |||
public void setWorkingdir( File value ) | |||
{ | |||
workingDir = value; | |||
m_workingDir = value; | |||
} | |||
/** | |||
@@ -210,7 +169,7 @@ public class Coverage extends Task | |||
*/ | |||
public void addFileset( FileSet fs ) | |||
{ | |||
filesets.add( fs ); | |||
m_filesets.add( fs ); | |||
} | |||
/** | |||
@@ -235,11 +194,9 @@ public class Coverage extends Task | |||
public Filters createFilters() | |||
{ | |||
return filters; | |||
return m_filters; | |||
} | |||
// | |||
/** | |||
* the jvm arguments | |||
* | |||
@@ -252,20 +209,20 @@ public class Coverage extends Task | |||
public Socket createSocket() | |||
{ | |||
if( socket == null ) | |||
if( m_socket == null ) | |||
{ | |||
socket = new Socket(); | |||
m_socket = new Socket(); | |||
} | |||
return socket; | |||
return m_socket; | |||
} | |||
public Triggers createTriggers() | |||
{ | |||
if( triggers == null ) | |||
if( m_triggers == null ) | |||
{ | |||
triggers = new Triggers(); | |||
m_triggers = new Triggers(); | |||
} | |||
return triggers; | |||
return m_triggers; | |||
} | |||
/** | |||
@@ -278,19 +235,19 @@ public class Coverage extends Task | |||
{ | |||
File paramfile = null; | |||
// if an input file is used, all other options are ignored... | |||
if( inputFile == null ) | |||
if( m_inputFile == null ) | |||
{ | |||
checkOptions(); | |||
paramfile = createParamFile(); | |||
} | |||
else | |||
{ | |||
paramfile = inputFile; | |||
paramfile = m_inputFile; | |||
} | |||
try | |||
{ | |||
// we need to run Coverage from his directory due to dll/jar issues | |||
cmdl.setExecutable( new File( home, "jplauncher" ).getAbsolutePath() ); | |||
cmdl.setExecutable( new File( m_home, "jplauncher" ).getAbsolutePath() ); | |||
cmdl.createArgument().setValue( "-jp_input=" + paramfile.getAbsolutePath() ); | |||
// use the custom handler for stdin issues | |||
@@ -313,7 +270,7 @@ public class Coverage extends Task | |||
finally | |||
{ | |||
//@todo should be removed once switched to JDK1.2 | |||
if( inputFile == null && paramfile != null ) | |||
if( m_inputFile == null && paramfile != null ) | |||
{ | |||
paramfile.delete(); | |||
} | |||
@@ -331,35 +288,35 @@ public class Coverage extends Task | |||
throws TaskException | |||
{ | |||
ArrayList params = new ArrayList(); | |||
params.add( "-jp_function=" + function ); | |||
if( vm != null ) | |||
params.add( "-jp_function=coverage" ); | |||
if( m_vm != null ) | |||
{ | |||
params.add( "-jp_vm=" + vm ); | |||
params.add( "-jp_vm=" + m_vm ); | |||
} | |||
if( javaExe != null ) | |||
if( m_javaExe != null ) | |||
{ | |||
params.add( "-jp_java_exe=" + resolveFile( javaExe.getPath() ) ); | |||
params.add( "-jp_java_exe=" + resolveFile( m_javaExe.getPath() ) ); | |||
} | |||
params.add( "-jp_working_dir=" + workingDir.getPath() ); | |||
params.add( "-jp_snapshot_dir=" + snapshotDir.getPath() ); | |||
params.add( "-jp_record_from_start=" + recordFromStart ); | |||
params.add( "-jp_warn=" + warnLevel ); | |||
if( seedName != null ) | |||
params.add( "-jp_working_dir=" + m_workingDir.getPath() ); | |||
params.add( "-jp_snapshot_dir=" + m_snapshotDir.getPath() ); | |||
params.add( "-jp_record_from_start=" + m_recordFromStart ); | |||
params.add( "-jp_warn=" + m_warnLevel ); | |||
if( m_seedName != null ) | |||
{ | |||
params.add( "-jp_output_file=" + seedName ); | |||
params.add( "-jp_output_file=" + m_seedName ); | |||
} | |||
params.add( "-jp_filter=" + filters.toString() ); | |||
if( triggers != null ) | |||
params.add( "-jp_filter=" + m_filters.toString() ); | |||
if( m_triggers != null ) | |||
{ | |||
params.add( "-jp_trigger=" + triggers.toString() ); | |||
params.add( "-jp_trigger=" + m_triggers.toString() ); | |||
} | |||
if( finalSnapshot != null ) | |||
if( m_finalSnapshot != null ) | |||
{ | |||
params.add( "-jp_final_snapshot=" + finalSnapshot ); | |||
params.add( "-jp_final_snapshot=" + m_finalSnapshot ); | |||
} | |||
params.add( "-jp_exit_prompt=" + exitPrompt ); | |||
params.add( "-jp_exit_prompt=" + m_exitPrompt ); | |||
//params.add("-jp_append=" + append); | |||
params.add( "-jp_track_natives=" + trackNatives ); | |||
params.add( "-jp_track_natives=" + m_trackNatives ); | |||
//.... now the jvm | |||
// arguments | |||
String[] vmargs = cmdlJava.getVmCommand().getArguments(); | |||
@@ -397,50 +354,50 @@ public class Coverage extends Task | |||
throws TaskException | |||
{ | |||
// check coverage home | |||
if( home == null || !home.isDirectory() ) | |||
if( m_home == null || !m_home.isDirectory() ) | |||
{ | |||
throw new TaskException( "Invalid home directory. Must point to JProbe home directory" ); | |||
} | |||
home = new File( home, "coverage" ); | |||
File jar = new File( home, "coverage.jar" ); | |||
m_home = new File( m_home, "coverage" ); | |||
File jar = new File( m_home, "coverage.jar" ); | |||
if( !jar.exists() ) | |||
{ | |||
throw new TaskException( "Cannot find Coverage directory: " + home ); | |||
throw new TaskException( "Cannot find Coverage directory: " + m_home ); | |||
} | |||
// make sure snapshot dir exists and is resolved | |||
if( snapshotDir == null ) | |||
if( m_snapshotDir == null ) | |||
{ | |||
snapshotDir = new File( "." ); | |||
m_snapshotDir = new File( "." ); | |||
} | |||
snapshotDir = resolveFile( snapshotDir.getPath() ); | |||
if( !snapshotDir.isDirectory() || !snapshotDir.exists() ) | |||
m_snapshotDir = resolveFile( m_snapshotDir.getPath() ); | |||
if( !m_snapshotDir.isDirectory() || !m_snapshotDir.exists() ) | |||
{ | |||
throw new TaskException( "Snapshot directory does not exists :" + snapshotDir ); | |||
throw new TaskException( "Snapshot directory does not exists :" + m_snapshotDir ); | |||
} | |||
if( workingDir == null ) | |||
if( m_workingDir == null ) | |||
{ | |||
workingDir = new File( "." ); | |||
m_workingDir = new File( "." ); | |||
} | |||
workingDir = resolveFile( workingDir.getPath() ); | |||
m_workingDir = resolveFile( m_workingDir.getPath() ); | |||
// check for info, do your best to select the java executable. | |||
// JProbe 3.0 fails if there is no javaexe option. So | |||
if( javaExe == null && ( vm == null || "java2".equals( vm ) ) ) | |||
if( m_javaExe == null && ( m_vm == null || "java2".equals( m_vm ) ) ) | |||
{ | |||
String version = System.getProperty( "java.version" ); | |||
// make we are using 1.2+, if it is, then do your best to | |||
// get a javaexe | |||
if( !version.startsWith( "1.1" ) ) | |||
{ | |||
if( vm == null ) | |||
if( m_vm == null ) | |||
{ | |||
vm = "java2"; | |||
m_vm = "java2"; | |||
} | |||
// if we are here obviously it is java2 | |||
String home = System.getProperty( "java.home" ); | |||
boolean isUnix = File.separatorChar == '/'; | |||
javaExe = isUnix ? new File( home, "bin/java" ) : new File( home, "/bin/java.exe" ); | |||
m_javaExe = isUnix ? new File( home, "bin/java" ) : new File( home, "/bin/java.exe" ); | |||
} | |||
} | |||
} | |||
@@ -458,7 +415,7 @@ public class Coverage extends Task | |||
throws TaskException | |||
{ | |||
//@todo change this when switching to JDK 1.2 and use File.createTmpFile() | |||
File file = createTmpFile(); | |||
File file = File.createTempFile( "jpcoverage", "tmp" ); | |||
getLogger().debug( "Creating parameter file: " + file ); | |||
// options need to be one per line in the parameter file | |||
@@ -500,72 +457,4 @@ public class Coverage extends Task | |||
} | |||
return file; | |||
} | |||
/** | |||
* create a temporary file in the current dir (For JDK1.1 support) | |||
* | |||
* @return Description of the Returned Value | |||
*/ | |||
protected File createTmpFile() | |||
{ | |||
final long rand = ( new Random( System.currentTimeMillis() ) ).nextLong(); | |||
File file = new File( "jpcoverage" + rand + ".tmp" ); | |||
return file; | |||
} | |||
public static class Finalsnapshot extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} | |||
public static class Javavm extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"java2", "jdk118", "jdk117"}; | |||
} | |||
} | |||
public static class Recordfromstart extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} | |||
/** | |||
* specific pumper to avoid those nasty stdin issues | |||
*/ | |||
static class CoverageStreamHandler | |||
extends LogStreamHandler | |||
{ | |||
CoverageStreamHandler( OutputStream output, OutputStream error ) | |||
{ | |||
super( output, error ); | |||
} | |||
/** | |||
* there are some issues concerning all JProbe executable In our case a | |||
* 'Press ENTER to close this window..." will be displayed in the | |||
* current window waiting for enter. So I'm closing the stream right | |||
* away to avoid problems. | |||
* | |||
* @param os The new ProcessInputStream value | |||
*/ | |||
public void setProcessInputStream( OutputStream os ) | |||
{ | |||
try | |||
{ | |||
os.close(); | |||
} | |||
catch( IOException ignored ) | |||
{ | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||
import java.io.OutputStream; | |||
import java.io.IOException; | |||
/** | |||
* specific pumper to avoid those nasty stdin issues | |||
*/ | |||
class CoverageStreamHandler | |||
extends LogStreamHandler | |||
{ | |||
CoverageStreamHandler( OutputStream output, OutputStream error ) | |||
{ | |||
super( output, error ); | |||
} | |||
/** | |||
* there are some issues concerning all JProbe executable In our case a | |||
* 'Press ENTER to close this window..." will be displayed in the | |||
* current window waiting for enter. So I'm closing the stream right | |||
* away to avoid problems. | |||
* | |||
* @param os The new ProcessInputStream value | |||
*/ | |||
public void setProcessInputStream( OutputStream os ) | |||
{ | |||
try | |||
{ | |||
os.close(); | |||
} | |||
catch( IOException ignored ) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
public class Finalsnapshot | |||
extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
public class Javavm | |||
extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"java2", "jdk118", "jdk117"}; | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
/* | |||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||
* | |||
* This software is published under the terms of the Apache Software License | |||
* version 1.1, a copy of which has been included with this distribution in | |||
* the LICENSE.txt file. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
public class Recordfromstart | |||
extends EnumeratedAttribute | |||
{ | |||
public String[] getValues() | |||
{ | |||
return new String[]{"coverage", "none", "all"}; | |||
} | |||
} |