Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Maven 4.0.0-alpha-8 #895

Merged
merged 4 commits into from
Oct 25, 2023
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 @@ -18,6 +18,8 @@
*/
package org.mvndaemon.mvnd.client;

import javax.xml.stream.XMLStreamException;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -41,9 +43,8 @@
import java.util.stream.Collectors;
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.io.xpp3.CoreExtensionsXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.mvndaemon.mvnd.common.Environment;
import org.mvndaemon.mvnd.common.InterpolationHelper;
import org.mvndaemon.mvnd.common.Os;
Expand Down Expand Up @@ -449,7 +450,7 @@ private String defaultValue(Environment env) {
.map(e -> e.getGroupId() + ":" + e.getArtifactId() + ":" + e.getVersion())
.collect(Collectors.toList());
return String.join(";", extensions);
} catch (IOException | XmlPullParserException e) {
} catch (IOException | XMLStreamException e) {
throw new RuntimeException("Unable to parse core extensions", e);
}
} else {
Expand All @@ -470,15 +471,15 @@ private static List<String> parseExtClasspath(Path userDir) {
}

private static List<CoreExtension> readCoreExtensionsDescriptor(Path multiModuleProjectDirectory)
throws IOException, XmlPullParserException {
throws IOException, XMLStreamException {
if (multiModuleProjectDirectory == null) {
return Collections.emptyList();
}
Path extensionsFile = multiModuleProjectDirectory.resolve(EXTENSIONS_FILENAME);
if (!Files.exists(extensionsFile)) {
return Collections.emptyList();
}
CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader();
CoreExtensionsStaxReader parser = new CoreExtensionsStaxReader();
try (InputStream is = Files.newInputStream(extensionsFile)) {
return parser.read(is).getExtensions();
}
Expand Down
47 changes: 25 additions & 22 deletions daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ void initialize(CliRequest cliRequest) throws ExitException {
}
topDirectory = getCanonicalPath(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.
// 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 =
ServiceLoader.load(RootLocator.class).iterator().next();
Path rootDirectory = rootLocator.findRoot(topDirectory);
Expand Down Expand Up @@ -495,6 +495,7 @@ private void commands(CliRequest cliRequest) {
if (MessageUtils.isColorEnabled()) {
MessageBuilder buff = MessageUtils.builder();
buff.a("Message styles: ");
buff.trace("trace").a(' ');
buff.debug("debug").a(' ');
buff.info("info").a(' ');
buff.warning("warning").a(' ');
Expand Down Expand Up @@ -571,10 +572,11 @@ DefaultPlexusContainer container() throws Exception {
.filter(s -> s != null && !s.isEmpty())
.map(s -> {
String[] parts = s.split(":");
CoreExtension ce = new CoreExtension();
ce.setGroupId(parts[0]);
ce.setArtifactId(parts[1]);
ce.setVersion(parts[2]);
CoreExtension ce = CoreExtension.newBuilder()
.groupId(parts[0])
.artifactId(parts[1])
.version(parts[2])
.build();
return ce;
})
.collect(Collectors.toList());
Expand Down Expand Up @@ -623,11 +625,18 @@ protected void configure() {

container.setLoggerManager(plexusLoggerManager);

AbstractValueSource extensionSource = new AbstractValueSource(false) {
@Override
public Object getValue(String expression) {
return null;
}
};
for (CoreExtensionEntry extension : extensionsEntries) {
container.discoverComponents(
extension.getClassRealm(),
new SessionScopeModule(container),
new MojoExecutionScopeModule(container));
new MojoExecutionScopeModule(container),
new ExtensionConfigurationModule(extension, extensionSource));
}
return container;
}
Expand Down Expand Up @@ -1181,12 +1190,12 @@ private static boolean isRunningOnCI(Properties systemProperties) {
}

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) {
return userDefinedLocalRepo;
}

return request.getSystemProperties().getProperty(MavenCli.LOCAL_REPO_PROPERTY);
return request.getSystemProperties().getProperty(DaemonMavenCli.LOCAL_REPO_PROPERTY);
}

private File determinePom(
Expand All @@ -1199,22 +1208,16 @@ private File determinePom(
alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
}

File current = baseDirectory;
if (alternatePomFile != null) {
File pom = 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;
}
current = resolveFile(new File(alternatePomFile), workingDirectory);
}

return null;
if (modelProcessor != null) {
return modelProcessor.locateExistingPom(current);
} else {
return current.isFile() ? current : null;
}
}

// Visible for testing
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<jansi.version>2.4.0</jansi.version>
<jline.version>3.23.0</jline.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>
<maven4.version>${maven.version}</maven4.version>
<!-- Keep in sync with Maven -->
Expand All @@ -113,7 +113,7 @@
<maven-assembly-plugin.version>3.6.0</maven-assembly-plugin.version>
<xstream.version>1.4.20</xstream.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>

<dependencyManagement>
Expand Down
Loading