Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 19, 2020
2 parents 6022acc + f930a30 commit 5ea8c40
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/.idea/
/target/
/.settings/
.project
.classpath
.factorypath
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

Add the plugin execution to your `pom.xml`:

```
```xml
<plugin>
<groupId>org.jpeek</groupId>
<artifactId>jpeek-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>jpeek-analysis</goal>
<!-- Bound by default to verify phase -->
<goal>analyze</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Those are the default values -->
<inputDirectory>${project.build.outputDirectory}</inputDirectory>
<outputDirectory>${project.build.directory}/jpeek/</outputDirectory>
</configuration>
</plugin>
```
```

Or run it from the command-line:

```
mvn org.jpeek:jpeek-maven-plugin:1.0-SNAPSHOT:analyze
```
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ SOFTWARE.
<url>https://github.com/yegor256/jpeek-maven-plugin</url>
<inceptionYear>2020</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Expand Down Expand Up @@ -72,7 +73,32 @@ SOFTWARE.
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jpeek</groupId>
<artifactId>jpeek</artifactId>
<version>0.30.24</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>mojo-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>qulice</id>
Expand Down
51 changes: 44 additions & 7 deletions src/main/java/org/jpeek/plugin/JpeekMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.VERIFY)
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);
}
}
}
}

3 comments on commit 5ea8c40

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 5ea8c40 May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-34fd3cb7 disappeared from src/main/java/org/jpeek/plugin/JpeekMojo.java, that's why I closed #3. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 5ea8c40 May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 3-16086dcb discovered in src/main/java/org/jpeek/plugin/JpeekMojo.java and submitted as #6. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 5ea8c40 May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 3-fbe16028 discovered in src/main/java/org/jpeek/plugin/JpeekMojo.java and submitted as #7. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.