You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/30 12:00:21 UTC
cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka CoverageStreamHandler.java Finalsnapshot.java Javavm.java Recordfromstart.java Coverage.java
donaldp 01/12/30 03:00:21
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka
Coverage.java
Added: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka
CoverageStreamHandler.java Finalsnapshot.java
Javavm.java Recordfromstart.java
Log:
Begin to cleanup tasks
Revision Changes Path
1.14 +77 -188 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java
Index: Coverage.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Coverage.java 30 Dec 2001 10:46:59 -0000 1.13
+++ Coverage.java 30 Dec 2001 11:00:20 -0000 1.14
@@ -10,11 +10,9 @@
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.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 @@
*
* @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;
+ private String m_exitPrompt = "never";
- 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 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 void setExitprompt( String value )
{
- exitPrompt = value;
+ m_exitPrompt = value;
}
/**
@@ -128,11 +89,9 @@
*/
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 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 void setRecordfromstart( Recordfromstart value )
{
- recordFromStart = value.getValue();
+ m_recordFromStart = value.getValue();
}
/**
@@ -170,17 +129,17 @@
*/
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 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 void addFileset( FileSet fs )
{
- filesets.add( fs );
+ m_filesets.add( fs );
}
/**
@@ -235,11 +194,9 @@
public Filters createFilters()
{
- return filters;
+ return m_filters;
}
- //
-
/**
* the jvm arguments
*
@@ -252,20 +209,20 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 )
- {
- }
- }
- }
-
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CoverageStreamHandler.java
Index: CoverageStreamHandler.java
===================================================================
/*
* 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 )
{
}
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Finalsnapshot.java
Index: Finalsnapshot.java
===================================================================
/*
* 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"};
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Javavm.java
Index: Javavm.java
===================================================================
/*
* 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"};
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Recordfromstart.java
Index: Recordfromstart.java
===================================================================
/*
* 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"};
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>