-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
275 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ | |
|
||
invoker.java.version = 17+ | ||
invoker.goals.1 = clean install | ||
invoker.maven.version = 3 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# 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 | ||
invoker.maven.version = 4+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.apache.maven.its</groupId> | ||
<artifactId>v4api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>maven-plugin</packaging> | ||
|
||
<name>Maven Integration Test :: v4api</name> | ||
<description> | ||
Test maven-plugin-plugin support for the Maven 4.x api. | ||
</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-api-core</artifactId> | ||
<version>@maven4Version@</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>@compilerPluginVersion@</version> | ||
<configuration> | ||
<source>1.8</source><!-- avoid ${maven.compiler.source} since value is not as expected --> | ||
<target>1.8</target><!-- avoid ${maven.compiler.target} since value is not as expected --> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<goalPrefix>prefix</goalPrefix> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>help-goal</id> | ||
<goals> | ||
<goal>helpmojo</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
75 changes: 75 additions & 0 deletions
75
maven-plugin-plugin/src/it/v4api-4x/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.its.v4api; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.apache.maven.api.MojoExecution; | ||
import org.apache.maven.api.Project; | ||
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.Mojo; | ||
import org.apache.maven.api.plugin.annotations.Parameter; | ||
|
||
/** | ||
* 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 @Inject dependency on ArtifactInstaller (hint=test) which does not exist | ||
* | ||
* @since 1.2 | ||
*/ | ||
@Mojo(name = "first", defaultPhase = "integration-test") | ||
public class FirstMojo implements org.apache.maven.api.plugin.Mojo { | ||
|
||
/** | ||
* Project directory. | ||
*/ | ||
@Parameter(defaultValue = "${basedir}", readonly = true) | ||
private Path basedir; | ||
|
||
@Parameter(property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt", required = true) | ||
private Path touchFile; | ||
|
||
/** | ||
* @since 0.1 | ||
* @deprecated As of 0.2 | ||
*/ | ||
@Deprecated | ||
@Parameter(name = "namedParam", alias = "alias") | ||
private String aliasedParam; | ||
|
||
@Inject | ||
private Session session; | ||
|
||
@Inject | ||
private Project project; | ||
|
||
@Inject | ||
private MojoExecution mojo; | ||
|
||
@Inject | ||
private Log log; | ||
|
||
public void execute() throws MojoException { | ||
log.info("Executing first"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import groovy.xml.XmlParser | ||
|
||
File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" ); | ||
assert descriptorFile.isFile() | ||
|
||
def pluginDescriptor = new XmlParser().parse( descriptorFile ); | ||
|
||
assert pluginDescriptor.requiredJavaVersion.text() == '17' | ||
assert pluginDescriptor.requiredMavenVersion.text() == '4.0.0-beta-3' | ||
|
||
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.projectRequired.text() == 'true' | ||
assert mojo.onlineRequired.text() == 'false' | ||
assert mojo.aggregator.text() == 'false' | ||
assert mojo.phase.text() == 'integration-test' | ||
|
||
assert mojo.parameters.parameter.size() == 3 | ||
|
||
parameter = mojo.parameters.parameter.findAll{ it.name.text() == "basedir" }[0] | ||
assert parameter.name.text() == 'basedir' | ||
assert parameter.alias.isEmpty() | ||
assert parameter.type.text() == 'java.nio.file.Path' | ||
assert parameter.since.isEmpty() | ||
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' | ||
assert parameter.alias.isEmpty() | ||
assert parameter.type.text() == 'java.nio.file.Path' | ||
assert parameter.since.isEmpty() | ||
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' | ||
assert parameter.alias.text() == 'alias' | ||
assert parameter.type.text() == 'java.lang.String' | ||
assert parameter.since.text() == '0.1' | ||
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() | ||
|
||
// check help mojo source and class | ||
assert new File( basedir, "target/classes/org/apache/maven/its/v4api/HelpMojo.class" ).isFile() | ||
assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/its/v4api/HelpMojo.java" ).isFile() | ||
|
||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters