Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Jul 4, 2024
1 parent ff9e569 commit 651abd2
Show file tree
Hide file tree
Showing 36 changed files with 1,414 additions and 2,109 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is the [animal-sniffer-maven-plugin](https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/).

Please note this plugin is now in maintenance level as the exact same feature can be now easily achieved using the `--release`
Please note this plugin is now in maintenance level as the exact same feature can be now easily achieved using the `--release`
flag from Javac see (https://openjdk.java.net/jeps/247)

[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/animal-sniffer-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.mojo/animal-sniffer-maven-plugin)
Expand All @@ -21,3 +21,4 @@ cd target/checkout
mvn verify site
mvn scm-publish:publish-scm
```

Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.CLASS;

/**
* @author Kohsuke Kawaguchi
*/
@Retention(CLASS)
@Documented
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.FIELD})
public @interface IgnoreJRERequirement
{
}
public @interface IgnoreJRERequirement {}
6 changes: 2 additions & 4 deletions animal-sniffer-ant-tasks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
<packaging>jar</packaging>

<name>Animal Sniffer Ant Tasks</name>
<description>
Animal Sniffer Ant Tasks.
</description>
<description>Animal Sniffer Ant Tasks.</description>

<properties>
<!-- skip execution of invoker tests for now, as something is seriously botched
Expand Down Expand Up @@ -66,10 +64,10 @@
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,39 @@
/**
* @author Stephane Nicoll
*/
public class Annotation
{
public class Annotation {
private String className;

public String getClassName()
{
public String getClassName() {
return className;
}

public void setClassName( String className )
{
public void setClassName(String className) {
this.className = className;
}

public boolean equals( Object o )
{
if ( this == o )
{
public boolean equals(Object o) {
if (this == o) {
return true;
}
if ( !( o instanceof Annotation ) )
{
if (!(o instanceof Annotation)) {
return false;
}

Annotation annotation = (Annotation) o;

if ( className != null ? !className.equals( annotation.className ) : annotation.className != null )
{
if (className != null ? !className.equals(annotation.className) : annotation.className != null) {
return false;
}

return true;
}

public int hashCode()
{
public int hashCode() {
return 0;
}

public String toString()
{
public String toString() {
return "Annotation{" + "className='" + className + '\'' + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,52 @@
*
*/

import org.codehaus.mojo.animal_sniffer.logging.Logger;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.codehaus.mojo.animal_sniffer.logging.Logger;

/**
* An animal sniffer logger that delegates to a maven log.
*
* @author connollys
* @since 1.3
*/
public final class AntLogger
implements Logger
{
public final class AntLogger implements Logger {
private final Task delegate;

public AntLogger( Task delegate )
{
public AntLogger(Task delegate) {
this.delegate = delegate;
}

public void info( String message )
{
delegate.log( message, Project.MSG_INFO );
public void info(String message) {
delegate.log(message, Project.MSG_INFO);
}

public void info( String message, Throwable t )
{
delegate.log( message, t, Project.MSG_INFO );
public void info(String message, Throwable t) {
delegate.log(message, t, Project.MSG_INFO);
}

public void debug( String message )
{
delegate.log( message, Project.MSG_DEBUG );
public void debug(String message) {
delegate.log(message, Project.MSG_DEBUG);
}

public void debug( String message, Throwable t )
{
delegate.log( message, t, Project.MSG_DEBUG );
public void debug(String message, Throwable t) {
delegate.log(message, t, Project.MSG_DEBUG);
}

public void warn( String message )
{
delegate.log( message, Project.MSG_WARN );
public void warn(String message) {
delegate.log(message, Project.MSG_WARN);
}

public void warn( String message, Throwable t )
{
delegate.log( message, t, Project.MSG_WARN );
public void warn(String message, Throwable t) {
delegate.log(message, t, Project.MSG_WARN);
}

public void error( String message )
{
delegate.log( message, Project.MSG_ERR );
public void error(String message) {
delegate.log(message, Project.MSG_ERR);
}

public void error( String message, Throwable t )
{
delegate.log( message, t, Project.MSG_ERR );
public void error(String message, Throwable t) {
delegate.log(message, t, Project.MSG_ERR);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
/**
* @author Kohsuke Kawaguchi
*/
public class BuildSignaturesTask
extends Task
{
public class BuildSignaturesTask extends Task {

private File destfile;

Expand All @@ -55,122 +53,92 @@ public class BuildSignaturesTask

private Vector<Ignore> excludeClasses = new Vector<>();

public void setDestfile( File dest )
{
public void setDestfile(File dest) {
this.destfile = dest;
}

public void addPath( Path path )
{
paths.add( path );
public void addPath(Path path) {
paths.add(path);
}

public Signature createSignature()
{
public Signature createSignature() {
Signature signature = new Signature();
signatures.add( signature );
signatures.add(signature);
return signature;
}

public Ignore createIncludeClasses()
{
public Ignore createIncludeClasses() {
final Ignore result = new Ignore();
includeClasses.add( result );
includeClasses.add(result);
return result;
}

public Ignore createExcludeClasses()
{
public Ignore createExcludeClasses() {
final Ignore result = new Ignore();
excludeClasses.add( result );
excludeClasses.add(result);
return result;
}

protected void validate()
{
if ( destfile == null )
{
throw new BuildException( "destfile not set" );
protected void validate() {
if (destfile == null) {
throw new BuildException("destfile not set");
}
if ( paths.size() < 1 )
{
throw new BuildException( "path not set" );
if (paths.size() < 1) {
throw new BuildException("path not set");
}
for ( Signature signature : signatures )
{
if ( signature.getSrc() == null )
{
throw new BuildException( "signature src not set" );
for (Signature signature : signatures) {
if (signature.getSrc() == null) {
throw new BuildException("signature src not set");
}
if ( !signature.getSrc().isFile() )
{
throw new BuildException( "signature " + signature.getSrc() + " does not exist" );
if (!signature.getSrc().isFile()) {
throw new BuildException("signature " + signature.getSrc() + " does not exist");
}
}
for ( Ignore tmp : includeClasses )
{
if ( tmp.getClassName() == null )
{
throw new BuildException( "includeClasses className not set" );
for (Ignore tmp : includeClasses) {
if (tmp.getClassName() == null) {
throw new BuildException("includeClasses className not set");
}
}
for ( Ignore tmp : excludeClasses )
{
if ( tmp.getClassName() == null )
{
throw new BuildException( "excludeClasses className not set" );
for (Ignore tmp : excludeClasses) {
if (tmp.getClassName() == null) {
throw new BuildException("excludeClasses className not set");
}
}

}

public void execute()
throws BuildException
{
public void execute() throws BuildException {
validate();
try
{
try {
Vector<InputStream> inStreams = new Vector<>();
for ( Signature signature : signatures )
{
log( "Importing signatures from " + signature.getSrc() );
inStreams.add( new FileInputStream( signature.getSrc() ) );
for (Signature signature : signatures) {
log("Importing signatures from " + signature.getSrc());
inStreams.add(new FileInputStream(signature.getSrc()));
}

SignatureBuilder builder =
new SignatureBuilder( inStreams.toArray( new InputStream[0] ),
new FileOutputStream( destfile ), new AntLogger( this ) );
for ( Ignore tmp: includeClasses )
{
builder.addInclude( tmp.getClassName() );
SignatureBuilder builder = new SignatureBuilder(
inStreams.toArray(new InputStream[0]), new FileOutputStream(destfile), new AntLogger(this));
for (Ignore tmp : includeClasses) {
builder.addInclude(tmp.getClassName());
}
for ( Ignore tmp : excludeClasses )
{
builder.addExclude( tmp.getClassName() );
for (Ignore tmp : excludeClasses) {
builder.addExclude(tmp.getClassName());
}
for ( Path path : paths )
{
for (Path path : paths) {
final String[] files = path.list();
for ( String file : files )
{
log( "Capturing signatures from " + file, Project.MSG_INFO );
process( builder, new File( file ) );
for (String file : files) {
log("Capturing signatures from " + file, Project.MSG_INFO);
process(builder, new File(file));
}
}
builder.close();
}
catch ( IOException e )
{
throw new BuildException( e );
} catch (IOException e) {
throw new BuildException(e);
}
}

private void process( SignatureBuilder builder, File f )
throws IOException
{
if ( f.exists() )
{
builder.process( f );
private void process(SignatureBuilder builder, File f) throws IOException {
if (f.exists()) {
builder.process(f);
}
}
}
Loading

0 comments on commit 651abd2

Please sign in to comment.