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

cstamas pushed a commit to branch add-more-goals
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git

commit b044bbeee3211ce21545530dd7d91b5662787104
Author: Tamas Cservenak <[email protected]>
AuthorDate: Thu Jun 18 19:57:24 2026 +0200

    Add more goals to help plugin, making it more useful.
    
    Example output with (just for example sake) Takari Lifecycle
    added to POM as extension. The goals show the "real state".
    
    https://gist.github.com/cstamas/d466b0df2c63a448109aea4d673db8b5
---
 pom.xml                                            |   8 ++
 .../plugins/help/DescribeDependencyTypeMojo.java   | 106 +++++++++++++++++++++
 .../plugins/help/DescribeLifecyclePhaseMojo.java   |  82 ++++++++++++++++
 .../maven/plugins/help/DescribePackagingMojo.java  | 103 ++++++++++++++++++++
 4 files changed, 299 insertions(+)

diff --git a/pom.xml b/pom.xml
index a5861f4..692f56a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -266,6 +266,14 @@
         </plugin>
       </plugins>
     </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>io.takari.maven.plugins</groupId>
+        <artifactId>takari-lifecycle-plugin</artifactId>
+        <version>2.3.4</version>
+        <extensions>true</extensions>
+      </plugin>
+    </plugins>
   </build>
 
   <profiles>
