mirror of https://github.com/apache/maven.git
JIRA issues fixed:
MRM-1 MRM-7 MRM-3 MRM-5 o Pipelining all logging through a single Reporter now, to repository.report.txt o Disabled WARNING reports by default, add 'reportWarnings=true' to config file to enable them. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@189629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
921d4ced59
commit
0db2b646d2
|
@ -141,6 +141,7 @@ public class Main
|
||||||
config.setReportsPath( props.getProperty( "reportsPath" ) );
|
config.setReportsPath( props.getProperty( "reportsPath" ) );
|
||||||
config.setBlacklistedPatterns( props.getProperty( "blacklistedPatterns" ) );
|
config.setBlacklistedPatterns( props.getProperty( "blacklistedPatterns" ) );
|
||||||
config.setReportOnly( Boolean.valueOf( props.getProperty( "reportOnly" ) ).booleanValue() );
|
config.setReportOnly( Boolean.valueOf( props.getProperty( "reportOnly" ) ).booleanValue() );
|
||||||
|
config.setReportWarningEnabled( Boolean.valueOf( props.getProperty( "reportWarnings", "false" ) ).booleanValue() );
|
||||||
|
|
||||||
config.setMailErrorReport( Boolean.valueOf( props.getProperty( "errorReport.mailOnError", "false" ) )
|
config.setMailErrorReport( Boolean.valueOf( props.getProperty( "errorReport.mailOnError", "false" ) )
|
||||||
.booleanValue() );
|
.booleanValue() );
|
||||||
|
@ -176,14 +177,15 @@ public class Main
|
||||||
+ "errorReport.toName=Developers List\n" + "\n" + "# [DEFAULT VALUE: legacy]\n"
|
+ "errorReport.toName=Developers List\n" + "\n" + "# [DEFAULT VALUE: legacy]\n"
|
||||||
+ "#sourceRepositoryLayout=[legacy|default]\n\n" + "# [DEFAULT VALUE: v3]\n"
|
+ "#sourceRepositoryLayout=[legacy|default]\n\n" + "# [DEFAULT VALUE: v3]\n"
|
||||||
+ "# [DEFAULT VALUE: default]\n" + "#targetRepositoryLayout=[legacy|default]\n"
|
+ "# [DEFAULT VALUE: default]\n" + "#targetRepositoryLayout=[legacy|default]\n"
|
||||||
+ "# [DEFAULT VALUE: localhost]\n" + "#errorReport.smtpHost=<hostname>\n" + "\n" );
|
+ "# [DEFAULT VALUE: localhost]\n" + "#errorReport.smtpHost=<hostname>\n"
|
||||||
|
+ "# [DEFAULT VALUE: false]\n" + "#reportWarnings=[true|false]\n" + "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printUsage()
|
private static void printUsage()
|
||||||
{
|
{
|
||||||
System.out.println( "Required input is missing.\n\n" + "Usage:\n"
|
System.out.println( "Required input is missing.\n\n" + "Usage:\n"
|
||||||
+ "--------------------------------------------------\n\n"
|
+ "--------------------------------------------------\n\n"
|
||||||
+ "repoclean -h|-template|<configuration-properties-file>\n" );
|
+ "repoclean [--force] -h|-template|<configuration-properties-file>\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -79,7 +79,7 @@ public class RepositoryCleaner
|
||||||
FileReporter repoReporter = null;
|
FileReporter repoReporter = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repoReporter = new FileReporter( reportsBase, "repository.report.txt" );
|
repoReporter = new FileReporter( reportsBase, "repository.report.txt", configuration.isReportWarningEnabled() );
|
||||||
|
|
||||||
List artifacts;
|
List artifacts;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class RepositoryCleanerConfiguration
|
||||||
|
|
||||||
private String blacklistedPatterns;
|
private String blacklistedPatterns;
|
||||||
|
|
||||||
|
private boolean reportWarningEnabled = false;
|
||||||
|
|
||||||
public void setSourceRepositoryPath( String sourceRepositoryPath )
|
public void setSourceRepositoryPath( String sourceRepositoryPath )
|
||||||
{
|
{
|
||||||
this.sourceRepositoryPath = sourceRepositoryPath;
|
this.sourceRepositoryPath = sourceRepositoryPath;
|
||||||
|
@ -203,4 +205,14 @@ public class RepositoryCleanerConfiguration
|
||||||
this.errorReportLink = errorReportLink;
|
this.errorReportLink = errorReportLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isReportWarningEnabled()
|
||||||
|
{
|
||||||
|
return reportWarningEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReportWarningEnabled( boolean reportWarningEnabled )
|
||||||
|
{
|
||||||
|
this.reportWarningEnabled = reportWarningEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -66,26 +66,26 @@ public class ProjectMetadata
|
||||||
|
|
||||||
public boolean exists()
|
public boolean exists()
|
||||||
{
|
{
|
||||||
return false;
|
return artifact.getFile() != null && artifact.getFile().exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupId()
|
public String getGroupId()
|
||||||
{
|
{
|
||||||
return null;
|
return artifact.getGroupId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArtifactId()
|
public String getArtifactId()
|
||||||
{
|
{
|
||||||
return null;
|
return artifact.getArtifactId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion()
|
public String getVersion()
|
||||||
{
|
{
|
||||||
return null;
|
return artifact.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseVersion()
|
public String getBaseVersion()
|
||||||
{
|
{
|
||||||
return null;
|
return artifact.getBaseVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class LegacyArtifactDiscoverer
|
||||||
+ "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|"
|
+ "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|"
|
||||||
+ "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|"
|
+ "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|"
|
||||||
+ "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|"
|
+ "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|"
|
||||||
+ "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])";
|
+ "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "([AaBb][_.0-9]*)";
|
||||||
|
|
||||||
// let's discover the version, and whatever's leftover will be either
|
// let's discover the version, and whatever's leftover will be either
|
||||||
// a classifier, or part of the artifactId, depending on position.
|
// a classifier, or part of the artifactId, depending on position.
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.apache.maven.tools.repoclean.RepositoryCleanerConfiguration;
|
||||||
import org.apache.maven.tools.repoclean.artifact.metadata.ProjectMetadata;
|
import org.apache.maven.tools.repoclean.artifact.metadata.ProjectMetadata;
|
||||||
import org.apache.maven.tools.repoclean.digest.DigestException;
|
import org.apache.maven.tools.repoclean.digest.DigestException;
|
||||||
import org.apache.maven.tools.repoclean.digest.DigestVerifier;
|
import org.apache.maven.tools.repoclean.digest.DigestVerifier;
|
||||||
import org.apache.maven.tools.repoclean.report.FileReporter;
|
|
||||||
import org.apache.maven.tools.repoclean.report.ReportWriteException;
|
import org.apache.maven.tools.repoclean.report.ReportWriteException;
|
||||||
import org.apache.maven.tools.repoclean.report.Reporter;
|
import org.apache.maven.tools.repoclean.report.Reporter;
|
||||||
import org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter;
|
import org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter;
|
||||||
|
@ -37,6 +36,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -70,15 +70,35 @@ public class RewritePhase
|
||||||
|
|
||||||
public List execute( List artifacts, ArtifactRepository sourceRepo, ArtifactRepository targetRepo,
|
public List execute( List artifacts, ArtifactRepository sourceRepo, ArtifactRepository targetRepo,
|
||||||
RepositoryCleanerConfiguration configuration, File reportsBase, Reporter repoReporter )
|
RepositoryCleanerConfiguration configuration, File reportsBase, Reporter repoReporter )
|
||||||
throws Exception
|
throws ReportWriteException
|
||||||
{
|
{
|
||||||
Logger logger = getLogger();
|
Logger logger = getLogger();
|
||||||
|
|
||||||
List rewritten = new ArrayList();
|
List rewritten = new ArrayList();
|
||||||
|
|
||||||
File sourceBase = new File( new URL( sourceRepo.getUrl() ).getPath() );
|
File sourceBase = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sourceBase = new File( new URL( sourceRepo.getUrl() ).getPath() );
|
||||||
|
}
|
||||||
|
catch ( MalformedURLException e )
|
||||||
|
{
|
||||||
|
repoReporter.error( "Cannot construct source repository base File for: " + sourceRepo, e );
|
||||||
|
|
||||||
File targetBase = new File( new URL( targetRepo.getUrl() ).getPath() );
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
File targetBase = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
targetBase = new File( new URL( targetRepo.getUrl() ).getPath() );
|
||||||
|
}
|
||||||
|
catch ( MalformedURLException e )
|
||||||
|
{
|
||||||
|
repoReporter.error( "Cannot construct target repository base File for: " + targetRepo, e );
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -88,11 +108,8 @@ public class RewritePhase
|
||||||
|
|
||||||
String artifactReportPath = buildArtifactReportPath( artifact );
|
String artifactReportPath = buildArtifactReportPath( artifact );
|
||||||
|
|
||||||
FileReporter artifactReporter = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactReporter = new FileReporter( reportsBase, artifactReportPath );
|
|
||||||
|
|
||||||
boolean errorOccurred = false;
|
boolean errorOccurred = false;
|
||||||
|
|
||||||
File artifactSource = new File( sourceRepo.getBasedir(), sourceRepo.pathOf( artifact ) );
|
File artifactSource = new File( sourceRepo.getBasedir(), sourceRepo.pathOf( artifact ) );
|
||||||
|
@ -110,37 +127,27 @@ public class RewritePhase
|
||||||
{
|
{
|
||||||
transaction.addFile( artifactTarget );
|
transaction.addFile( artifactTarget );
|
||||||
|
|
||||||
try
|
if ( !configuration.reportOnly() )
|
||||||
{
|
{
|
||||||
if ( !configuration.reportOnly() )
|
if ( logger.isDebugEnabled() )
|
||||||
{
|
{
|
||||||
if ( logger.isDebugEnabled() )
|
logger.debug( "sourceRepo basedir is: \'" + sourceRepo.getBasedir() + "\'" );
|
||||||
{
|
logger.debug( "targetRepo basedir is: \'" + targetRepo.getBasedir() + "\'" );
|
||||||
logger.debug( "sourceRepo basedir is: \'" + sourceRepo.getBasedir() + "\'" );
|
|
||||||
logger.debug( "targetRepo basedir is: \'" + targetRepo.getBasedir() + "\'" );
|
|
||||||
}
|
|
||||||
|
|
||||||
File targetParent = artifactTarget.getParentFile();
|
|
||||||
if ( !targetParent.exists() )
|
|
||||||
{
|
|
||||||
targetParent.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( logger.isDebugEnabled() )
|
|
||||||
{
|
|
||||||
logger.debug( "Copying artifact[" + artifact.getId() + "] from \'" + artifactSource
|
|
||||||
+ "\' to \'" + artifactTarget + "\'." );
|
|
||||||
}
|
|
||||||
|
|
||||||
copyArtifact( artifact, artifactTarget, artifactReporter );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
repoReporter.error( "Error transferring artifact[" + artifact.getId()
|
|
||||||
+ "] to the target repository.", e );
|
|
||||||
|
|
||||||
throw e;
|
File targetParent = artifactTarget.getParentFile();
|
||||||
|
if ( !targetParent.exists() )
|
||||||
|
{
|
||||||
|
targetParent.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.debug( "Copying artifact[" + artifact.getId() + "] from \'" + artifactSource
|
||||||
|
+ "\' to \'" + artifactTarget + "\'." );
|
||||||
|
}
|
||||||
|
|
||||||
|
copyArtifact( artifact, artifactTarget, repoReporter );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( logger.isDebugEnabled() )
|
if ( logger.isDebugEnabled() )
|
||||||
|
@ -149,46 +156,27 @@ public class RewritePhase
|
||||||
+ artifact.getGroupId() + "\'" );
|
+ artifact.getGroupId() + "\'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
digestVerifier.verifyDigest( artifactSource, artifactTarget, transaction, repoReporter,
|
||||||
{
|
configuration.reportOnly() );
|
||||||
digestVerifier.verifyDigest( artifactSource, artifactTarget, transaction, artifactReporter,
|
|
||||||
configuration.reportOnly() );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
repoReporter.error( "Error verifying digest for artifact[" + artifact.getId() + "]", e );
|
|
||||||
|
|
||||||
throw e;
|
rewriteMetadata( artifact, transaction, sourceBase, sourceRepo, targetBase, targetRepo,
|
||||||
}
|
repoReporter, configuration.reportOnly() );
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
rewriteMetadata( artifact, transaction, sourceBase, sourceRepo, targetBase, targetRepo,
|
|
||||||
artifactReporter, configuration.reportOnly() );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
repoReporter.error( "Error rewriting POM for artifact[" + artifact.getId()
|
|
||||||
+ "] into the target repository.\n Error message: " + e.getMessage() );
|
|
||||||
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
rewritten.add( artifact );
|
rewritten.add( artifact );
|
||||||
}
|
}
|
||||||
else if ( !targetMissingOrOlder )
|
else if ( !targetMissingOrOlder )
|
||||||
{
|
{
|
||||||
artifactReporter.warn( "Target file for artifact is present and not stale. (Artifact: \'"
|
repoReporter.warn( "Target file for artifact is present and not stale. (Artifact: \'"
|
||||||
+ artifact.getId() + "\' in path: \'" + artifactSource + "\' with target path: "
|
+ artifact.getId() + "\' in path: \'" + artifactSource + "\' with target path: "
|
||||||
+ artifactTarget + ")." );
|
+ artifactTarget + ")." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
artifactReporter.error( "Cannot find source file for artifact: \'" + artifact.getId()
|
repoReporter.error( "Cannot find source file for artifact: \'" + artifact.getId()
|
||||||
+ "\' under path: \'" + artifactSource + "\'" );
|
+ "\' under path: \'" + artifactSource + "\'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( artifactReporter.hasError() )
|
if ( repoReporter.hasError() )
|
||||||
{
|
{
|
||||||
repoReporter.warn( "Error(s) occurred while rewriting artifact: \'" + artifact.getId()
|
repoReporter.warn( "Error(s) occurred while rewriting artifact: \'" + artifact.getId()
|
||||||
+ "\' or its POM." );
|
+ "\' or its POM." );
|
||||||
|
@ -213,15 +201,8 @@ public class RewritePhase
|
||||||
repoReporter.warn( "NOT Rolling back conversion for: " + artifact + "; we are in --force mode." );
|
repoReporter.warn( "NOT Rolling back conversion for: " + artifact + "; we are in --force mode." );
|
||||||
}
|
}
|
||||||
|
|
||||||
artifactReporter.error( "Error while rewriting file or POM for artifact: \'" + artifact.getId()
|
repoReporter.error( "Error while rewriting file or POM for artifact: \'" + artifact.getId()
|
||||||
+ "\'. See report at: \'" + artifactReportPath + "\'.", e );
|
+ "\'.", e );
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( artifactReporter != null )
|
|
||||||
{
|
|
||||||
artifactReporter.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,47 +271,39 @@ public class RewritePhase
|
||||||
|
|
||||||
transaction.addFile( bridgedTargetPom );
|
transaction.addFile( bridgedTargetPom );
|
||||||
|
|
||||||
|
File targetPomParent = targetPom.getParentFile();
|
||||||
|
if ( !targetPomParent.exists() )
|
||||||
|
{
|
||||||
|
targetPomParent.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileWriter to = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File targetPomParent = targetPom.getParentFile();
|
StringReader from = null;
|
||||||
if ( !targetPomParent.exists() )
|
if ( pomContents != null )
|
||||||
{
|
{
|
||||||
targetPomParent.mkdirs();
|
from = new StringReader( pomContents );
|
||||||
}
|
}
|
||||||
|
|
||||||
FileWriter to = null;
|
to = new FileWriter( targetPom );
|
||||||
try
|
|
||||||
{
|
|
||||||
StringReader from = null;
|
|
||||||
if ( pomContents != null )
|
|
||||||
{
|
|
||||||
from = new StringReader( pomContents );
|
|
||||||
}
|
|
||||||
|
|
||||||
to = new FileWriter( targetPom );
|
|
||||||
|
|
||||||
artifactPomRewriter.rewrite( artifact, from, to, artifactReporter, reportOnly );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( to );
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean wroteBridge = bridgePomLocations( pom, targetPom, bridgedTargetPom, artifactReporter,
|
|
||||||
transaction, reportOnly );
|
|
||||||
|
|
||||||
digestVerifier.verifyDigest( sourcePom, targetPom, transaction, artifactReporter, reportOnly );
|
|
||||||
|
|
||||||
if ( wroteBridge )
|
|
||||||
{
|
|
||||||
digestVerifier.verifyDigest( sourcePom, bridgedTargetPom, transaction, artifactReporter,
|
|
||||||
reportOnly );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
artifactPomRewriter.rewrite( artifact, from, to, artifactReporter, reportOnly );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
finally
|
||||||
{
|
{
|
||||||
throw e;
|
IOUtil.close( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean wroteBridge = bridgePomLocations( pom, targetPom, bridgedTargetPom, artifactReporter,
|
||||||
|
transaction, reportOnly );
|
||||||
|
|
||||||
|
digestVerifier.verifyDigest( sourcePom, targetPom, transaction, artifactReporter, reportOnly );
|
||||||
|
|
||||||
|
if ( wroteBridge )
|
||||||
|
{
|
||||||
|
digestVerifier.verifyDigest( sourcePom, bridgedTargetPom, transaction, artifactReporter,
|
||||||
|
reportOnly );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -421,7 +394,7 @@ public class RewritePhase
|
||||||
+ ( ( classifier != null ) ? ( classifier + "-" ) : ( "" ) ) + version + ".report.txt";
|
+ ( ( classifier != null ) ? ( classifier + "-" ) : ( "" ) ) + version + ".report.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyArtifact( Artifact artifact, File artifactTarget, FileReporter reporter )
|
private void copyArtifact( Artifact artifact, File artifactTarget, Reporter reporter )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
File artifactSource = artifact.getFile();
|
File artifactSource = artifact.getFile();
|
||||||
|
|
|
@ -50,8 +50,12 @@ public class FileReporter
|
||||||
|
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
|
|
||||||
public FileReporter( File reportsBase, String reportPath )
|
private final boolean warningsEnabled;
|
||||||
|
|
||||||
|
public FileReporter( File reportsBase, String reportPath, boolean warningsEnabled )
|
||||||
{
|
{
|
||||||
|
this.warningsEnabled = warningsEnabled;
|
||||||
|
|
||||||
this.reportsFile = new File( reportsBase, reportPath );
|
this.reportsFile = new File( reportsBase, reportPath );
|
||||||
|
|
||||||
File parentDir = reportsFile.getParentFile();
|
File parentDir = reportsFile.getParentFile();
|
||||||
|
@ -126,22 +130,37 @@ public class FileReporter
|
||||||
public void warn( String message )
|
public void warn( String message )
|
||||||
throws ReportWriteException
|
throws ReportWriteException
|
||||||
{
|
{
|
||||||
hasWarning = true;
|
if( warningsEnabled )
|
||||||
write( new AppendingList( 2 ).append( WARN_LEVEL ).append( message ) );
|
{
|
||||||
|
hasWarning = true;
|
||||||
|
String source = getSourceLine();
|
||||||
|
write( new AppendingList( 3 ).append( WARN_LEVEL ).append( source ).append( message ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error( String message, Throwable error )
|
public void error( String message, Throwable error )
|
||||||
throws ReportWriteException
|
throws ReportWriteException
|
||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
write( new AppendingList( 3 ).append( ERROR_LEVEL ).append( message ).append( error ) );
|
String source = getSourceLine();
|
||||||
|
write( new AppendingList( 4 ).append( ERROR_LEVEL ).append( source ).append( message ).append( error ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error( String message )
|
public void error( String message )
|
||||||
throws ReportWriteException
|
throws ReportWriteException
|
||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
write( new AppendingList( 2 ).append( ERROR_LEVEL ).append( message ) );
|
String source = getSourceLine();
|
||||||
|
write( new AppendingList( 3 ).append( ERROR_LEVEL ).append( source ).append( message ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSourceLine()
|
||||||
|
{
|
||||||
|
NullPointerException npe = new NullPointerException();
|
||||||
|
|
||||||
|
StackTraceElement element = npe.getStackTrace()[2];
|
||||||
|
|
||||||
|
return " Reported from: (" + element.getClassName() + "." + element.getMethodName() + "(..):" + element.getLineNumber() + ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence format( List messageParts )
|
private CharSequence format( List messageParts )
|
||||||
|
|
|
@ -43,24 +43,10 @@ public class V3PomRewriter
|
||||||
|
|
||||||
if( from != null )
|
if( from != null )
|
||||||
{
|
{
|
||||||
org.apache.maven.model.v3_0_0.Model v3Model = null;
|
MavenXpp3Reader v3Reader = new MavenXpp3Reader();
|
||||||
try
|
|
||||||
{
|
|
||||||
MavenXpp3Reader v3Reader = new MavenXpp3Reader();
|
|
||||||
|
|
||||||
v3Model = v3Reader.read( from );
|
org.apache.maven.model.v3_0_0.Model v3Model = v3Reader.read( from );
|
||||||
}
|
v4Model = translator.translate( v3Model, reporter );
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
reporter.error( "Invalid v3 POM at: \'" + from + "\'. Cannot read.", e );
|
|
||||||
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( v3Model != null )
|
|
||||||
{
|
|
||||||
v4Model = translator.translate( v3Model, reporter );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue