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
Original file line number Diff line number Diff line change
Expand Up @@ -1723,11 +1723,7 @@ private static String stripLeadingAndTrailingQuotes(String str) {
}

private static Path getCanonicalPath(Path path) {
try {
return path.toRealPath();
} catch (IOException e) {
return getCanonicalPath(path.getParent()).resolve(path.getFileName());
}
return path.toAbsolutePath().normalize();
}

static class ExitException extends Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.maven.cling.invoker;

import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -60,11 +59,7 @@ public static String stripLeadingAndTrailingQuotes(String str) {
@Nonnull
public static Path getCanonicalPath(Path path) {
requireNonNull(path, "path");
try {
return path.toRealPath();
} catch (IOException e) {
return getCanonicalPath(path.getParent()).resolve(path.getFileName());
}
return path.toAbsolutePath().normalize();
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.maven.api.cli;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
Expand Down Expand Up @@ -401,9 +400,13 @@ private Impl(
this.cwd = getCanonicalPath(requireNonNull(cwd));
this.installationDirectory = getCanonicalPath(requireNonNull(installationDirectory));
this.userHomeDirectory = getCanonicalPath(requireNonNull(userHomeDirectory));
this.jvmSystemProperties = jvmSystemProperties != null ? Map.copyOf(jvmSystemProperties) : null;
this.environmentVariables = environmentVariables != null ? Map.copyOf(environmentVariables) : null;
this.jvmArguments = jvmArguments != null ? List.copyOf(jvmArguments) : null;
this.jvmSystemProperties = jvmSystemProperties != null && !jvmSystemProperties.isEmpty()
? Map.copyOf(jvmSystemProperties)
: null;
this.environmentVariables = environmentVariables != null && !environmentVariables.isEmpty()
? Map.copyOf(environmentVariables)
: null;
this.jvmArguments = jvmArguments != null && !jvmArguments.isEmpty() ? List.copyOf(jvmArguments) : null;
this.stdIn = stdIn;
this.stdOut = stdOut;
this.stdErr = stdErr;
Expand Down Expand Up @@ -510,10 +513,6 @@ static Path discoverUserHomeDirectory() {
@Nonnull
static Path getCanonicalPath(Path path) {
requireNonNull(path, "path");
try {
return path.toRealPath();
} catch (IOException e) {
return getCanonicalPath(path.getParent()).resolve(path.getFileName());
}
return path.toAbsolutePath().normalize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,12 @@ protected Context doCreate(Path mavenHome, ExecutorRequest executorRequest) {
getClass().getSimpleName() + " does not support command " + executorRequest.command());
}
if (executorRequest.environmentVariables().isPresent()) {
throw new IllegalArgumentException(getClass().getSimpleName() + " does not support environment variables");
throw new IllegalArgumentException(getClass().getSimpleName() + " does not support environment variables: "
+ executorRequest.environmentVariables().get());
}
if (executorRequest.jvmArguments().isPresent()) {
throw new IllegalArgumentException(getClass().getSimpleName() + " does not support jvmArguments");
throw new IllegalArgumentException(getClass().getSimpleName() + " does not support jvmArguments: "
+ executorRequest.jvmArguments().get());
}
Path boot = mavenHome.resolve("boot");
Path m2conf = mavenHome.resolve("bin/m2.conf");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.maven.cling.executor.internal;

import java.nio.file.Path;
import java.util.Collections;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -94,8 +93,7 @@ protected Executor getExecutor(Mode mode, ExecutorRequest request) throws Execut
}

private Executor getExecutorByRequest(ExecutorRequest request) {
if (request.environmentVariables().orElse(Collections.emptyMap()).isEmpty()
&& request.jvmArguments().orElse(Collections.emptyList()).isEmpty()) {
if (request.environmentVariables().isEmpty() && request.jvmArguments().isEmpty()) {
return getExecutor(Mode.EMBEDDED, request);
} else {
return getExecutor(Mode.FORKED, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ protected Optional<Path> getRootDirectoryFallback() {
}

protected Path getCanonicalPath(Path path) {
try {
return path.toRealPath();
} catch (IOException e) {
return getCanonicalPath(path.getParent()).resolve(path.getFileName());
}
return path.toAbsolutePath().normalize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ public void testitModel() throws Exception {
verifier.addCliArgument("--settings=settings.xml");
verifier.addCliArgument("-Dmaven.repo.local=" + testDir.toPath().resolve("target/local-repo"));
verifier.addCliArgument("-Dmaven.repo.local.tail=target/null");
verifier.addCliArgument("-Dmaven.repo.central=http://repo1.maven.org/");
// note: intentionally bad URL, we just want tu ensure that this bad URL is used
verifier.addCliArgument("-Dmaven.repo.central=https://repo1.maven.org");
verifier.addCliArgument("validate");
verifier.setHandleLocalRepoTail(false); // we want isolation to have Maven fail due non-HTTPS repo
verifier.setHandleLocalRepoTail(false); // we want isolation to have Maven fail due bad URL
assertThrows(VerificationException.class, verifier::execute);
verifier.verifyTextInLog("central (http://repo1.maven.org/, default, releases)");
// error is
// PluginResolutionException: Plugin eu.maveniverse.maven.mimir:extension3:XXX or one of its dependencies could
// not be resolved:
// Could not find artifact eu.maveniverse.maven.mimir:extension3:jar:XXX in central (https://repo1.maven.org)
verifier.verifyTextInLog("central (https://repo1.maven.org)");
}
}