Skip to content

Commit 50482ba

Browse files
authored
[MPLUGIN-441] Support for the new maven4 api (#117)
1 parent 31a35b9 commit 50482ba

38 files changed

Lines changed: 1062 additions & 138 deletions

File tree

maven-plugin-plugin/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
<properties>
4545
<it.debug>true</it.debug>
46+
<javaVersion>8</javaVersion>
4647
</properties>
4748

4849
<dependencies>
@@ -135,7 +136,7 @@
135136

136137
<!-- plexus -->
137138
<dependency>
138-
<groupId>org.codehaus.plexus</groupId>
139+
<groupId>org.apache.maven</groupId>
139140
<artifactId>plexus-utils</artifactId>
140141
</dependency>
141142
<dependency>

maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ under the License.
5858
<scope>compile</scope>
5959
</dependency>
6060
<dependency>
61-
<groupId>org.codehaus.plexus</groupId>
61+
<groupId>org.apache.maven</groupId>
6262
<artifactId>plexus-utils</artifactId>
6363
<version>@plexusUtilsVersion@</version>
6464
</dependency>

maven-plugin-plugin/src/it/java-basic-annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ under the License.
5252
<scope>provided</scope>
5353
</dependency>
5454
<dependency>
55-
<groupId>org.codehaus.plexus</groupId>
55+
<groupId>org.apache.maven</groupId>
5656
<artifactId>plexus-utils</artifactId>
5757
<version>@plexusUtilsVersion@</version>
5858
</dependency>

maven-plugin-plugin/src/it/mplugin-272_java8/src/main/java/fr/ca/MyMojo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.maven.plugin.AbstractMojo;
2323
import org.apache.maven.plugin.MojoExecutionException;
24-
import org.apache.maven.plugin.MojoFailureException;
2524
import org.apache.maven.plugins.annotations.LifecyclePhase;
2625
import org.apache.maven.plugins.annotations.Mojo;
2726

@@ -31,7 +30,7 @@
3130
@Mojo(name="test-plugin",defaultPhase = LifecyclePhase.GENERATE_SOURCES)
3231
public class MyMojo extends AbstractMojo {
3332
@Override
34-
public void execute() throws MojoExecutionException, MojoFailureException {
33+
public void execute() throws MojoExecutionException {
3534

3635
}
3736
}

maven-plugin-plugin/src/it/settings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ under the License.
3939
<url>@localRepositoryUrl@</url>
4040
<releases>
4141
<enabled>true</enabled>
42+
<checksumPolicy>ignore</checksumPolicy>
4243
</releases>
4344
<snapshots>
4445
<enabled>true</enabled>
46+
<checksumPolicy>ignore</checksumPolicy>
4547
</snapshots>
4648
</repository>
4749
</repositories>
@@ -51,9 +53,11 @@ under the License.
5153
<url>@localRepositoryUrl@</url>
5254
<releases>
5355
<enabled>true</enabled>
56+
<checksumPolicy>ignore</checksumPolicy>
5457
</releases>
5558
<snapshots>
5659
<enabled>true</enabled>
60+
<checksumPolicy>ignore</checksumPolicy>
5761
</snapshots>
5862
</pluginRepository>
5963
</pluginRepositories>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals.1 = clean install
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<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">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.its</groupId>
26+
<artifactId>v4api</artifactId>
27+
<version>1.0-SNAPSHOT</version>
28+
<packaging>maven-plugin</packaging>
29+
30+
<name>Maven Integration Test :: v4api</name>
31+
<description>
32+
Test maven-plugin-plugin support for the Maven 4.x api.
33+
</description>
34+
35+
<properties>
36+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.apache.maven</groupId>
42+
<artifactId>maven-api-core</artifactId>
43+
<version>@maven4Version@</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
</dependencies>
47+
48+
<build>
49+
<pluginManagement>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-compiler-plugin</artifactId>
54+
<version>3.1</version>
55+
<configuration>
56+
<source>1.8</source><!-- avoid ${maven.compiler.source} since value is not as expected -->
57+
<target>1.8</target><!-- avoid ${maven.compiler.target} since value is not as expected -->
58+
</configuration>
59+
</plugin>
60+
</plugins>
61+
</pluginManagement>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-plugin-plugin</artifactId>
66+
<version>@project.version@</version>
67+
<executions>
68+
<execution>
69+
<id>help-goal</id>
70+
<goals>
71+
<goal>helpmojo</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
</plugins>
77+
</build>
78+
</project>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package org.apache.maven.its.v4api;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import org.apache.maven.api.MojoExecution;
23+
import org.apache.maven.api.ResolutionScope;
24+
import org.apache.maven.api.Session;
25+
import org.apache.maven.api.plugin.Log;
26+
import org.apache.maven.api.plugin.MojoException;
27+
import org.apache.maven.api.plugin.annotations.Component;
28+
import org.apache.maven.api.plugin.annotations.Execute;
29+
import org.apache.maven.api.plugin.annotations.LifecyclePhase;
30+
import org.apache.maven.api.plugin.annotations.Mojo;
31+
import org.apache.maven.api.plugin.annotations.Parameter;
32+
import org.apache.maven.api.Project;
33+
import org.apache.maven.api.services.ArtifactInstaller;
34+
import org.apache.maven.api.settings.Settings;
35+
36+
import java.nio.file.Path;
37+
38+
/**
39+
* Test mojo for the v4 api plugin descriptor generation.
40+
* This mojo is not actually runnable because:
41+
* - it's using a custom lifecycle which is not defined
42+
* - it has a @Component dependency on ArtifactInstaller (hint=test) which does not exist
43+
*
44+
* @since 1.2
45+
*/
46+
@Mojo( name = "first", requiresDependencyResolution = ResolutionScope.TEST,
47+
defaultPhase = LifecyclePhase.INTEGRATION_TEST )
48+
@Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
49+
public class FirstMojo
50+
implements org.apache.maven.api.plugin.Mojo
51+
{
52+
53+
/**
54+
* Project directory.
55+
*/
56+
@Parameter( defaultValue = "${basedir}", readonly = true )
57+
private Path basedir;
58+
59+
@Parameter( property = "first.touchFile", defaultValue = "${project.build.directory}/touch.txt",
60+
required = true )
61+
private Path touchFile;
62+
63+
/**
64+
* @since 0.1
65+
* @deprecated As of 0.2
66+
*/
67+
@Deprecated
68+
@Parameter( name = "namedParam", alias = "alias" )
69+
private String aliasedParam;
70+
71+
@Component
72+
private Session session;
73+
74+
@Component
75+
private Project project;
76+
77+
@Component
78+
private MojoExecution mojo;
79+
80+
@Component
81+
private Settings settings;
82+
83+
@Component
84+
private Log log;
85+
86+
@Component( role = ArtifactInstaller.class, hint = "test" )
87+
private Object custom;
88+
89+
public void execute()
90+
throws MojoException
91+
{
92+
}
93+
94+
}

0 commit comments

Comments
 (0)