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

Maven Archetype 3.3.0 compatibility #1070

Merged
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 .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
artifact-name: helidon-cli-dist
artifact-path: cli/impl/target/helidon-cli.zip
run: |
mvn --version
mvn ${MAVEN_ARGS} build-cache:go-offline
mvn ${MAVEN_ARGS} -T8 \
-Dorg.slf4j.simpleLogger.showThreadName=true \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void testWrongMavenVersion() throws Exception {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Path mavenBinDir = mavenDirectory.resolve("apache-maven-3.1.1/bin");
List<String> mavenArgs = List.of(
"archetype:generate",
"org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate",
"-DinteractiveMode=false",
"-DarchetypeGroupId=io.helidon.archetypes",
"-DarchetypeArtifactId=helidon",
Expand Down Expand Up @@ -266,7 +266,7 @@ private void runMissingValueTest(List<String> args, String mavenVersion) throws
private void missingArtifactGroupPackageValues(String mavenVersion) {
List<String> args = List.of(
"-B",
"archetype:generate",
"org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate",
"-DinteractiveMode=false",
"-DarchetypeGroupId=io.helidon.archetypes",
"-DarchetypeArtifactId=helidon",
Expand All @@ -281,7 +281,7 @@ private void missingArtifactGroupPackageValues(String mavenVersion) {
private void missingFlavorValue(String mavenVersion) {
List<String> args = List.of(
"-B",
"archetype:generate",
"org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate",
"-DinteractiveMode=false",
"-DarchetypeGroupId=io.helidon.archetypes",
"-DarchetypeArtifactId=helidon",
Expand All @@ -298,7 +298,7 @@ private void missingFlavorValue(String mavenVersion) {
private void missingBaseValue(String mavenVersion) {
List<String> args = List.of(
"-B",
"archetype:generate",
"org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate",
"-DinteractiveMode=false",
"-DarchetypeGroupId=io.helidon.archetypes",
"-DarchetypeArtifactId=helidon",
Expand Down
5 changes: 5 additions & 0 deletions maven-plugins/helidon-archetype-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<artifactId>maven-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import io.helidon.build.common.ansi.AnsiConsoleInstaller;
import io.helidon.build.maven.archetype.config.Validation;

import org.apache.maven.RepositoryUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -58,17 +59,17 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.ProjectArtifact;
import org.apache.maven.shared.invoker.DefaultInvocationRequest;
import org.apache.maven.shared.invoker.InvocationOutputHandler;
import org.apache.maven.shared.invoker.InvocationRequest;
import org.apache.maven.shared.invoker.InvocationResult;
import org.apache.maven.shared.invoker.Invoker;
import org.apache.maven.shared.invoker.MavenInvocationException;
import org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerException;
import org.apache.maven.shared.transfer.project.NoFileAssignedException;
import org.apache.maven.shared.transfer.project.install.ProjectInstaller;
import org.apache.maven.shared.transfer.project.install.ProjectInstallerRequest;
import org.codehaus.plexus.PlexusContainer;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.installation.InstallRequest;
import org.eclipse.aether.installation.InstallationException;

import static io.helidon.build.common.FileUtils.ensureDirectory;
import static io.helidon.build.common.FileUtils.unique;
Expand Down Expand Up @@ -107,7 +108,6 @@ public class IntegrationTestMojo extends AbstractMojo {
*/
@Parameter(defaultValue = "${session}", readonly = true, required = true)
private MavenSession session;

/**
* Skip the integration test.
*/
Expand Down Expand Up @@ -244,7 +244,7 @@ public class IntegrationTestMojo extends AbstractMojo {
private Map<String, String> invokerEnvVars;

@Component
private ProjectInstaller installer;
private RepositorySystem repoSystem;

@Component
private PluginContainerManager pluginContainerManager;
Expand Down Expand Up @@ -495,11 +495,13 @@ private void mavenCompatGenerate(String archetypeGroupId,
Path basedir) throws MojoExecutionException {

// pre-install the archetype JAR so that the post-generate script can resolve it
ProjectInstallerRequest projectInstallerRequest = new ProjectInstallerRequest().setProject(project);
try {
installer.install(session.getProjectBuildingRequest(), projectInstallerRequest);
} catch (IOException | ArtifactInstallerException | NoFileAssignedException ex) {
throw new MojoExecutionException("Unable to pre-install archetype artifact", ex);
InstallRequest request = new InstallRequest();
request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project)));
request.addArtifact(RepositoryUtils.toArtifact(project.getArtifact()));
repoSystem.install(session.getRepositorySession(), request);
} catch (InstallationException ex) {
throw new MojoExecutionException("Unable to pre-install project", ex);
}

PlexusContainer container = pluginContainerManager.create(MAVEN_ARCHETYPE_PLUGIN,
Expand Down Expand Up @@ -529,7 +531,7 @@ private void invokePostArchetypeGenerationGoals(File basedir) throws IOException
.setUserSettingsFile(session.getRequest().getUserSettingsFile())
.setLocalRepositoryDirectory(localRepo)
.setBaseDirectory(basedir)
.setGoals(List.of(testGoal))
.addArgs(List.of(testGoal))
.setProfiles(testProfiles)
.setBatchMode(true)
.setShowErrors(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,7 +67,7 @@ static void generate(PlexusContainer container,
.setPackage(properties.getProperty("package"))
.setOutputDirectory(basedir.toString())
.setProperties(properties)
.setProjectBuildingRequest(session.getProjectBuildingRequest());
.setRepositorySession(session.getRepositorySession());

ArchetypeGenerationResult result = new ArchetypeGenerationResult();

Expand Down
Loading