diff --git 
a/src/main/java/org/apache/maven/plugins/help/DescribeDependencyTypeMojo.java 
b/src/main/java/org/apache/maven/plugins/help/DescribeDependencyTypeMojo.java
new file mode 100644
index 0000000..94b0437
--- /dev/null
+++ 
b/src/main/java/org/apache/maven/plugins/help/DescribeDependencyTypeMojo.java
@@ -0,0 +1,106 @@
+/*
+ * 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.help;
+
+import javax.inject.Inject;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.project.ProjectBuilder;
+import org.eclipse.aether.RepositorySystem;
+
+/**
+ * Displays a list of artifact handlers that are defined in Maven.
+ *
+ * @since 3.5.2
+ */
+@Mojo(name = "describe-dependency-type", requiresProject = false, aggregator = 
true)
+public class DescribeDependencyTypeMojo extends AbstractHelpMojo {
+    /**
+     * The default indent size when writing description's Mojo.
+     */
+    private static final int INDENT_SIZE = 2;
+
+    /**
+     * The Maven default built-in lifecycles.
+     */
+    private final Map<String, ArtifactHandler> artifactHandlers;
+
+    @Inject
+    public DescribeDependencyTypeMojo(
+            ProjectBuilder projectBuilder,
+            RepositorySystem repositorySystem,
+            Map<String, ArtifactHandler> artifactHandlers) {
+        super(projectBuilder, repositorySystem);
+        this.artifactHandlers = artifactHandlers;
+    }
+
+    // ----------------------------------------------------------------------
+    // Mojo parameters
+    // ----------------------------------------------------------------------
+
+    // ----------------------------------------------------------------------
+    // Public methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        try {
+            StringBuilder descriptionBuffer = new StringBuilder();
+            for (Map.Entry<String, ArtifactHandler> handlerEntry : new 
TreeMap<>(artifactHandlers).entrySet()) {
+                if ("default".equals(handlerEntry.getKey())) {
+                    continue;
+                }
+                descriptionBuffer.append(handlerEntry.getKey()).append(LS);
+                ArtifactHandler handler = handlerEntry.getValue();
+                descriptionBuffer
+                        .append(" - Extension: ")
+                        .append("*.")
+                        .append(handler.getExtension())
+                        .append(LS);
+                if (handler.getClassifier() != null && 
!handler.getClassifier().isEmpty()) {
+                    descriptionBuffer
+                            .append(" - Classifier: ")
+                            .append(handler.getClassifier())
+                            .append(LS);
+                }
+                if (handler.isAddedToClasspath()) {
+                    descriptionBuffer.append(" - Added to 
Classpath").append(LS);
+                }
+                if (handler.isIncludesDependencies()) {
+                    descriptionBuffer.append(" - Includes 
dependencies").append(LS);
+                }
+                descriptionBuffer.append(LS);
+            }
+            getLog().info(LS + "Maven Dependency Types defined:" + LS + LS + 
descriptionBuffer);
+            writeFile(output, descriptionBuffer);
+        } catch (IOException e) {
+            throw new MojoFailureException(e);
+        }
+    }
+}
diff --git 
a/src/main/java/org/apache/maven/plugins/help/DescribeLifecyclePhaseMojo.java 
b/src/main/java/org/apache/maven/plugins/help/DescribeLifecyclePhaseMojo.java
new file mode 100644
index 0000000..22b1bf6
--- /dev/null
+++ 
b/src/main/java/org/apache/maven/plugins/help/DescribeLifecyclePhaseMojo.java
@@ -0,0 +1,82 @@
+/*
+ * 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.help;
+
+import javax.inject.Inject;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.lifecycle.DefaultLifecycles;
+import org.apache.maven.lifecycle.Lifecycle;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.project.ProjectBuilder;
+import org.eclipse.aether.RepositorySystem;
+
+/**
+ * Displays a list of lifecycle phases that are defined in Maven.
+ *
+ * @since 3.5.2
+ */
+@Mojo(name = "describe-lifecycle-phase", requiresProject = false, aggregator = 
true)
+public class DescribeLifecyclePhaseMojo extends AbstractHelpMojo {
+    /**
+     * The Maven default built-in lifecycles.
+     */
+    private final DefaultLifecycles defaultLifecycles;
+
+    @Inject
+    public DescribeLifecyclePhaseMojo(
+            ProjectBuilder projectBuilder, RepositorySystem repositorySystem, 
DefaultLifecycles defaultLifecycles) {
+        super(projectBuilder, repositorySystem);
+        this.defaultLifecycles = defaultLifecycles;
+    }
+
+    // ----------------------------------------------------------------------
+    // Mojo parameters
+    // ----------------------------------------------------------------------
+
+    // ----------------------------------------------------------------------
+    // Public methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        try {
+            StringBuilder descriptionBuffer = new StringBuilder();
+            List<Lifecycle> lifecycles = defaultLifecycles.getLifeCycles();
+            for (Lifecycle lifecycle : lifecycles) {
+                descriptionBuffer.append(lifecycle.getId()).append(LS);
+                lifecycle
+                        .getPhases()
+                        .forEach(p -> descriptionBuffer.append(" * 
").append(p).append(LS));
+                descriptionBuffer.append(LS);
+            }
+            getLog().info(LS + "Maven lifecycles defined:" + LS + LS + 
descriptionBuffer);
+            writeFile(output, descriptionBuffer);
+        } catch (IOException e) {
+            throw new MojoFailureException(e);
+        }
+    }
+}
diff --git 
a/src/main/java/org/apache/maven/plugins/help/DescribePackagingMojo.java 
b/src/main/java/org/apache/maven/plugins/help/DescribePackagingMojo.java
new file mode 100644
index 0000000..cd20817
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/help/DescribePackagingMojo.java
@@ -0,0 +1,103 @@
+/*
+ * 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.help;
+
+import javax.inject.Inject;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.maven.lifecycle.mapping.Lifecycle;
+import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+import org.apache.maven.lifecycle.mapping.LifecycleMojo;
+import org.apache.maven.lifecycle.mapping.LifecyclePhase;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.project.ProjectBuilder;
+import org.eclipse.aether.RepositorySystem;
+
+/**
+ * Displays a list of packaging that are defined in Maven.
+ *
+ * @since 3.5.2
+ */
+@Mojo(name = "describe-packaging", requiresProject = false, aggregator = true)
+public class DescribePackagingMojo extends AbstractHelpMojo {
+    /**
+     * The Maven default built-in lifecycles.
+     */
+    private final Map<String, LifecycleMapping> lifecycleMapping;
+
+    @Inject
+    public DescribePackagingMojo(
+            ProjectBuilder projectBuilder,
+            RepositorySystem repositorySystem,
+            Map<String, LifecycleMapping> lifecycleMapping) {
+        super(projectBuilder, repositorySystem);
+        this.lifecycleMapping = lifecycleMapping;
+    }
+
+    // ----------------------------------------------------------------------
+    // Mojo parameters
+    // ----------------------------------------------------------------------
+
+    // ----------------------------------------------------------------------
+    // Public methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        try {
+            StringBuilder descriptionBuffer = new StringBuilder();
+            for (Map.Entry<String, LifecycleMapping> mappingEntry : new 
TreeMap<>(lifecycleMapping).entrySet()) {
+                LifecycleMapping mapping = mappingEntry.getValue();
+                for (Map.Entry<String, Lifecycle> phaseEntry :
+                        mapping.getLifecycles().entrySet()) {
+                    Lifecycle lifecycle = phaseEntry.getValue();
+                    descriptionBuffer
+                            .append(mappingEntry.getKey())
+                            .append(" (lifecycle: ")
+                            .append(lifecycle.getId())
+                            .append(")")
+                            .append(LS);
+                    for (Map.Entry<String, LifecyclePhase> phaseE :
+                            lifecycle.getLifecyclePhases().entrySet()) {
+                        descriptionBuffer.append("  - 
").append(phaseE.getKey()).append(LS);
+                        for (LifecycleMojo mojo : 
phaseE.getValue().getMojos()) {
+                            descriptionBuffer
+                                    .append("    - ")
+                                    .append(mojo.getGoal())
+                                    .append(LS);
+                        }
+                    }
+                }
+                descriptionBuffer.append(LS);
+            }
+            getLog().info(LS + "Maven packaging defined:" + LS + LS + 
descriptionBuffer);
+            writeFile(output, descriptionBuffer);
+        } catch (IOException e) {
+            throw new MojoFailureException(e);
+        }
+    }
+}

Reply via email to