You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/02/25 23:15:57 UTC
[maven-integration-testing] branch MNG-6656 updated: Pom will be
read again for build/consumer
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-6656
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git
The following commit(s) were added to refs/heads/MNG-6656 by this push:
new 662241a Pom will be read again for build/consumer
662241a is described below
commit 662241aa3599bdd52e8a4e8a1bca34fc47fa79ff
Author: rfscholte <rf...@apache.org>
AuthorDate: Wed Feb 26 00:15:42 2020 +0100
Pom will be read again for build/consumer
---
.../maven/it/MavenITmng5669ReadPomsOnce.java | 57 +++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5669ReadPomsOnce.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5669ReadPomsOnce.java
index 26944d2..7bfccb9 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5669ReadPomsOnce.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5669ReadPomsOnce.java
@@ -45,7 +45,7 @@ public class MavenITmng5669ReadPomsOnce
super( "[3.7.0,)" );
}
- public void test()
+ public void testWithoutBuildConsumer()
throws Exception
{
// prepare JavaAgent
@@ -61,6 +61,7 @@ public class MavenITmng5669ReadPomsOnce
verifier.setAutoclean( false );
verifier.addCliOption( "-q" );
verifier.addCliOption( "-U" );
+ verifier.addCliOption( "-Dmaven.experimental.buildconsumer=false" );
verifier.executeGoals( Arrays.asList( "verify" ) );
verifier.resetStreams();
@@ -96,4 +97,58 @@ public class MavenITmng5669ReadPomsOnce
}
assertEquals( uniqueBuildingSources.size(), 167 /* is 168 minus superpom */ );
}
+
+ public void testWithBuildConsumer()
+ throws Exception
+ {
+ // prepare JavaAgent
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5669-read-poms-once" );
+ Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
+ Map<String, String> filterProperties =
+ Collections.singletonMap( "${javaAgentJar}",
+ verifier.getArtifactPath( "mng-coreit", "javaagent", "1.0-SNAPSHOT", "jar" ) );
+ verifier.filterFile( ".mvn/jvm.config", ".mvn/jvm.config", null, filterProperties );
+
+ verifier.setForkJvm( true ); // pick up agent
+ verifier.setMavenDebug( false );
+ verifier.setAutoclean( false );
+ verifier.addCliOption( "-q" );
+ verifier.addCliOption( "-U" );
+ verifier.addCliOption( "-Dmaven.experimental.buildconsumer=true" );
+ verifier.executeGoals( Arrays.asList( "verify" ) );
+ verifier.resetStreams();
+
+ List<String> logTxt = verifier.loadLines( "log.txt", "utf-8" );
+ for ( String line : logTxt )
+ {
+ if ( line.startsWith( "Picked up JAVA_TOOL_OPTIONS:" ) )
+ {
+ logTxt.remove( line );
+ break;
+ }
+ }
+ assertEquals( logTxt.toString(), 168 + 4 /* reactor poms are read twice: file + raw (=XMLFilters) */, logTxt.size() );
+
+ // analyze lines. It is a Hashmap, so we can't rely on the order
+ Set<String> uniqueBuildingSources = new HashSet<>( 168 );
+ final String buildSourceKey = "org.apache.maven.model.building.source=";
+ final int keyLength = buildSourceKey.length();
+ for( String line : logTxt )
+ {
+ int start = line.indexOf( buildSourceKey );
+ if ( start < 0 )
+ {
+ continue;
+ }
+
+ int end = line.indexOf(", ", start);
+ if ( end < 0)
+ {
+ end = line.length() - 1; // is the }
+ }
+ uniqueBuildingSources.add( line.substring( start + keyLength, end ) );
+ }
+ assertEquals( uniqueBuildingSources.size(), 167 /* is 168 minus superpom */ );
+ }
+
}