Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-1134] Deprecate internal Verifier debug mode #48

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 16 additions & 60 deletions src/main/java/org/apache/maven/shared/verifier/Verifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
Expand Down Expand Up @@ -81,10 +80,6 @@ public class Verifier

private final String[] defaultCliArguments;

private PrintStream originalOut;

private PrintStream originalErr;

private List<String> cliArguments = new ArrayList<>();

private Properties systemProperties = new Properties();
Expand All @@ -97,8 +92,6 @@ public class Verifier

private String localRepoLayout = "default";

private boolean debug;

/**
* If {@code true} uses {@link ForkedLauncher}, if {@code false} uses {@link Embedded3xLauncher},
* otherwise considers the value {@link #forkMode}.
Expand Down Expand Up @@ -190,15 +183,6 @@ private Verifier( String basedir, String settingsFile, boolean debug, Boolean fo
this.forkJvm = forkJvm;
this.forkMode = System.getProperty( "verifier.forkMode" );

if ( !debug )
{
originalOut = System.out;

originalErr = System.err;
}

setDebug( debug );

findLocalRepo( settingsFile );
if ( mavenHome == null )
{
Expand All @@ -224,35 +208,19 @@ public void setLocalRepo( String localRepo )
this.localRepo = localRepo;
}

/**
* @deprecated will be removed without replacement
*/
public void resetStreams()
{
if ( !debug )
{
System.setOut( originalOut );

System.setErr( originalErr );
}
}


/**
* @deprecated will be removed without replacement
*/
public void displayStreamBuffers()
{
String out = outStream.toString();

if ( out != null && out.trim().length() > 0 )
{
System.out.println( "----- Standard Out -----" );

System.out.println( out );
}

String err = errStream.toString();

if ( err != null && err.trim().length() > 0 )
{
System.err.println( "----- Standard Error -----" );

System.err.println( err );
}
}

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -690,7 +658,6 @@ private static String retrieveLocalRepo( String settingsXmlPath )

if ( settingsXmlPath != null )
{
System.out.println( "Using settings from " + settingsXmlPath );
userXml = new File( settingsXmlPath );
}
else
Expand Down Expand Up @@ -1077,7 +1044,7 @@ private void verifyFilePresence( String filePath, boolean wanted )
}
catch ( IOException e )
{
System.err.println( "WARN: error closing stream: " + e );
// ignore
}
}
}
Expand Down Expand Up @@ -1528,23 +1495,17 @@ public void parse( File file )

public void warning( SAXParseException spe )
{
printParseError( "Warning", spe );
}

public void error( SAXParseException spe )
{
printParseError( "Error", spe );
// ignore warnings
}

public void fatalError( SAXParseException spe )
public void error( SAXParseException spe ) throws SAXException
{
printParseError( "Fatal Error", spe );
throw new SAXException( spe );
}

private void printParseError( String type, SAXParseException spe )
public void fatalError( SAXParseException spe ) throws SAXException
{
System.err.println(
type + " [line " + spe.getLineNumber() + ", row " + spe.getColumnNumber() + "]: " + spe.getMessage() );
throw new SAXException( spe );
}

public String getLocalRepository()
Expand Down Expand Up @@ -1749,16 +1710,11 @@ public void setLogFileName( String logFileName )
this.logFileName = logFileName;
}

/**
* @deprecated will be removed without replacement
*/
public void setDebug( boolean debug )
{
this.debug = debug;

if ( !debug )
{
System.setOut( new PrintStream( outStream ) );

System.setErr( new PrintStream( errStream ) );
}
}

/**
Expand Down