You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2022/01/05 07:50:15 UTC

[maven] branch MNG-7263 created (now 40b5985)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch MNG-7263
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at 40b5985  [MNG-7263] refactor lifecycle providers to ease documentation

This branch includes the following new commits:

     new 40b5985  [MNG-7263] refactor lifecycle providers to ease documentation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven] 01/01: [MNG-7263] refactor lifecycle providers to ease documentation

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-7263
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 40b5985aa5ef0580f7f5b3a905f1d179a5c1ba7d
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Wed Jan 5 08:50:07 2022 +0100

    [MNG-7263] refactor lifecycle providers to ease documentation
    
    - lifecycle id
    - phases
    - default plugins bindings
---
 .../providers/CleanLifecycleProvider.java          | 25 +++++----
 .../providers/DefaultLifecycleProvider.java        | 61 ++++++++++++----------
 .../lifecycle/providers/SiteLifecycleProvider.java | 29 ++++++----
 .../providers/WrapperLifecycleProvider.java        | 21 ++++++--
 4 files changed, 84 insertions(+), 52 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java
index 937bfc8..4b72b5e 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java
@@ -31,27 +31,34 @@ import javax.inject.Singleton;
 import org.apache.maven.lifecycle.Lifecycle;
 import org.apache.maven.lifecycle.mapping.LifecyclePhase;
 
