1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.util.ResourceExtractor;
23
24 import java.io.File;
25 import java.util.LinkedList;
26 import java.util.List;
27
28
29
30
31
32
33
34
35 public class MavenITmng6057CheckReactorOrderTest
36 extends AbstractMavenIntegrationTestCase
37 {
38
39 public MavenITmng6057CheckReactorOrderTest()
40 {
41
42
43 super( "[3.5.0-alpha-2,)" );
44 }
45
46
47
48
49
50
51 public void testitReactorShouldResultInExpectedOrder()
52 throws Exception
53 {
54 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6057-check-reactor-order" );
55
56 Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
57 verifier.setMavenDebug( false );
58 verifier.setAutoclean( false );
59
60 verifier.setLogFileName( "log-only.txt" );
61 verifier.addCliOption( "-Drevision=1.3.0-SNAPSHOT" );
62 verifier.executeGoal( "clean" );
63 verifier.verifyErrorFreeLog();
64 verifier.resetStreams();
65
66 List<String> loadedLines = verifier.loadLines( "log-only.txt", "UTF-8" );
67 List<String> resultingLines = extractReactorBuildOrder( loadedLines );
68
69
70 assertEquals( 3, resultingLines.size() );
71
72
73 assertTrue( resultingLines.get( 0 ).startsWith( "[INFO] base-project" ) );
74 assertTrue( resultingLines.get( 1 ).startsWith( "[INFO] module-1" ) );
75 assertTrue( resultingLines.get( 2 ).startsWith( "[INFO] module-2" ) );
76 }
77
78
79
80
81
82
83
84
85
86
87
88
89
90 private List<String> extractReactorBuildOrder( List<String> loadedLines )
91 {
92 List<String> resultingLines = new LinkedList<String>();
93 boolean start = false;
94 for ( String line : loadedLines )
95 {
96 if ( start )
97 {
98 if ( line.startsWith( "[INFO] -------------" ) )
99 {
100 start = false;
101 }
102 else if ( !line.endsWith( "[INFO] " ) )
103 {
104 resultingLines.add( line );
105 }
106 }
107 else
108 {
109 if ( line.startsWith( "[INFO] Reactor Build Order:" ) )
110 {
111 start = true;
112 }
113
114 }
115 }
116 return resultingLines;
117
118 }
119
120 }