From af2576975755f9bb04c2fd4294b63106aefd309d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20No=C3=ABl?= Date: Sat, 16 May 2020 14:11:57 +0200 Subject: [PATCH 1/3] (#3) - jPeek mojo for main classes --- README.md | 20 ++++++-- pom.xml | 26 ++++++++++ src/main/java/org/jpeek/plugin/JpeekMojo.java | 51 ++++++++++++++++--- 3 files changed, 86 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3691d9b..e33a76f 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,29 @@ Add the plugin execution to your `pom.xml`: -``` +```xml org.jpeek jpeek-maven-plugin - 0.0.1-SNAPSHOT + 1.0-SNAPSHOT - jpeek-analysis + + analyze + + + ${project.build.outputDirectory} + ${project.build.directory}/jpeek/ + -``` \ No newline at end of file +``` + +Or run it from the command-line: + +``` +mvn org.jpeek:jpeek-maven-plugin:1.0-SNAPSHOT:analyze +``` diff --git a/pom.xml b/pom.xml index 2cf3d1d..7117c95 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ SOFTWARE. https://github.com/yegor256/jpeek-maven-plugin 2020 + UTF-8 1.8 1.8 @@ -72,7 +73,32 @@ SOFTWARE. 3.6.0 provided + + org.jpeek + jpeek + 0.30.24 + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.6.0 + + + mojo-descriptor + process-classes + + descriptor + + + + + + + qulice diff --git a/src/main/java/org/jpeek/plugin/JpeekMojo.java b/src/main/java/org/jpeek/plugin/JpeekMojo.java index 87e7a4b..48ed40f 100644 --- a/src/main/java/org/jpeek/plugin/JpeekMojo.java +++ b/src/main/java/org/jpeek/plugin/JpeekMojo.java @@ -23,25 +23,62 @@ */ package org.jpeek.plugin; +import java.io.File; +import java.io.IOException; 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.jpeek.App; /** * {@link org.apache.maven.plugin.AbstractMojo} implementation for jPeek. * * @since 0.1 - * @todo #1:30min Implement jpeek plugin execution - * JpeekMojo must execute jpeek and analyze project files upon build. - * Use the jpeek jar from manve repository to execute it with in the - * project. + * @todo #3:30min Add some tests for this Mojo using AbstractMojoTestCase + * from maven-plugin-testing-harness. A good resource for examples is + * maven-checkstyle-plugin. It has been verified that it works from the + * command line (see README). + * @todo #3:30min Add support for analyzing classes in the test directory. + * This should output an analysis most certainly in a different directory + * from the main classes. */ -@Mojo(name = "jpeek-analysis", defaultPhase = LifecyclePhase.TEST) -public class JpeekMojo extends AbstractMojo { +@Mojo(name = "analyze", defaultPhase = LifecyclePhase.SITE) +public final class JpeekMojo extends AbstractMojo { + + /** + * Specifies the path where to find classes analyzed by jPeek. + * @checkstyle MemberNameCheck (3 lines) + */ + @Parameter(property = "jpeek.input", defaultValue = "${project.build.outputDirectory}") + private File inputDirectory; + + /** + * Specifies the path to save the jPeek output. + * @checkstyle MemberNameCheck (3 lines) + */ + @Parameter(property = "jpeek.output", defaultValue = "${project.build.directory}/jpeek/") + private File outputDirectory; + + /** + * Skip analyze. + */ + @Parameter(property = "jpeek.skip", defaultValue = "false") + private boolean skip; + @Override public void execute() throws MojoExecutionException, MojoFailureException { - //method body + if (!this.skip) { + try { + new App( + this.inputDirectory.toPath(), + this.outputDirectory.toPath() + ).analyze(); + } catch (final IOException ex) { + throw new MojoExecutionException("Couldn't analyze", ex); + } + } } } From 64d3003c9b3d2b470e681a4ced9847660a4ee65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20No=C3=ABl?= Date: Tue, 19 May 2020 20:20:05 +0200 Subject: [PATCH 2/3] (#3) - Add Eclipse files to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 2d513a0..c164804 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /.idea/ /target/ +/.settings/ +.project +.classpath +.factorypath From f930a302c7d8e175775a4161d326e21d9626f1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20No=C3=ABl?= Date: Tue, 19 May 2020 20:20:21 +0200 Subject: [PATCH 3/3] (#3) - Bind the analyze goal to the site phase as per ARC request --- README.md | 2 +- src/main/java/org/jpeek/plugin/JpeekMojo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e33a76f..b993b67 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Add the plugin execution to your `pom.xml`: - + analyze diff --git a/src/main/java/org/jpeek/plugin/JpeekMojo.java b/src/main/java/org/jpeek/plugin/JpeekMojo.java index 48ed40f..f1b415a 100644 --- a/src/main/java/org/jpeek/plugin/JpeekMojo.java +++ b/src/main/java/org/jpeek/plugin/JpeekMojo.java @@ -45,7 +45,7 @@ * This should output an analysis most certainly in a different directory * from the main classes. */ -@Mojo(name = "analyze", defaultPhase = LifecyclePhase.SITE) +@Mojo(name = "analyze", defaultPhase = LifecyclePhase.VERIFY) public final class JpeekMojo extends AbstractMojo { /**