diff --git a/maven-plugin-plugin/src/it/ant-basic/invoker.properties b/maven-plugin-plugin/src/it/ant-basic/invoker.properties
deleted file mode 100644
index 55875b64e..000000000
--- a/maven-plugin-plugin/src/it/ant-basic/invoker.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.goals.1 = clean install
-invoker.goals.2 = org.apache.maven.ant.it:maven-ant-it-basic:1.0-SNAPSHOT:touch -Dname=touch.txt
-
diff --git a/maven-plugin-plugin/src/it/ant-basic/pom.xml b/maven-plugin-plugin/src/it/ant-basic/pom.xml
deleted file mode 100644
index 86e0a1fe6..000000000
--- a/maven-plugin-plugin/src/it/ant-basic/pom.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.ant.it
- maven-ant-it-basic
- 1.0-SNAPSHOT
- maven-plugin
-
- Basic Ant-Mojo Integration Test
- Tests the simplest case of using an Ant script to drive a mojo.
-
-
- @project.version@
-
-
-
-
- org.apache.ant
- ant
- @antVersion@
-
-
- org.apache.maven.plugin-tools
- maven-script-ant
- @project.version@
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- ${pluginPluginVersion}
-
- antBasic
-
-
-
- org.apache.maven.plugin-tools
- maven-plugin-tools-ant
- ${pluginPluginVersion}
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-basic/src/main/scripts/touch.build.xml b/maven-plugin-plugin/src/it/ant-basic/src/main/scripts/touch.build.xml
deleted file mode 100644
index dc163ecfb..000000000
--- a/maven-plugin-plugin/src/it/ant-basic/src/main/scripts/touch.build.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/maven-plugin-plugin/src/it/ant-basic/src/main/scripts/touch.mojos.xml b/maven-plugin-plugin/src/it/ant-basic/src/main/scripts/touch.mojos.xml
deleted file mode 100644
index d904ca783..000000000
--- a/maven-plugin-plugin/src/it/ant-basic/src/main/scripts/touch.mojos.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
- touch-file
-
- touch
-
-
- name
- ${name}
- true
- false
- java.lang.String
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-basic/verify.groovy b/maven-plugin-plugin/src/it/ant-basic/verify.groovy
deleted file mode 100644
index 71ea7e143..000000000
--- a/maven-plugin-plugin/src/it/ant-basic/verify.groovy
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-File touchFile = new File( basedir, "target/touch.txt" )
-assert touchFile.isFile()
-
-File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
-assert descriptorFile.isFile()
-
-File oldHelpClass = new File( basedir, "target/classes/HelpMojo.class" );
-assert !oldHelpClass.exists()
-
-
-return true;
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties b/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties
deleted file mode 100644
index 96636d0b6..000000000
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.goals.1 = clean install
-invoker.goals.2 = org.apache.maven.ant.it:maven-ant-it-referenceParameter:1.0-SNAPSHOT:test
-
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/pom.xml b/maven-plugin-plugin/src/it/ant-reference-parameter/pom.xml
deleted file mode 100644
index 0de107d67..000000000
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/pom.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.ant.it
- maven-ant-it-referenceParameter
- 1.0-SNAPSHOT
- maven-plugin
-
- Ant-Mojo Integration Test with non-String parameter
- Tests using an Ant script to drive a mojo where a parameter is not a String type.
-
-
-
- org.apache.ant
- ant
- @antVersion@
-
-
- org.apache.maven.plugin-tools
- maven-script-ant
- @project.version@
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- @project.version@
-
- antWithRefs
-
-
-
- org.apache.maven.plugin-tools
- maven-plugin-tools-ant
- @project.version@
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java b/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java
deleted file mode 100644
index 3098d66e2..000000000
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.plugins.antWithRefs;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-public class ArtifactsTask extends Task {
-
- public void execute() throws BuildException {
- log(String.valueOf((Object) getProject().getReference("artifacts")));
- }
-}
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/resources/org/apache/maven/plugins/antWithRefs/antlib.xml b/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/resources/org/apache/maven/plugins/antWithRefs/antlib.xml
deleted file mode 100644
index 2fb4b4f28..000000000
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/resources/org/apache/maven/plugins/antWithRefs/antlib.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/scripts/test.build.xml b/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/scripts/test.build.xml
deleted file mode 100644
index 72a61c96e..000000000
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/scripts/test.build.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
- Project artifacts:
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/scripts/test.mojos.xml b/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/scripts/test.mojos.xml
deleted file mode 100644
index ef296d041..000000000
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/scripts/test.mojos.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
- test
- test
- compile
-
-
- artifacts
- ${project.artifacts}
- true
- true
- java.util.List
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties b/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties
deleted file mode 100644
index 3df4a4d69..000000000
--- a/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.goals.1 = clean install
-#invoker.goals.2 = org.apache.maven.ant.it:maven-ant-it-referenceParameter:1.0-SNAPSHOT:test
-
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/plugin/pom.xml b/maven-plugin-plugin/src/it/ant-simple-usage/plugin/pom.xml
deleted file mode 100644
index 315fa01e6..000000000
--- a/maven-plugin-plugin/src/it/ant-simple-usage/plugin/pom.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.ant.it
- simpleUsage-root
- 1.0-SNAPSHOT
-
- simpleUsage-plugin
- Simple Ant-Mojo
- maven-plugin
- Tests the simplest case of using an Ant script to drive a mojo.
-
-
- @project.version@
-
-
-
-
- org.apache.ant
- ant
-
-
- org.apache.maven.plugin-tools
- maven-script-ant
- @project.version@
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- ${pluginPluginVersion}
-
- antSimpleUsage
-
-
-
- org.apache.maven.plugin-tools
- maven-plugin-tools-ant
- @project.version@
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/plugin/src/main/scripts/test.build.xml b/maven-plugin-plugin/src/it/ant-simple-usage/plugin/src/main/scripts/test.build.xml
deleted file mode 100644
index 8ba12c136..000000000
--- a/maven-plugin-plugin/src/it/ant-simple-usage/plugin/src/main/scripts/test.build.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
- Hello, ${name}!
-
-
\ No newline at end of file
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/plugin/src/main/scripts/test.mojos.xml b/maven-plugin-plugin/src/it/ant-simple-usage/plugin/src/main/scripts/test.mojos.xml
deleted file mode 100644
index 464d8aa6d..000000000
--- a/maven-plugin-plugin/src/it/ant-simple-usage/plugin/src/main/scripts/test.mojos.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
- test
- test
-
-
- name
- ${name}
- true
- false
- java.lang.String
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/pom.xml b/maven-plugin-plugin/src/it/ant-simple-usage/pom.xml
deleted file mode 100644
index 46eb6738b..000000000
--- a/maven-plugin-plugin/src/it/ant-simple-usage/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.ant.it
- simpleUsage-root
- 1.0-SNAPSHOT
- pom
-
- Simple-Usage Ant-Mojo Integration Test - Root
- Tests the simplest case of using an Ant script to drive a mojo.
-
-
-
-
- org.apache.ant
- ant
- @antVersion@
-
-
-
-
-
- plugin
- usage
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/usage/pom.xml b/maven-plugin-plugin/src/it/ant-simple-usage/usage/pom.xml
deleted file mode 100644
index 7339c8049..000000000
--- a/maven-plugin-plugin/src/it/ant-simple-usage/usage/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.ant.it
- simpleUsage-root
- 1.0-SNAPSHOT
-
- simpleUsage-usage
- Simple Ant-Mojo Usage Case
- Tests the simplest case of using an Ant script to drive a mojo.
-
-
-
- org.apache.ant
- ant
-
-
-
-
-
-
- org.apache.maven.ant.it
- simpleUsage-plugin
- 1.0-SNAPSHOT
-
-
- Hani
-
-
-
-
- test
- package
-
- test
-
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-since-maven-plugin/pom.xml b/maven-plugin-plugin/src/it/ant-since-maven-plugin/pom.xml
deleted file mode 100644
index 74669006a..000000000
--- a/maven-plugin-plugin/src/it/ant-since-maven-plugin/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
- 4.0.0
- test
- trivial-maven-plugin
- maven-plugin
- 1.0
- trivial-maven-plugin
- Just a test project
- http://nowere.test
- 2012
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- @project.version@
-
-
- org.apache.maven.plugin-tools
- maven-plugin-tools-ant
- @project.version@
-
-
-
- prefix
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-since-maven-plugin/src/main/scripts/sample.build.xml b/maven-plugin-plugin/src/it/ant-since-maven-plugin/src/main/scripts/sample.build.xml
deleted file mode 100644
index a2793dc40..000000000
--- a/maven-plugin-plugin/src/it/ant-since-maven-plugin/src/main/scripts/sample.build.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/ant-since-maven-plugin/src/main/scripts/sample.mojos.xml b/maven-plugin-plugin/src/it/ant-since-maven-plugin/src/main/scripts/sample.mojos.xml
deleted file mode 100644
index 988c04af5..000000000
--- a/maven-plugin-plugin/src/it/ant-since-maven-plugin/src/main/scripts/sample.mojos.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
- sample
- sample-task
- Just a test
- false
- false
- 1.0
-
-
-
- message
- java.lang.String
- true
- true
- 1.0
- Test param
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties b/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
deleted file mode 100644
index 88773cf4e..000000000
--- a/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.goals.1 = clean install
-invoker.goals.2 = org.apache.maven.beanshell.it:maven-beanshell-it-basic:1.0-SNAPSHOT:touch -Dname=touch.txt
-
diff --git a/maven-plugin-plugin/src/it/beanshell-simple/pom.xml b/maven-plugin-plugin/src/it/beanshell-simple/pom.xml
deleted file mode 100644
index 713f2ac2a..000000000
--- a/maven-plugin-plugin/src/it/beanshell-simple/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.apache.maven.beanshell.it
- maven-beanshell-it-basic
- 1.0-SNAPSHOT
- maven-plugin
-
- Basic Beanshell-Mojo Integration Test
-
-
- @project.version@
-
-
-
-
- org.apache-extras.beanshell
- bsh
- 2.0b6
-
-
- org.apache.maven.plugin-tools
- maven-script-beanshell
- @project.version@
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- ${pluginPluginVersion}
-
- beanshellBasic
-
-
-
- org.apache.maven.plugin-tools
- maven-plugin-tools-beanshell
- ${pluginPluginVersion}
-
-
-
-
-
-
diff --git a/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh b/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
deleted file mode 100644
index 99de7e4c5..000000000
--- a/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-// START SNIPPET: beanshell-mojo
-/**
- * Touches a test file.
- *
- * @goal touch
- * @requiresDependencyResolution=test
- * @deprecated Don't use!
- * @since 1.2
- */
-
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.script.beanshell.BeanshellMojoAdapter;
-import org.codehaus.plexus.util.FileUtils;
-
-
-
-execute()
-{
- logger.info( "Executing beanshell mojo..." );
- FileUtils.fileWrite( outDir + "/" + name, "This is a Beanshell test" );
-}
-
-/**
- * Output directory for files.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- */
-setOutDir( file )
-{
- outDir = file;
-}
-
-/**
- *
- *
- * @parameter expression="${name}"
- * @required
- */
-setName( name )
-{
- name = name;
-}
-
-return new BeanshellMojoAdapter( (Mojo) this, this.interpreter );
-// END SNIPPET: beanshell-mojo
diff --git a/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy b/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
deleted file mode 100644
index c58c823e5..000000000
--- a/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-File touchFile = new File( basedir, "target/touch.txt" )
-assert touchFile.exists()
-assert touchFile.isFile()
-content = touchFile.text
-assert content.contains('This is a Beanshell test');
-
-
-return true;
diff --git a/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java b/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
index 879f3cefa..abab3cee0 100644
--- a/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
+++ b/maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java
@@ -22,13 +22,12 @@
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.di.Named;
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;
@@ -38,15 +37,12 @@
* 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")
+@Execute(phase = "generate-sources", lifecycle = "cobertura")
public class FirstMojo implements org.apache.maven.api.plugin.Mojo {
/**
@@ -66,23 +62,24 @@ public class FirstMojo implements org.apache.maven.api.plugin.Mojo {
@Parameter(name = "namedParam", alias = "alias")
private String aliasedParam;
- @Component
+ @Inject
private Session session;
- @Component
+ @Inject
private Project project;
- @Component
+ @Inject
private MojoExecution mojo;
- @Component
+ @Inject
private Settings settings;
- @Component
+ @Inject
private Log log;
- @Component(role = ArtifactInstaller.class, hint = "test")
- private Object custom;
+ @Inject
+ @Named("test")
+ private ArtifactInstaller custom;
public void execute() throws MojoException {}
}
diff --git a/maven-plugin-plugin/src/it/v4api/verify.groovy b/maven-plugin-plugin/src/it/v4api/verify.groovy
index 1405e2313..878ab95a3 100644
--- a/maven-plugin-plugin/src/it/v4api/verify.groovy
+++ b/maven-plugin-plugin/src/it/v4api/verify.groovy
@@ -24,8 +24,8 @@ 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-3'
def mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "first" }[0]
@@ -33,51 +33,12 @@ 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
@@ -90,6 +51,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'
@@ -100,6 +63,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'
@@ -110,6 +75,8 @@ 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()
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
index 862edeaec..527798596 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
@@ -19,12 +19,16 @@
package org.apache.maven.plugin.plugin;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URI;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
@@ -32,6 +36,7 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -48,8 +53,14 @@
import org.apache.maven.tools.plugin.scanner.MojoScanner;
import org.codehaus.plexus.component.repository.ComponentDependency;
import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.io.CachingOutputStream;
+import org.codehaus.plexus.util.io.CachingWriter;
+import org.objectweb.asm.*;
import org.sonatype.plexus.build.incremental.BuildContext;
+import static org.objectweb.asm.Opcodes.*;
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+
/**
*
* Generate a plugin descriptor.
@@ -78,6 +89,12 @@ public class DescriptorGeneratorMojo extends AbstractGeneratorMojo {
@Parameter(defaultValue = "${project.build.outputDirectory}/META-INF/maven", readonly = true)
private File outputDirectory;
+ /**
+ * The directory where the generated class files will be put.
+ */
+ @Parameter(defaultValue = "${project.build.outputDirectory}", readonly = true)
+ private File classOutputDirectory;
+
/**
* The file encoding of the source files.
*
@@ -269,7 +286,6 @@ public class DescriptorGeneratorMojo extends AbstractGeneratorMojo {
protected BuildContext buildContext;
public void generate() throws MojoExecutionException {
-
if (!"maven-plugin".equalsIgnoreCase(project.getArtifactId())
&& project.getArtifactId().toLowerCase().startsWith("maven-")
&& project.getArtifactId().toLowerCase().endsWith("-plugin")
@@ -352,6 +368,12 @@ public void generate() throws MojoExecutionException {
PluginDescriptorFilesGenerator pluginDescriptorGenerator = new PluginDescriptorFilesGenerator();
pluginDescriptorGenerator.execute(outputDirectory, request);
+ // Generate the additional factories for v4 mojos
+ generateFactories(request.getPluginDescriptor());
+
+ // Generate index for v4 beans
+ generateIndex();
+
buildContext.refresh(outputDirectory);
} catch (GeneratorException e) {
throw new MojoExecutionException("Error writing plugin descriptor", e);
@@ -367,6 +389,141 @@ public void generate() throws MojoExecutionException {
}
}
+ private void generateIndex() throws GeneratorException {
+ try {
+ Set diBeans = new TreeSet<>();
+ try (Stream paths = Files.walk(classOutputDirectory.toPath())) {
+ List classes = paths.filter(
+ p -> p.getFileName().toString().endsWith(".class"))
+ .collect(Collectors.toList());
+ for (Path classFile : classes) {
+ String fileString = classFile.toString();
+ String className = fileString
+ .substring(0, fileString.length() - ".class".length())
+ .replace('/', '.');
+ try (InputStream is = Files.newInputStream(classFile)) {
+ ClassReader rdr = new ClassReader(is);
+ rdr.accept(
+ new ClassVisitor(Opcodes.ASM9) {
+ String className;
+
+ @Override
+ public void visit(
+ int version,
+ int access,
+ String name,
+ String signature,
+ String superName,
+ String[] interfaces) {
+ super.visit(version, access, name, signature, superName, interfaces);
+ className = name;
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
+ if ("Lorg/apache/maven/api/di/Named;".equals(descriptor)) {
+ diBeans.add(className.replace('/', '.'));
+ }
+ return null;
+ }
+ },
+ ClassReader.SKIP_FRAMES | ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
+ }
+
+ // Class> clazz = project.getClassRealm().loadClass(className);
+ // boolean hasQualifier = Stream.of(clazz.getAnnotations())
+ // .flatMap(ann -> Stream.of(ann.getClass().getAnnotations()))
+ // .anyMatch(ann -> "org.apache.maven.api.di.Qualifier"
+ // .equals(ann.annotationType().getName()));
+ // if (hasQualifier) {
+ // diBeans.add(className);
+ // }
+ }
+ }
+ Path path = outputDirectory.toPath().resolve("org.apache.maven.api.di.Inject");
+ if (diBeans.isEmpty()) {
+ Files.deleteIfExists(path);
+ } else {
+ try (CachingWriter w = new CachingWriter(path, StandardCharsets.UTF_8)) {
+ String content = diBeans.stream().collect(Collectors.joining("\n", "", "\n"));
+ w.write(content);
+ }
+ }
+ } catch (Exception e) {
+ throw new GeneratorException("Unable to generate index for v4 beans", e);
+ }
+ }
+
+ private void generateFactories(PluginDescriptor pd) throws GeneratorException {
+ try {
+ // Set diBeans = new TreeSet<>();
+ for (MojoDescriptor md : pd.getMojos()) {
+ if (md.isV4Api()) {
+ // diBeans.add(md.getImplementation() + "Factory");
+ generateFactory(md);
+ }
+ }
+ // if (!diBeans.isEmpty()) {
+ // Path path = outputDirectory.toPath().resolve("org.apache.maven.api.di.Inject");
+ // if (Files.exists(path)) {
+ // try (Stream lines = Files.lines(path, StandardCharsets.UTF_8)) {
+ // lines.forEach(diBeans::add);
+ // }
+ // }
+ // try (CachingWriter w = new CachingWriter(path, StandardCharsets.UTF_8)) {
+ // String content = diBeans.stream().collect(Collectors.joining("\n", "", "\n"));
+ // w.write(content);
+ // }
+ // }
+ } catch (IOException e) {
+ throw new GeneratorException("Unable to generate factories for v4 mojos", e);
+ }
+ }
+
+ private void generateFactory(MojoDescriptor md) throws IOException {
+ String mojoClassName = md.getImplementation();
+ String packageName = mojoClassName.substring(0, mojoClassName.lastIndexOf('.'));
+ String generatorClassName = mojoClassName.substring(mojoClassName.lastIndexOf('.') + 1) + "Factory";
+ String mojoName = md.getId();
+
+ getLog().debug("Generating v4 factory for " + mojoClassName);
+
+ byte[] bin = computeGeneratorClassBytes(packageName, generatorClassName, mojoName, mojoClassName);
+
+ try (OutputStream os = new CachingOutputStream(classOutputDirectory
+ .toPath()
+ .resolve(packageName.replace('.', '/') + "/" + generatorClassName + ".class"))) {
+ os.write(bin);
+ }
+ }
+
+ static byte[] computeGeneratorClassBytes(
+ String packageName, String generatorClassName, String mojoName, String mojoClassName) {
+ String mojo = mojoClassName.replace('.', '/');
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
+ cw.visitSource(generatorClassName + ".java", null);
+ AnnotationVisitor av = cw.visitAnnotation("Lorg/apache/maven/api/di/Named;", true);
+ av.visit("value", mojoName);
+ av.visitEnd();
+ cw.visitAnnotation("Lorg/apache/maven/api/annotations/Generated;", true).visitEnd();
+ cw.visit(
+ V1_8,
+ ACC_PUBLIC + ACC_SUPER + ACC_SYNTHETIC,
+ packageName.replace(".", "/") + "/" + generatorClassName,
+ null,
+ mojo,
+ null);
+ MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_SYNTHETIC, "", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitMethodInsn(Opcodes.INVOKESPECIAL, mojo, "", "()V", false);
+ mv.visitInsn(Opcodes.RETURN);
+ mv.visitMaxs(-1, -1);
+ mv.visitEnd();
+ cw.visitEnd();
+ return cw.toByteArray();
+ }
+
private PluginDescriptor extendPluginDescriptor(PluginToolsRequest request) {
ExtendedPluginDescriptor extendedPluginDescriptor = new ExtendedPluginDescriptor(request.getPluginDescriptor());
extendedPluginDescriptor.setRequiredJavaVersion(getRequiredJavaVersion(request));
diff --git a/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/DiGeneratorMojoTest.java b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/DiGeneratorMojoTest.java
new file mode 100644
index 000000000..def5971f1
--- /dev/null
+++ b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/DiGeneratorMojoTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.plugin.plugin;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class DiGeneratorMojoTest {
+
+ @Test
+ void testMojoGenerator() throws Exception {
+ byte[] data = DescriptorGeneratorMojo.computeGeneratorClassBytes(
+ "org.foo",
+ "MojoGenerator",
+ "the-mojo-full-id",
+ MyMojo.class.getName().replace('.', '/'));
+
+ CustomClassLoader cl = new CustomClassLoader(getClass().getClassLoader());
+ Class> generator = cl.loadClassFromBytes(data);
+ Object result = generator.getConstructor().newInstance();
+ assertNotNull(result);
+ assertInstanceOf(MyMojo.class, result);
+ }
+
+ static class CustomClassLoader extends ClassLoader {
+ public CustomClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+
+ public Class> loadClassFromBytes(byte[] classBytes) {
+ return defineClass(null, classBytes, 0, classBytes.length); // Define the class
+ }
+ }
+
+ public static class MyMojo implements org.apache.maven.api.plugin.Mojo {
+ @Override
+ public void execute() {}
+ }
+}
diff --git a/maven-plugin-report-plugin/pom.xml b/maven-plugin-report-plugin/pom.xml
index d023ad270..313417ede 100644
--- a/maven-plugin-report-plugin/pom.xml
+++ b/maven-plugin-report-plugin/pom.xml
@@ -23,7 +23,7 @@
org.apache.maven.plugin-tools
maven-plugin-tools
- 3.13.1-SNAPSHOT
+ 4.0.0-SNAPSHOT
org.apache.maven.plugins
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml
deleted file mode 100644
index a529d616c..000000000
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
- 4.0.0
-
-
- test
- maven-since-3.x
- 1.0-SNAPSHOT
-
-
- test
- antsample-maven-plugin
- maven-plugin
- ANT Sample
- Just a test project
- http://nowere.test
- 2012
-
-
- UTF-8
-
-
-
-
- org.apache.maven
- maven-plugin-api
- @maven3Version@
- provided
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- @project.version@
-
-
- org.apache.maven.plugin-tools
- maven-plugin-tools-ant
- @project.version@
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-report-plugin
- @project.version@
-
-
-
-
-
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/main/scripts/sample.build.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/main/scripts/sample.build.xml
deleted file mode 100644
index 4e8e415ca..000000000
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/main/scripts/sample.build.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/main/scripts/sample.mojos.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/main/scripts/sample.mojos.xml
deleted file mode 100644
index 1116b9075..000000000
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/main/scripts/sample.mojos.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
- sample
- sample-task
- Just a test
- false
- false
- 1.0
-
-
-
- message
- java.lang.String
- true
- false
- 0.9
- Test param
-
-
-
-
-
-
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml
deleted file mode 100644
index e4ac0af49..000000000
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
- org.apache.maven.skins
- maven-fluido-skin
- 1.11.1
-
-
-
-
-
-
-
-
-
diff --git a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
index b36696602..7e5a8fba9 100644
--- a/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
+++ b/maven-plugin-report-plugin/src/it/fix-maven-since-3.x/pom.xml
@@ -30,7 +30,6 @@
2012
- antsample-maven-plugin
javasample-maven-plugin
@@ -60,13 +59,6 @@
-