Skip to content

Instantly share code, notes, and snippets.

@learnit-codeit
Created December 21, 2020 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save learnit-codeit/0b042740064a94774112f035a2572f23 to your computer and use it in GitHub Desktop.
Save learnit-codeit/0b042740064a94774112f035a2572f23 to your computer and use it in GitHub Desktop.
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