diff --git a/EmptyProject/pom.xml b/EmptyProject/pom.xml index 0b30830..e799ff7 100644 --- a/EmptyProject/pom.xml +++ b/EmptyProject/pom.xml @@ -8,10 +8,47 @@ EmptyProject 1.0-SNAPSHOT + + org.plugin + MavenPluginParent + 1.0-SNAPSHOT + + 17 17 UTF-8 - \ No newline at end of file + + + dev1 + Test User 1 + test.user1@example.com + https://github.com/testuser1 + + + dev2 + Test User 2 + test.user2@example.com + https://github.com/testuser2 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + + org.plugin + MavenPlugin + 1.0-SNAPSHOT + + + + + diff --git a/MavenPlugin/pom.xml b/MavenPlugin/pom.xml index 9f5cd58..ce40647 100644 --- a/MavenPlugin/pom.xml +++ b/MavenPlugin/pom.xml @@ -7,6 +7,15 @@ org.plugin MavenPlugin 1.0-SNAPSHOT + maven-plugin + + + + org.plugin + MavenPluginParent + 1.0-SNAPSHOT + + 17 @@ -14,4 +23,57 @@ UTF-8 + + + + + org.apache.maven + maven-plugin-api + 3.9.6 + + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.6.0 + compile + + + + org.apache.maven + maven-core + 3.9.6 + provided + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.9.0 + + + generate-descriptor + compile + + descriptor + + + + + + + + \ No newline at end of file diff --git a/MavenPlugin/src/main/java/org/plugin/ DeveloperInfoMojo.java b/MavenPlugin/src/main/java/org/plugin/ DeveloperInfoMojo.java new file mode 100644 index 0000000..9e34cad --- /dev/null +++ b/MavenPlugin/src/main/java/org/plugin/ DeveloperInfoMojo.java @@ -0,0 +1,48 @@ +package org.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +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.model.Developer; +import org.apache.maven.project.MavenProject; + +import java.util.List; + +@Mojo(name = "show-developers", defaultPhase = LifecyclePhase.PACKAGE) +public class DeveloperInfoMojo extends AbstractMojo { + + @Parameter(defaultValue = "${project}", readonly = true) + private MavenProject project; + + @Parameter(property = "showEmails", defaultValue = "true") + private boolean showEmails; + + @Parameter(property = "showUrls", defaultValue = "true") + private boolean showUrls; + + public void execute() throws MojoExecutionException { + List developers = project.getDevelopers(); + + if (developers.isEmpty()) { + getLog().info("No developers found"); + return; + } + + getLog().info("Developer(s) info:"); + developers.forEach(this::logDeveloperInfo); + } + + private void logDeveloperInfo(Developer dev) { + getLog().info("Name: " + dev.getName()); + if (showEmails && dev.getEmail() != null) { + getLog().info("Email: " + dev.getEmail()); + } + if (showUrls && dev.getUrl() != null) { + getLog().info("URL: " + dev.getUrl()); + } + getLog().info("------------------------"); + } +}