Switch to Maven 4.0.0-alpha-8 (#895)

This commit is contained in:
Guillaume Nodet
2023-10-25 17:03:53 +02:00
committed by GitHub
parent acf64a7fab
commit dc4179fc3b
3 changed files with 33 additions and 29 deletions

View File

@@ -18,6 +18,8 @@
*/ */
package org.mvndaemon.mvnd.client; package org.mvndaemon.mvnd.client;
import javax.xml.stream.XMLStreamException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -41,9 +43,8 @@ import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.maven.cli.internal.extension.io.CoreExtensionsStaxReader;
import org.apache.maven.cli.internal.extension.model.CoreExtension; import org.apache.maven.cli.internal.extension.model.CoreExtension;
import org.apache.maven.cli.internal.extension.model.io.xpp3.CoreExtensionsXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.mvndaemon.mvnd.common.Environment; import org.mvndaemon.mvnd.common.Environment;
import org.mvndaemon.mvnd.common.InterpolationHelper; import org.mvndaemon.mvnd.common.InterpolationHelper;
import org.mvndaemon.mvnd.common.Os; import org.mvndaemon.mvnd.common.Os;
@@ -449,7 +450,7 @@ public class DaemonParameters {
.map(e -> e.getGroupId() + ":" + e.getArtifactId() + ":" + e.getVersion()) .map(e -> e.getGroupId() + ":" + e.getArtifactId() + ":" + e.getVersion())
.collect(Collectors.toList()); .collect(Collectors.toList());
return String.join(";", extensions); return String.join(";", extensions);
} catch (IOException | XmlPullParserException e) { } catch (IOException | XMLStreamException e) {
throw new RuntimeException("Unable to parse core extensions", e); throw new RuntimeException("Unable to parse core extensions", e);
} }
} else { } else {
@@ -470,7 +471,7 @@ public class DaemonParameters {
} }
private static List<CoreExtension> readCoreExtensionsDescriptor(Path multiModuleProjectDirectory) private static List<CoreExtension> readCoreExtensionsDescriptor(Path multiModuleProjectDirectory)
throws IOException, XmlPullParserException { throws IOException, XMLStreamException {
if (multiModuleProjectDirectory == null) { if (multiModuleProjectDirectory == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -478,7 +479,7 @@ public class DaemonParameters {
if (!Files.exists(extensionsFile)) { if (!Files.exists(extensionsFile)) {
return Collections.emptyList(); return Collections.emptyList();
} }
CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader(); CoreExtensionsStaxReader parser = new CoreExtensionsStaxReader();
try (InputStream is = Files.newInputStream(extensionsFile)) { try (InputStream is = Files.newInputStream(extensionsFile)) {
return parser.read(is).getExtensions(); return parser.read(is).getExtensions();
} }

View File

@@ -287,10 +287,10 @@ public class DaemonMavenCli implements DaemonCli {
} }
topDirectory = getCanonicalPath(topDirectory); topDirectory = getCanonicalPath(topDirectory);
cliRequest.topDirectory = topDirectory; cliRequest.topDirectory = topDirectory;
// We're very early in the process and we don't have the container set up yet, // We're very early in the process, and we don't have the container set up yet,
// so we rely on the JDK services to eventually look up a custom RootLocator. // so we rely on the JDK services to eventually look up a custom RootLocator.
// This is used to compute {@code session.rootDirectory} but all {@code project.rootDirectory} // This is used to compute {@code session.rootDirectory} but all {@code project.rootDirectory}
// properties will be compute through the RootLocator found in the container. // properties will be computed through the RootLocator found in the container.
RootLocator rootLocator = RootLocator rootLocator =
ServiceLoader.load(RootLocator.class).iterator().next(); ServiceLoader.load(RootLocator.class).iterator().next();
Path rootDirectory = rootLocator.findRoot(topDirectory); Path rootDirectory = rootLocator.findRoot(topDirectory);
@@ -495,6 +495,7 @@ public class DaemonMavenCli implements DaemonCli {
if (MessageUtils.isColorEnabled()) { if (MessageUtils.isColorEnabled()) {
MessageBuilder buff = MessageUtils.builder(); MessageBuilder buff = MessageUtils.builder();
buff.a("Message styles: "); buff.a("Message styles: ");
buff.trace("trace").a(' ');
buff.debug("debug").a(' '); buff.debug("debug").a(' ');
buff.info("info").a(' '); buff.info("info").a(' ');
buff.warning("warning").a(' '); buff.warning("warning").a(' ');
@@ -571,10 +572,11 @@ public class DaemonMavenCli implements DaemonCli {
.filter(s -> s != null && !s.isEmpty()) .filter(s -> s != null && !s.isEmpty())
.map(s -> { .map(s -> {
String[] parts = s.split(":"); String[] parts = s.split(":");
CoreExtension ce = new CoreExtension(); CoreExtension ce = CoreExtension.newBuilder()
ce.setGroupId(parts[0]); .groupId(parts[0])
ce.setArtifactId(parts[1]); .artifactId(parts[1])
ce.setVersion(parts[2]); .version(parts[2])
.build();
return ce; return ce;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -623,11 +625,18 @@ public class DaemonMavenCli implements DaemonCli {
container.setLoggerManager(plexusLoggerManager); container.setLoggerManager(plexusLoggerManager);
AbstractValueSource extensionSource = new AbstractValueSource(false) {
@Override
public Object getValue(String expression) {
return null;
}
};
for (CoreExtensionEntry extension : extensionsEntries) { for (CoreExtensionEntry extension : extensionsEntries) {
container.discoverComponents( container.discoverComponents(
extension.getClassRealm(), extension.getClassRealm(),
new SessionScopeModule(container), new SessionScopeModule(container),
new MojoExecutionScopeModule(container)); new MojoExecutionScopeModule(container),
new ExtensionConfigurationModule(extension, extensionSource));
} }
return container; return container;
} }
@@ -1181,12 +1190,12 @@ public class DaemonMavenCli implements DaemonCli {
} }
private String determineLocalRepositoryPath(final MavenExecutionRequest request) { private String determineLocalRepositoryPath(final MavenExecutionRequest request) {
String userDefinedLocalRepo = request.getUserProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY); String userDefinedLocalRepo = request.getUserProperties().getProperty(DaemonMavenCli.LOCAL_REPO_PROPERTY);
if (userDefinedLocalRepo != null) { if (userDefinedLocalRepo != null) {
return userDefinedLocalRepo; return userDefinedLocalRepo;
} }
return request.getSystemProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY); return request.getSystemProperties().getProperty(DaemonMavenCli.LOCAL_REPO_PROPERTY);
} }
private File determinePom( private File determinePom(
@@ -1199,22 +1208,16 @@ public class DaemonMavenCli implements DaemonCli {
alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE); alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
} }
File current = baseDirectory;
if (alternatePomFile != null) { if (alternatePomFile != null) {
File pom = resolveFile(new File(alternatePomFile), workingDirectory); current = resolveFile(new File(alternatePomFile), workingDirectory);
if (pom.isDirectory()) {
pom = new File(pom, "pom.xml");
}
return pom;
} else if (modelProcessor != null) {
File pom = modelProcessor.locatePom(baseDirectory);
if (pom.isFile()) {
return pom;
}
} }
return null; if (modelProcessor != null) {
return modelProcessor.locateExistingPom(current);
} else {
return current.isFile() ? current : null;
}
} }
// Visible for testing // Visible for testing

View File

@@ -88,7 +88,7 @@
<jansi.version>2.4.0</jansi.version> <jansi.version>2.4.0</jansi.version>
<jline.version>3.23.0</jline.version> <jline.version>3.23.0</jline.version>
<junit.jupiter.version>5.9.2</junit.jupiter.version> <junit.jupiter.version>5.9.2</junit.jupiter.version>
<maven.version>4.0.0-alpha-7</maven.version> <maven.version>4.0.0-alpha-8</maven.version>
<maven3.version>3.9.5</maven3.version> <maven3.version>3.9.5</maven3.version>
<maven4.version>${maven.version}</maven4.version> <maven4.version>${maven.version}</maven4.version>
<!-- Keep in sync with Maven --> <!-- Keep in sync with Maven -->
@@ -113,7 +113,7 @@
<maven-assembly-plugin.version>3.6.0</maven-assembly-plugin.version> <maven-assembly-plugin.version>3.6.0</maven-assembly-plugin.version>
<xstream.version>1.4.20</xstream.version> <xstream.version>1.4.20</xstream.version>
<plexus-interactivity-api.version>1.0</plexus-interactivity-api.version> <plexus-interactivity-api.version>1.0</plexus-interactivity-api.version>
<takari-smart-builder.version>0.6.3</takari-smart-builder.version> <takari-smart-builder.version>0.6.4</takari-smart-builder.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>