Created
December 21, 2020 04:43
-
-
Save learnit-codeit/0b042740064a94774112f035a2572f23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.maven.model.Dependency; | |
import org.apache.maven.plugin.AbstractMojo; | |
import org.apache.maven.plugin.MojoExecutionException; | |
import org.apache.maven.plugin.MojoFailureException; | |
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; | |
@Mojo(name = "my-sample", defaultPhase = LifecyclePhase.COMPILE) | |
public class MySampleMojo extends AbstractMojo { | |
@Parameter(defaultValue = "${project}", required = true, readonly = true) | |
MavenProject project; | |
public void execute() throws MojoExecutionException, MojoFailureException { | |
getLog().info("========== PROJECT DETAILS ========="); | |
getLog().info(">>>> GroupId :" + project.getGroupId()); | |
getLog().info(">>>> ArtifactId :" + project.getArtifactId()); | |
getLog().info(">>>> Version :" + project.getVersion()); | |
List<Dependency> dependencies = project.getDependencies(); | |
getLog().info(">>>> Dependencies :"); | |
for (Dependency eachDep : dependencies) { | |
getLog().info(eachDep.getGroupId() + ":" + eachDep.getArtifactId() + ":" + eachDep.getVersion()); | |
} | |
getLog().info("===================================="); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment