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

Upgrade to beta-4 #295

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ jobs:
build:
name: Verify
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
with:
maven-matrix: '[ "3.6.3", "3.9.7", "4.0.0-beta-3" ]'
jdk-matrix: '[ "8", "17", "21" ]'
matrix-exclude: '[ { maven: "4.0.0-beta-3", jdk: "8" } ]'

2 changes: 2 additions & 0 deletions maven-plugin-plugin/src/it/v4api/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# specific language governing permissions and limitations
# under the License.

invoker.java.version = 17+
invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.its:v4api:1.0-SNAPSHOT:first
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,27 @@
package org.apache.maven.its.v4api;

import java.nio.file.Path;
import java.util.List;

import org.apache.maven.api.MojoExecution;
import org.apache.maven.api.Project;
import org.apache.maven.api.ResolutionScope;
import org.apache.maven.api.Session;
import org.apache.maven.api.di.Inject;
import org.apache.maven.api.plugin.Log;
import org.apache.maven.api.plugin.MojoException;
import org.apache.maven.api.plugin.annotations.Component;
import org.apache.maven.api.plugin.annotations.Execute;
import org.apache.maven.api.plugin.annotations.LifecyclePhase;
import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.api.services.ArtifactInstaller;
import org.apache.maven.api.settings.Settings;
import org.apache.maven.api.plugin.annotations.Resolution;

/**
* Test mojo for the v4 api plugin descriptor generation.
* This mojo is not actually runnable because:
* - it's using a custom lifecycle which is not defined
* - it has a @Component dependency on ArtifactInstaller (hint=test) which does not exist
* - it has a @Inject dependency on ArtifactInstaller (hint=test) which does not exist
*
* @since 1.2
*/
@Mojo(
name = "first",
requiresDependencyResolution = ResolutionScope.TEST,
defaultPhase = LifecyclePhase.INTEGRATION_TEST)
@Execute(phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura")
@Mojo(name = "first", defaultPhase = "integration-test")
public class FirstMojo implements org.apache.maven.api.plugin.Mojo {

/**
Expand All @@ -66,23 +59,25 @@ public class FirstMojo implements org.apache.maven.api.plugin.Mojo {
@Parameter(name = "namedParam", alias = "alias")
private String aliasedParam;

@Component
@Resolution(pathScope = "main-runtime")
private List<Path> classPath;

@Inject
private Session session;

@Component
@Inject
private Project project;

@Component
@Inject
private MojoExecution mojo;

@Component
private Settings settings;

@Component
@Inject
private Log log;

@Component(role = ArtifactInstaller.class, hint = "test")
private Object custom;

public void execute() throws MojoException {}
public void execute() throws MojoException {
log.info("Executing first");
for (Path path : classPath) {
log.info(path.toString());
}
}
}
62 changes: 17 additions & 45 deletions maven-plugin-plugin/src/it/v4api/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,19 @@ assert descriptorFile.isFile()

def pluginDescriptor = new XmlParser().parse( descriptorFile );

assert pluginDescriptor.requiredJavaVersion.text() == '1.8'
assert pluginDescriptor.requiredMavenVersion.text() == '4.0.0-alpha-4'
assert pluginDescriptor.requiredJavaVersion.text() == '17'
assert pluginDescriptor.requiredMavenVersion.text() == '4.0.0-beta-4-SNAPSHOT'

def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first" }[0]

assert mojo.goal.text() == 'first'
assert mojo.implementation.text() == 'org.apache.maven.its.v4api.FirstMojo'
assert mojo.language.text() == 'java'
assert mojo.description.text().startsWith('Test mojo for the v4 api plugin descriptor generation.')
assert mojo.requiresDependencyResolution.text() == 'test'
assert mojo.requiresDependencyCollection.text() == ''
assert mojo.requiresProject.text() == 'true'
assert mojo.requiresOnline.text() == 'false'
assert mojo.requiresDirectInvocation.text() == 'false'
assert mojo.projectRequired.text() == 'true'
assert mojo.onlineRequired.text() == 'false'
assert mojo.aggregator.text() == 'false'
assert mojo.threadSafe.text() == 'false'
assert mojo.phase.text() == 'integration-test'
assert mojo.executePhase.text() == 'generate-sources'
assert mojo.executeLifecycle.text() == 'cobertura'
assert mojo.v4Api.text() == 'true'

assert mojo.configuration.basedir[0].text() == ''
assert mojo.configuration.basedir[0].'@implementation' == 'java.nio.file.Path'
assert mojo.configuration.basedir[0].'@default-value' == '${basedir}'

assert mojo.configuration.touchFile[0].text() == '${first.touchFile}'
assert mojo.configuration.touchFile[0].'@implementation' == 'java.nio.file.Path'
assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.directory}/touch.txt'

assert mojo.requirements.requirement.size() == 6

assert mojo.requirements.requirement[0].role.text() == 'org.apache.maven.api.services.ArtifactInstaller'
assert mojo.requirements.requirement[0].'role-hint'.text() == 'test'
assert mojo.requirements.requirement[0].'field-name'.text() == 'custom'

assert mojo.requirements.requirement[1].role.text() == 'org.apache.maven.api.plugin.Log'
assert mojo.requirements.requirement[1].'role-hint'.isEmpty()
assert mojo.requirements.requirement[1].'field-name'.text() == 'log'

assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.api.MojoExecution'
assert mojo.requirements.requirement[2].'role-hint'.isEmpty()
assert mojo.requirements.requirement[2].'field-name'.text() == 'mojo'

assert mojo.requirements.requirement[3].role.text() == 'org.apache.maven.api.Project'
assert mojo.requirements.requirement[3].'role-hint'.isEmpty()
assert mojo.requirements.requirement[3].'field-name'.text() == 'project'

assert mojo.requirements.requirement[4].role.text() == 'org.apache.maven.api.Session'
assert mojo.requirements.requirement[4].'role-hint'.isEmpty()
assert mojo.requirements.requirement[4].'field-name'.text() == 'session'

assert mojo.requirements.requirement[5].role.text() == 'org.apache.maven.api.settings.Settings'
assert mojo.requirements.requirement[5].'role-hint'.isEmpty()
assert mojo.requirements.requirement[5].'field-name'.text() == 'settings'

assert mojo.parameters.parameter.size() == 3

Expand All @@ -90,6 +49,8 @@ assert parameter.deprecated.isEmpty()
assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'false'
assert parameter.description.text() == 'Project directory.'
assert parameter.defaultValue.text() == '${basedir}'
assert parameter.expression.isEmpty()

parameter = mojo.parameters.parameter.findAll{ it.name.text() == "touchFile" }[0]
assert parameter.name.text() == 'touchFile'
Expand All @@ -100,6 +61,8 @@ assert parameter.deprecated.isEmpty()
assert parameter.required.text() == 'true'
assert parameter.editable.text() == 'true'
assert parameter.description.text() == ''
assert parameter.defaultValue.text() == '${project.build.directory}/touch.txt'
assert parameter.expression.text() == '${first.touchFile}'

parameter = mojo.parameters.parameter.findAll{ it.name.text() == "namedParam" }[0]
assert parameter.name.text() == 'namedParam'
Expand All @@ -110,6 +73,15 @@ assert parameter.deprecated.text() == 'As of 0.2'
assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'true'
assert parameter.description.text() == ''
assert parameter.defaultValue.isEmpty()
assert parameter.expression.isEmpty()

assert mojo.resolutions.resolution.size() == 1

resolution = mojo.resolutions.resolution[0]
assert resolution.field.text() == 'classPath'
assert resolution.pathScope.text() == 'main-runtime'
assert resolution.requestType.text() == ''

// check help mojo source and class
assert new File( basedir, "target/classes/org/apache/maven/its/v4api/HelpMojo.class" ).isFile()
Expand Down
Loading
Loading