+/**
+ * {@code clean} lifecycle provider.
+ */
 @Named( "clean" )
 @Singleton
 public final class CleanLifecycleProvider
     implements Provider<Lifecycle>
 {
+  private static final String LIFECYCLE_ID = "clean";
+
+  private static final String[] PHASES = {
+      "pre-clean",
+      "clean",
+      "post-clean"
+  };
+
   private final Lifecycle lifecycle;
 
   @Inject
   public CleanLifecycleProvider()
   {
-    HashMap<String, LifecyclePhase> phases = new HashMap<>();
-    phases.put( "clean", new LifecyclePhase( "org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean" ) );
+    HashMap<String, LifecyclePhase> defaultBindings = new HashMap<>();
+    defaultBindings.put( "clean", new LifecyclePhase( "org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean" ) );
 
     this.lifecycle = new Lifecycle(
-        "clean",
-        Collections.unmodifiableList( Arrays.asList(
-                "pre-clean",
-                "clean",
-                "post-clean"
-        ) ),
-        Collections.unmodifiableMap( phases )
+        LIFECYCLE_ID,
+        Collections.unmodifiableList( Arrays.asList( PHASES ) ),
+        Collections.unmodifiableMap( defaultBindings )
     );
   }
 
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java
index 56c032b..29d5483 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java
@@ -29,44 +29,51 @@ import javax.inject.Singleton;
 
 import org.apache.maven.lifecycle.Lifecycle;
 
+/**
+ * {@code default} lifecycle provider.
+ */
 @Named( "default" )
 @Singleton
 public final class DefaultLifecycleProvider
     implements Provider<Lifecycle>
 {
+  private static final String LIFECYCLE_ID = "default";
+
+  private static final String[] PHASES = {
+      "validate",
+      "initialize",
+      "generate-sources",
+      "process-sources",
+      "generate-resources",
+      "process-resources",
+      "compile",
+      "process-classes",
+      "generate-test-sources",
+      "process-test-sources",
+      "generate-test-resources",
+      "process-test-resources",
+      "test-compile",
+      "process-test-classes",
+      "test",
+      "prepare-package",
+      "package",
+      "pre-integration-test",
+      "integration-test",
+      "post-integration-test",
+      "verify",
+      "install",
+      "deploy"
+  };
+
   private final Lifecycle lifecycle;
 
   @Inject
   public DefaultLifecycleProvider()
   {
     this.lifecycle = new Lifecycle(
-        "default",
-        Collections.unmodifiableList( Arrays.asList(
-                "validate",
-                "initialize",
-                "generate-sources",
-                "process-sources",
-                "generate-resources",
-                "process-resources",
-                "compile",
-                "process-classes",
-                "generate-test-sources",
-                "process-test-sources",
-                "generate-test-resources",
-                "process-test-resources",
-                "test-compile",
-                "process-test-classes",
-                "test",
-                "prepare-package",
-                "package",
-                "pre-integration-test",
-                "integration-test",
-                "post-integration-test",
-                "verify",
-                "install",
-                "deploy"
-        ) ),
-        null
+        LIFECYCLE_ID,
+        Collections.unmodifiableList( Arrays.asList( PHASES ) ),
+        null // no global plugin bindings for default lifecycle: they are defined per-packaging in separate providers
     );
   }
 
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java
index 1453f03..d7ff563 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java
@@ -31,29 +31,36 @@ import javax.inject.Singleton;
 import org.apache.maven.lifecycle.Lifecycle;
 import org.apache.maven.lifecycle.mapping.LifecyclePhase;
 
+/**
+ * {@code site} lifecycle provider.
+ */
 @Named( "site" )
 @Singleton
 public final class SiteLifecycleProvider
     implements Provider<Lifecycle>
 {
+  private static final String LIFECYCLE_ID = "site";
+
+  private static final String[] PHASES = {
+      "pre-site",
+      "site",
+      "post-site",
+      "site-deploy"
+  };
+
   private final Lifecycle lifecycle;
 
   @Inject
   public SiteLifecycleProvider()
   {
-    HashMap<String, LifecyclePhase> phases = new HashMap<>();
-    phases.put( "site", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:site" ) );
-    phases.put( "site-deploy", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy" ) );
+    HashMap<String, LifecyclePhase> defaultBindings = new HashMap<>();
+    defaultBindings.put( "site", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:site" ) );
+    defaultBindings.put( "site-deploy", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy" ) );
 
     this.lifecycle = new Lifecycle(
-        "site",
-        Collections.unmodifiableList( Arrays.asList(
-                "pre-site",
-                "site",
-                "post-site",
-                "site-deploy"
-        ) ),
-        Collections.unmodifiableMap( phases )
+        LIFECYCLE_ID,
+        Collections.unmodifiableList( Arrays.asList( PHASES ) ),
+        Collections.unmodifiableMap( defaultBindings )
     );
   }
 
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java
index 619d502..b88dcc1 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java
@@ -19,6 +19,7 @@ package org.apache.maven.lifecycle.providers;
  * under the License.
  */
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 
@@ -30,23 +31,33 @@ import javax.inject.Singleton;
 import org.apache.maven.lifecycle.Lifecycle;
 import org.apache.maven.lifecycle.mapping.LifecyclePhase;
 
+/**
+ * {@code wrapper} lifecycle provider.
+ */
 @Named( "wrapper" )
 @Singleton
 public final class WrapperLifecycleProvider
     implements Provider<Lifecycle>
 {
+  private static final String LIFECYCLE_ID = "wrapper";
+
+  private static final String[] PHASES =
+  {
+      "wrapper"
+  };
+
   private final Lifecycle lifecycle;
 
   @Inject
   public WrapperLifecycleProvider()
   {
-    HashMap<String, LifecyclePhase> phases = new HashMap<>();
-    phases.put( "wrapper", new LifecyclePhase( "org.apache.maven.plugins:maven-wrapper-plugin:3.1.0:wrapper" ) );
+    HashMap<String, LifecyclePhase> defaultBindings = new HashMap<>();
+    defaultBindings.put( "wrapper", new LifecyclePhase( "org.apache.maven.plugins:maven-wrapper-plugin:3.1.0:wrapper" ) );
 
     this.lifecycle = new Lifecycle(
-        "wrapper",
-        Collections.singletonList( "wrapper" ),
-        Collections.unmodifiableMap( phases )
+        LIFECYCLE_ID,
+        Collections.unmodifiableList( Arrays.asList( PHASES ) ),
+        Collections.unmodifiableMap( defaultBindings )
     );
   }