2727import eu .maveniverse .maven .mimir .testing .MimirInfuser ;
2828import org .apache .maven .api .cli .Executor ;
2929import org .apache .maven .api .cli .ExecutorRequest ;
30+ import org .apache .maven .cling .executor .Environment ;
3031import org .apache .maven .cling .executor .ExecutorHelper ;
3132import org .apache .maven .cling .executor .embedded .EmbeddedMavenExecutor ;
3233import org .apache .maven .cling .executor .forked .ForkedMavenExecutor ;
@@ -48,24 +49,33 @@ public class ToolboxToolTest {
4849 private static final Executor EMBEDDED_MAVEN_EXECUTOR = new EmbeddedMavenExecutor ();
4950 private static final Executor FORKED_MAVEN_EXECUTOR = new ForkedMavenExecutor ();
5051
51- public static final String TOOLBOX_VERSION = System .getProperty ("version.toolbox" );
52-
5352 @ TempDir (cleanup = CleanupMode .NEVER )
5453 private static Path tempDir ;
5554
5655 private Path userHome ;
56+ private Path cwd ;
5757
5858 @ BeforeEach
5959 void beforeEach (TestInfo testInfo ) throws Exception {
60- userHome = tempDir .resolve (testInfo .getTestMethod ().orElseThrow ().getName ());
61- Files .createDirectories (userHome );
62- MimirInfuser .infuseUW (userHome );
60+ String testName = testInfo .getTestMethod ().orElseThrow ().getName ();
61+ userHome = tempDir .resolve (testName );
62+ cwd = userHome .resolve ("cwd" );
63+ Files .createDirectories (cwd );
64+
65+ if (MimirInfuser .isMimirPresentUW ()) {
66+ if (testName .contains ("3" )) {
67+ MimirInfuser .doInfusePW (Environment .MIMIR_VERSION , cwd , userHome );
68+ } else {
69+ MimirInfuser .doInfuseUW (Environment .MIMIR_VERSION , userHome );
70+ }
71+ }
6372
6473 System .out .println ("=== " + testInfo .getTestMethod ().orElseThrow ().getName ());
6574 }
6675
6776 private ExecutorRequest .Builder getExecutorRequest (ExecutorHelper helper ) {
68- ExecutorRequest .Builder builder = helper .executorRequest ();
77+ ExecutorRequest .Builder builder =
78+ helper .executorRequest ().cwd (cwd ).argument ("-Daether.remoteRepositoryFilter.prefixes=false" );
6979 if (System .getProperty ("localRepository" ) != null ) {
7080 builder .argument ("-Dmaven.repo.local.tail=" + System .getProperty ("localRepository" ));
7181 }
@@ -77,7 +87,8 @@ private ExecutorRequest.Builder getExecutorRequest(ExecutorHelper helper) {
7787 void dump3 (ExecutorHelper .Mode mode ) throws Exception {
7888 ExecutorHelper helper =
7989 new HelperImpl (mode , mvn3Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
80- Map <String , String > dump = new ToolboxTool (helper , TOOLBOX_VERSION ).dump (getExecutorRequest (helper ));
90+ Map <String , String > dump =
91+ new ToolboxTool (helper , Environment .TOOLBOX_VERSION ).dump (getExecutorRequest (helper ));
8192 System .out .println (mode .name () + ": " + dump .toString ());
8293 assertEquals (System .getProperty ("maven3version" ), dump .get ("maven.version" ));
8394 }
@@ -87,7 +98,8 @@ void dump3(ExecutorHelper.Mode mode) throws Exception {
8798 void dump4 (ExecutorHelper .Mode mode ) throws Exception {
8899 ExecutorHelper helper =
89100 new HelperImpl (mode , mvn4Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
90- Map <String , String > dump = new ToolboxTool (helper , TOOLBOX_VERSION ).dump (getExecutorRequest (helper ));
101+ Map <String , String > dump =
102+ new ToolboxTool (helper , Environment .TOOLBOX_VERSION ).dump (getExecutorRequest (helper ));
91103 System .out .println (mode .name () + ": " + dump .toString ());
92104 assertEquals (System .getProperty ("maven4version" ), dump .get ("maven.version" ));
93105 }
@@ -115,7 +127,8 @@ void version4(ExecutorHelper.Mode mode) {
115127 void localRepository3 (ExecutorHelper .Mode mode ) {
116128 ExecutorHelper helper =
117129 new HelperImpl (mode , mvn3Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
118- String localRepository = new ToolboxTool (helper , TOOLBOX_VERSION ).localRepository (getExecutorRequest (helper ));
130+ String localRepository =
131+ new ToolboxTool (helper , Environment .TOOLBOX_VERSION ).localRepository (getExecutorRequest (helper ));
119132 System .out .println (mode .name () + ": " + localRepository );
120133 Path local = Paths .get (localRepository );
121134 assertTrue (Files .isDirectory (local ));
@@ -126,7 +139,8 @@ void localRepository3(ExecutorHelper.Mode mode) {
126139 void localRepository4 (ExecutorHelper .Mode mode ) {
127140 ExecutorHelper helper =
128141 new HelperImpl (mode , mvn4Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
129- String localRepository = new ToolboxTool (helper , TOOLBOX_VERSION ).localRepository (getExecutorRequest (helper ));
142+ String localRepository =
143+ new ToolboxTool (helper , Environment .TOOLBOX_VERSION ).localRepository (getExecutorRequest (helper ));
130144 System .out .println (mode .name () + ": " + localRepository );
131145 Path local = Paths .get (localRepository );
132146 assertTrue (Files .isDirectory (local ));
@@ -137,7 +151,7 @@ void localRepository4(ExecutorHelper.Mode mode) {
137151 void artifactPath3 (ExecutorHelper .Mode mode ) {
138152 ExecutorHelper helper =
139153 new HelperImpl (mode , mvn3Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
140- String path = new ToolboxTool (helper , TOOLBOX_VERSION )
154+ String path = new ToolboxTool (helper , Environment . TOOLBOX_VERSION )
141155 .artifactPath (getExecutorRequest (helper ), "aopalliance:aopalliance:1.0" , "central" );
142156 System .out .println (mode .name () + ": " + path );
143157 // split repository: assert "ends with" as split may introduce prefixes
@@ -152,7 +166,7 @@ void artifactPath3(ExecutorHelper.Mode mode) {
152166 void artifactPath4 (ExecutorHelper .Mode mode ) {
153167 ExecutorHelper helper =
154168 new HelperImpl (mode , mvn4Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
155- String path = new ToolboxTool (helper , TOOLBOX_VERSION )
169+ String path = new ToolboxTool (helper , Environment . TOOLBOX_VERSION )
156170 .artifactPath (getExecutorRequest (helper ), "aopalliance:aopalliance:1.0" , "central" );
157171 System .out .println (mode .name () + ": " + path );
158172 // split repository: assert "ends with" as split may introduce prefixes
@@ -167,7 +181,7 @@ void artifactPath4(ExecutorHelper.Mode mode) {
167181 void metadataPath3 (ExecutorHelper .Mode mode ) {
168182 ExecutorHelper helper =
169183 new HelperImpl (mode , mvn4Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
170- String path = new ToolboxTool (helper , TOOLBOX_VERSION )
184+ String path = new ToolboxTool (helper , Environment . TOOLBOX_VERSION )
171185 .metadataPath (getExecutorRequest (helper ), "aopalliance" , "someremote" );
172186 System .out .println (mode .name () + ": " + path );
173187 // split repository: assert "ends with" as split may introduce prefixes
@@ -179,7 +193,7 @@ void metadataPath3(ExecutorHelper.Mode mode) {
179193 void metadataPath4 (ExecutorHelper .Mode mode ) {
180194 ExecutorHelper helper =
181195 new HelperImpl (mode , mvn4Home (), userHome , EMBEDDED_MAVEN_EXECUTOR , FORKED_MAVEN_EXECUTOR );
182- String path = new ToolboxTool (helper , TOOLBOX_VERSION )
196+ String path = new ToolboxTool (helper , Environment . TOOLBOX_VERSION )
183197 .metadataPath (getExecutorRequest (helper ), "aopalliance" , "someremote" );
184198 System .out .println (mode .name () + ": " + path );
185199 // split repository: assert "ends with" as split may introduce prefixes
0 commit comments