This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new edff852 Add more goals to help plugin (self documenting any Maven
version) (#374)
edff852 is described below
commit edff8529e073d18fa5c9a6cbe19a60bab651053f
Author: Tamas Cservenak <[email protected]>
AuthorDate: Tue Jun 30 12:14:20 2026 +0200
Add more goals to help plugin (self documenting any Maven version) (#374)
add 3 goals to
https://maven.apache.org/plugins/maven-help-plugin/plugin-info.html :
- `list-lifecycle-phases`
- `list-packaging`
- `list-dependency-types`
---
.../plugins/help/ListDependencyTypesMojo.java | 101 +++++++++++++++++
.../plugins/help/ListLifecyclePhasesMojo.java | 82 ++++++++++++++
.../maven/plugins/help/ListPackagingMojo.java | 123 +++++++++++++++++++++
3 files changed, 306 insertions(+)
diff --git
a/src/main/java/org/apache/maven/plugins/help/ListDependencyTypesMojo.java
b/src/main/java/org/apache/maven/plugins/help/ListDependencyTypesMojo.java
new file mode 100644
index 0000000..e45c095
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/help/ListDependencyTypesMojo.java
@@ -0,0 +1,101 @@
+/*
+ * 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 the list of dependency types that are defined in Maven.
+ *
+ * @since 3.5.2
+ */
+@Mojo(name = "list-dependency-types", requiresProject = false, aggregator =
true)
+public class ListDependencyTypesMojo extends AbstractHelpMojo {
+ /**
+ * The Maven default built-in lifecycles.
+ */
+ private final Map<String, ArtifactHandler> artifactHandlers;
+
+ @Inject
+ public ListDependencyTypesMojo(
+ 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/ListLifecyclePhasesMojo.java
b/src/main/java/org/apache/maven/plugins/help/ListLifecyclePhasesMojo.java
new file mode 100644
index 0000000..77ce1f2
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/help/ListLifecyclePhasesMojo.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 the list of all lifecycle phases that are defined in Maven.
+ *
+ * @since 3.5.2
+ */
+@Mojo(name = "list-lifecycle-phases", requiresProject = false, aggregator =
true)
+public class ListLifecyclePhasesMojo extends AbstractHelpMojo {
+ /**
+ * The Maven default built-in lifecycles.
+ */
+ private final DefaultLifecycles defaultLifecycles;
+
+ @Inject
+ public ListLifecyclePhasesMojo(
+ 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/ListPackagingMojo.java
b/src/main/java/org/apache/maven/plugins/help/ListPackagingMojo.java
new file mode 100644
index 0000000..e57146c
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/help/ListPackagingMojo.java
@@ -0,0 +1,123 @@
+/*
+ * 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.Objects;
+import java.util.TreeMap;
+
+import org.apache.maven.lifecycle.DefaultLifecycles;
+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 the list of packaging that are supported by Maven.
+ *
+ * @since 3.5.2
+ */
+@Mojo(name = "list-packaging", requiresProject = false, aggregator = true)
+public class ListPackagingMojo extends AbstractHelpMojo {
+ /**
+ * The Maven default built-in lifecycles.
+ */
+ private final DefaultLifecycles defaultLifecycles;
+
+ /**
+ * The Maven default built-in lifecycles.
+ */
+ private final Map<String, LifecycleMapping> lifecycleMapping;
+
+ @Inject
+ public ListPackagingMojo(
+ ProjectBuilder projectBuilder,
+ RepositorySystem repositorySystem,
+ DefaultLifecycles defaultLifecycles,
+ Map<String, LifecycleMapping> lifecycleMapping) {
+ super(projectBuilder, repositorySystem);
+ this.defaultLifecycles = defaultLifecycles;
+ 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> lifecycleMappingEntry :
+ new TreeMap<>(lifecycleMapping).entrySet()) {
+ LifecycleMapping lifecycleMapping =
lifecycleMappingEntry.getValue();
+ for (Map.Entry<String, Lifecycle> phaseEntry :
+ lifecycleMapping.getLifecycles().entrySet()) {
+ Lifecycle mapping = phaseEntry.getValue();
+ descriptionBuffer
+ .append(lifecycleMappingEntry.getKey())
+ .append(" (lifecycle: ")
+ .append(mapping.getId())
+ .append(")")
+ .append(LS);
+ org.apache.maven.lifecycle.Lifecycle lifecycle =
getLifecycle(mapping.getId());
+ for (String phase : lifecycle.getPhases()) {
+ LifecyclePhase lphase =
mapping.getLifecyclePhases().get(phase);
+ if (lphase != null) {
+ descriptionBuffer.append(" *
").append(phase).append(LS);
+ for (LifecycleMojo mojo : lphase.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);
+ }
+ }
+
+ private org.apache.maven.lifecycle.Lifecycle getLifecycle(String name) {
+ return defaultLifecycles.getLifeCycles().stream()
+ .filter(l -> Objects.equals(name, l.getId()))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("No such
lifecycle"));
+ }
+}