[MNG-6229] Write out optionality in Core IT Plugins for collection and resolution

Write out " (optional)" in the log entry as well as to the file for later
analysis.
This commit is contained in:
Michael Osipov 2017-05-09 23:26:51 +02:00
parent e2c15f1a90
commit 9abd8fdc48
3 changed files with 21 additions and 9 deletions

View File

@ -27,7 +27,7 @@ import java.util.List;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-947">MNG-947</a>.
*
*
* @author Benjamin Bentmann
*/
public class MavenITmng0947OptionalDependencyTest
@ -60,20 +60,20 @@ public class MavenITmng0947OptionalDependencyTest
verifier.resetStreams();
List<String> compile = verifier.loadLines( "target/compile.txt", "UTF-8" );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:d:jar:0.1" ) );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:e:jar:0.1" ) );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:d:jar:0.1 (optional)" ) );
assertTrue( compile.toString(), compile.contains( "org.apache.maven.its.mng0947:e:jar:0.1 (optional)" ) );
assertEquals( 2, compile.size() );
List<String> runtime = verifier.loadLines( "target/runtime.txt", "UTF-8" );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:c:jar:0.1" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:d:jar:0.1" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:e:jar:0.1" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:d:jar:0.1 (optional)" ) );
assertTrue( runtime.toString(), runtime.contains( "org.apache.maven.its.mng0947:e:jar:0.1 (optional)" ) );
assertEquals( 3, runtime.size() );
List<String> test = verifier.loadLines( "target/test.txt", "UTF-8" );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:c:jar:0.1" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:d:jar:0.1" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:e:jar:0.1" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:d:jar:0.1 (optional)" ) );
assertTrue( test.toString(), test.contains( "org.apache.maven.its.mng0947:e:jar:0.1 (optional)" ) );
assertEquals( 3, test.size() );
}

View File

@ -83,8 +83,14 @@ public abstract class AbstractDependencyMojo
{
Artifact artifact = (Artifact) artifact1;
writer.write( artifact.getId() );
String optional = "";
if ( artifact.isOptional() )
{
optional = " (optional)";
writer.write( optional );
}
writer.newLine();
getLog().info( "[MAVEN-CORE-IT-LOG] " + artifact.getId() );
getLog().info( "[MAVEN-CORE-IT-LOG] " + artifact.getId() + optional );
}
}
}

View File

@ -100,8 +100,14 @@ public abstract class AbstractDependencyMojo
Artifact artifact = (Artifact) artifact1;
String id = getId( artifact );
writer.write( id );
String optional = "";
if ( artifact.isOptional() )
{
optional = " (optional)";
writer.write( optional );
}
writer.newLine();
getLog().info( "[MAVEN-CORE-IT-LOG] " + id );
getLog().info( "[MAVEN-CORE-IT-LOG] " + id + optional );
}
}
}