Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
use maven annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiankirsch committed Sep 28, 2013
1 parent 74a7ec8 commit 7b2b56c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
28 changes: 27 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
Expand Down Expand Up @@ -113,12 +131,19 @@
</build>

<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
Expand All @@ -134,6 +159,7 @@
<artifactId>javassist</artifactId>
<version>3.18.0-GA</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -160,7 +186,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.5</version>
<version>${maven.plugin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
35 changes: 13 additions & 22 deletions src/main/java/de/is24/deadcode4j/plugin/FindDeadCodeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,36 @@
import de.is24.deadcode4j.DeadCode;
import de.is24.deadcode4j.DeadCodeFinder;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Execute;
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.util.Collection;
import java.util.Set;

import static com.google.common.collect.Lists.newArrayList;
import static org.apache.maven.plugins.annotations.LifecyclePhase.COMPILE;

/**
* The FindDeadCodeMojo attempts to find unused code.
* Finds dead (i.e. unused) code.
*
* @description Finds dead (i.e. unused) code
* @goal find
* @execute phase="compile"
* @threadSafe true
* @since 1.0.0
*/
@SuppressWarnings("UnusedDeclaration")
@Mojo(name = "find", threadSafe = true)
@Execute(phase = COMPILE)
public class FindDeadCodeMojo extends AbstractMojo {

/**
* The Maven Project.
*
* @parameter expression="${project}"
* @readonly
* @required
*/
@Component
private MavenProject project;

/**
* Lists the "dead" classes that should be ignored.
*
* @parameter
*/
/** Lists the "dead" classes that should be ignored. */
@Parameter
private Set<String> classesToIgnore;

public void execute() throws MojoExecutionException, MojoFailureException {
public void execute() {
DeadCode deadCode = analyzeCode();
log(deadCode);
}
Expand Down

0 comments on commit 7b2b56c

Please sign in to comment.