Switch to Maven plugin annotations 82/79182/3
authorStephen Kitt <skitt@redhat.com>
Thu, 3 Jan 2019 15:05:03 +0000 (16:05 +0100)
committerRobert Varga <nite@hq.sk>
Thu, 3 Jan 2019 17:26:37 +0000 (17:26 +0000)
This uses plugin annotations instead of Javadoc-based Mojo setup.

Change-Id: Ib3272ec24b7253f9a4a0989ce854cb7847ec0aec
Signed-off-by: Stephen Kitt <skitt@redhat.com>
karaf-plugin/pom.xml
karaf-plugin/src/main/java/org/opendaylight/odlparent/PopulateLocalRepoMojo.java

index 32f647fdca8c0e31d8a75d45139fcd282c57c24a..6aabcb53df986768c75189b74e95265af2104538 100644 (file)
       <artifactId>maven-plugin-api</artifactId>
       <version>3.5.4</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.5.2</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
index 664d5c6c0fc18fb861628ae0d0ffe03d0205badb..39c1c2d64adc0089dfde96efad3169305f9ec2e0 100644 (file)
@@ -32,6 +32,10 @@ import org.apache.karaf.features.internal.model.Features;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.RepositorySystemSession;
@@ -41,14 +45,10 @@ import org.opendaylight.odlparent.karafutil.CustomBundleUrlStreamHandlerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-// TODO: Use org.apache.maven.plugin.annotations.* to allow more flexibility for non-ODL consumers.
-
 /**
  * Mojo populating the local repository by delegating to Aether.
- *
- * @goal populate-local-repo
- * @phase prepare-package
  */
+@Mojo(name = "populate-local-repo", defaultPhase = LifecyclePhase.PREPARE_PACKAGE)
 // URL.setURLStreamHandlerFactory throws an Error directly, so we can’t do any better than this...
 @SuppressWarnings("checkstyle:IllegalCatch")
 public class PopulateLocalRepoMojo
@@ -68,41 +68,32 @@ public class PopulateLocalRepoMojo
 
     /**
      * The Maven project being built.
-     *
-     * @component
-     * @required
-     * @readonly
      */
+    @Parameter(defaultValue = "${project}", readonly = true, required = true)
     private MavenProject project;
 
     /**
      * The entry point to Aether, i.e. the component doing all the work.
-     *
-     * @component
      */
+    @Component
     private RepositorySystem repoSystem;
 
     /**
      * The current repository/network configuration of Maven.
-     *
-     * @parameter default-value="${repositorySystemSession}"
-     * @readonly
      */
+    @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
     private RepositorySystemSession repoSession;
 
     /**
      * The project's remote repositories to use for the resolution of plugins and their dependencies.
-     *
-     * @parameter default-value="${project.remoteProjectRepositories}"
-     * @readonly
      */
+    @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true)
     private List<RemoteRepository> remoteRepos;
 
     /**
      * The local repository to use for the resolution of plugins and their dependencies.
-     *
-     * @parameter
      */
+    @Parameter
     private File localRepo;
 
     private AetherUtil aetherUtil;