Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions impl/maven-executor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ under the License.
<maven4version>${maven4version}</maven4version>
<maven3home>${project.build.directory}/dependency/apache-maven-${maven3version}</maven3home>
<maven4home>${project.build.directory}/dependency/apache-maven-${maven4version}</maven4home>
<localRepository>${settings.localRepository}</localRepository>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.file.Paths;
import java.util.Map;

import org.apache.maven.api.cli.ExecutorRequest;
import org.apache.maven.cling.executor.ExecutorHelper;
import org.apache.maven.cling.executor.MavenExecutorTestSupport;
import org.apache.maven.cling.executor.MimirInfuser;
Expand All @@ -50,6 +51,14 @@ static void beforeAll() throws Exception {
MimirInfuser.infuse(userHome);
}

private ExecutorRequest.Builder getExecutorRequest(ExecutorHelper helper) {
ExecutorRequest.Builder builder = helper.executorRequest();
if (System.getProperty("localRepository") != null) {
builder.argument("-Dmaven.repo.local.tail=" + System.getProperty("localRepository"));
}
return builder;
}

@Timeout(15)
@ParameterizedTest
@EnumSource(ExecutorHelper.Mode.class)
Expand All @@ -60,7 +69,7 @@ void dump3(ExecutorHelper.Mode mode) throws Exception {
userHome,
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
Map<String, String> dump = new ToolboxTool(helper).dump(helper.executorRequest());
Map<String, String> dump = new ToolboxTool(helper).dump(getExecutorRequest(helper));
assertEquals(System.getProperty("maven3version"), dump.get("maven.version"));
}

Expand All @@ -74,7 +83,7 @@ void dump4(ExecutorHelper.Mode mode) throws Exception {
userHome,
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
Map<String, String> dump = new ToolboxTool(helper).dump(helper.executorRequest());
Map<String, String> dump = new ToolboxTool(helper).dump(getExecutorRequest(helper));
assertEquals(System.getProperty("maven4version"), dump.get("maven.version"));
}

Expand Down Expand Up @@ -114,7 +123,7 @@ void localRepository3(ExecutorHelper.Mode mode) {
userHome,
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
String localRepository = new ToolboxTool(helper).localRepository(helper.executorRequest());
String localRepository = new ToolboxTool(helper).localRepository(getExecutorRequest(helper));
Path local = Paths.get(localRepository);
assertTrue(Files.isDirectory(local));
}
Expand All @@ -130,7 +139,7 @@ void localRepository4(ExecutorHelper.Mode mode) {
userHome,
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
String localRepository = new ToolboxTool(helper).localRepository(helper.executorRequest());
String localRepository = new ToolboxTool(helper).localRepository(getExecutorRequest(helper));
Path local = Paths.get(localRepository);
assertTrue(Files.isDirectory(local));
}
Expand All @@ -146,7 +155,7 @@ void artifactPath3(ExecutorHelper.Mode mode) {
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
String path = new ToolboxTool(helper)
.artifactPath(helper.executorRequest(), "aopalliance:aopalliance:1.0", "central");
.artifactPath(getExecutorRequest(helper), "aopalliance:aopalliance:1.0", "central");
// split repository: assert "ends with" as split may introduce prefixes
assertTrue(
path.endsWith("aopalliance" + File.separator + "aopalliance" + File.separator + "1.0" + File.separator
Expand All @@ -165,7 +174,7 @@ void artifactPath4(ExecutorHelper.Mode mode) {
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
String path = new ToolboxTool(helper)
.artifactPath(helper.executorRequest(), "aopalliance:aopalliance:1.0", "central");
.artifactPath(getExecutorRequest(helper), "aopalliance:aopalliance:1.0", "central");
// split repository: assert "ends with" as split may introduce prefixes
assertTrue(
path.endsWith("aopalliance" + File.separator + "aopalliance" + File.separator + "1.0" + File.separator
Expand All @@ -183,7 +192,7 @@ void metadataPath3(ExecutorHelper.Mode mode) {
userHome,
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
String path = new ToolboxTool(helper).metadataPath(helper.executorRequest(), "aopalliance", "someremote");
String path = new ToolboxTool(helper).metadataPath(getExecutorRequest(helper), "aopalliance", "someremote");
// split repository: assert "ends with" as split may introduce prefixes
assertTrue(path.endsWith("aopalliance" + File.separator + "maven-metadata-someremote.xml"), "path=" + path);
}
Expand All @@ -198,7 +207,7 @@ void metadataPath4(ExecutorHelper.Mode mode) {
userHome,
MavenExecutorTestSupport.EMBEDDED_MAVEN_EXECUTOR,
MavenExecutorTestSupport.FORKED_MAVEN_EXECUTOR);
String path = new ToolboxTool(helper).metadataPath(helper.executorRequest(), "aopalliance", "someremote");
String path = new ToolboxTool(helper).metadataPath(getExecutorRequest(helper), "aopalliance", "someremote");
// split repository: assert "ends with" as split may introduce prefixes
assertTrue(path.endsWith("aopalliance" + File.separator + "maven-metadata-someremote.xml"), "path=" + path);
}
Expand Down
13 changes: 13 additions & 0 deletions impl/maven-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,17 @@ under the License.
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<localRepository>${settings.localRepository}</localRepository>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.impl.standalone;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -56,9 +57,13 @@ class RequestTraceTest {

@Test
void testTraces() {
Session session = ApiRunner.createSession(injector -> {
injector.bindInstance(RequestTraceTest.class, this);
});
Path localRepo =
System.getProperty("localRepository") != null ? Path.of(System.getProperty("localRepository")) : null;
Session session = ApiRunner.createSession(
injector -> {
injector.bindInstance(RequestTraceTest.class, this);
},
localRepo);

ModelBuilder builder = session.getService(ModelBuilder.class);
ModelBuilderResult result = builder.newSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.impl.standalone;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.apache.maven.api.ArtifactCoordinates;
Expand Down Expand Up @@ -46,9 +47,14 @@ class TestApiStandalone {

@Test
void testStandalone() {
Session session = ApiRunner.createSession(injector -> {
injector.bindInstance(TestApiStandalone.class, this);
});
Path localRepo =
System.getProperty("localRepository") != null ? Path.of(System.getProperty("localRepository")) : null;

Session session = ApiRunner.createSession(
injector -> {
injector.bindInstance(TestApiStandalone.class, this);
},
localRepo);

ModelBuilder builder = session.getService(ModelBuilder.class);
ModelBuilderResult result = builder.newSession()
Expand Down