diff --git a/2022/01/mojo_demo1/maven_mojo1/pom.xml b/2022/01/mojo_demo1/maven_mojo1/pom.xml index 045717d..70e1fca 100644 --- a/2022/01/mojo_demo1/maven_mojo1/pom.xml +++ b/2022/01/mojo_demo1/maven_mojo1/pom.xml @@ -23,6 +23,11 @@ 3.2 provided + + org.apache.maven + maven-project + 2.2.1 + junit junit diff --git a/2022/01/mojo_demo1/maven_mojo1/src/main/java/ch/polgrabia/demos/MyMojo.java b/2022/01/mojo_demo1/maven_mojo1/src/main/java/ch/polgrabia/demos/MyMojo.java index d00416a..b24834e 100644 --- a/2022/01/mojo_demo1/maven_mojo1/src/main/java/ch/polgrabia/demos/MyMojo.java +++ b/2022/01/mojo_demo1/maven_mojo1/src/main/java/ch/polgrabia/demos/MyMojo.java @@ -6,6 +6,7 @@ import org.apache.maven.plugin.logging.Log; 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; import java.io.File; import java.io.FileWriter; @@ -19,9 +20,15 @@ public class MyMojo @Parameter(property = "outputDirectory", defaultValue = "target") private File outputDirectory; + @Parameter(defaultValue = "${project}", required = true, readonly = true) + private MavenProject project; + public void execute() throws MojoExecutionException { + logger.info("Starting execution..."); + logger.info(String.format("My-mojo plugin running on %s:%s:%s", + project.getGroupId(), project.getArtifactId(), project.getVersion())); File f = outputDirectory; if (!f.exists()) {