http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java index db7b026..caf27d8 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/PropertiesUtil.java @@ -19,6 +19,9 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.configuration.PlexusConfiguration; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -34,12 +37,9 @@ import java.util.Iterator; import java.util.Map; import java.util.Properties; -import org.apache.maven.plugin.MojoExecutionException; -import org.codehaus.plexus.configuration.PlexusConfiguration; - /** * Assists in handling properties. - * + * * @author Benjamin Bentmann */ class PropertiesUtil @@ -164,18 +164,17 @@ class PropertiesUtil PlexusConfiguration children[] = config.getChildren(); props.setProperty( key + ".children", Integer.toString( children.length ) ); - Map indices = new HashMap(); - for ( int i = 0; i < children.length; i++ ) + Map<String, Integer> indices = new HashMap<>(); + for ( PlexusConfiguration child : children ) { - PlexusConfiguration child = children[i]; String name = child.getName(); - Integer index = (Integer) indices.get( name ); + Integer index = indices.get( name ); if ( index == null ) { - index = new Integer( 0 ); + index = 0; } serialize( props, key + ".children." + name + "." + index, child ); - indices.put( name, new Integer( index.intValue() + 1 ) ); + indices.put( name, index + 1 ); } } else if ( value instanceof Date )
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java index 29c8b72..ab4d2ac 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-core-stubs/maven-resources-plugin/src/main/java/org/apache/maven/plugin/coreit/ResourcesMojo.java @@ -31,12 +31,11 @@ import java.io.OutputStreamWriter; /** * Creates a text file in the project base directory. - * - * @goal resources - * @phase process-resources - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal resources + * @phase process-resources */ public class ResourcesMojo extends AbstractMojo @@ -44,7 +43,7 @@ public class ResourcesMojo /** * The current Maven project. - * + * * @parameter default-value="${project}" * @required * @readonly @@ -53,7 +52,7 @@ public class ResourcesMojo /** * The path to the output file, relative to the project base directory directory. - * + * * @parameter */ private String pathname = "target/resources-resources.txt"; @@ -61,16 +60,16 @@ public class ResourcesMojo /** * An optional message line to write to the output file (using UTF-8 encoding). If given, the output file will be * opened in append mode. - * + * * @parameter */ private String message; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. - * @throws MojoFailureException If the output file has not been set. + * @throws MojoFailureException If the output file has not been set. */ public void execute() throws MojoExecutionException, MojoFailureException @@ -98,16 +97,12 @@ public class ResourcesMojo { getLog().info( "[MAVEN-CORE-IT-LOG] " + message ); - OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), "UTF-8" ); - try + try ( OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), + "UTF-8" ) ) { writer.write( message ); writer.write( "\n" ); } - finally - { - writer.close(); - } } else { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java index 286dae5..68e6430 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java @@ -30,11 +30,10 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Collection; -import java.util.Iterator; /** * Provides common services for all mojos of this plugin. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -44,7 +43,7 @@ public abstract class AbstractDependencyMojo /** * The current Maven project. - * + * * @parameter default-value="${project}" * @required * @readonly @@ -53,9 +52,9 @@ public abstract class AbstractDependencyMojo /** * Writes the specified artifacts to the given output file. - * - * @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or - * empty if the output file should not be written. + * + * @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or + * empty if the output file should not be written. * @param artifacts The list of artifacts to write to the file, may be <code>null</code>. * @throws MojoExecutionException If the output file could not be written. */ @@ -80,9 +79,9 @@ public abstract class AbstractDependencyMojo if ( artifacts != null ) { - for ( Iterator it = artifacts.iterator(); it.hasNext(); ) + for ( Object artifact1 : artifacts ) { - Artifact artifact = (Artifact) it.next(); + Artifact artifact = (Artifact) artifact1; writer.write( artifact.getId() ); writer.newLine(); getLog().info( "[MAVEN-CORE-IT-LOG] " + artifact.getId() ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java index 54844db..7f85416 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-collection/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java @@ -19,24 +19,22 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.util.Iterator; -import java.util.List; - import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.util.List; + /** * Combines dependency collection with aggregation. The path parameters of this mojo support the token * <code>@artifactId@</code> to dynamically adjust the output file for each project in the reactor whose * dependencies are dumped. - * + * + * @author Benjamin Bentmann + * @version $Id$ * @goal aggregate-test * @requiresDependencyCollection test * @aggregator true - * - * @author Benjamin Bentmann - * @version $Id$ */ public class AggregateTestMojo extends AbstractDependencyMojo @@ -47,14 +45,14 @@ public class AggregateTestMojo * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to * disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that * do not contribute to the class path. - * + * * @parameter property="depres.projectArtifacts" */ private String projectArtifacts; /** * The Maven projects in the reactor. - * + * * @parameter default-value="${reactorProjects}" * @readonly */ @@ -62,7 +60,7 @@ public class AggregateTestMojo /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved. */ public void execute() @@ -70,9 +68,9 @@ public class AggregateTestMojo { try { - for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) + for ( Object reactorProject : reactorProjects ) { - MavenProject project = (MavenProject) it.next(); + MavenProject project = (MavenProject) reactorProject; writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java index 9d585d2..6990a6d 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AbstractDependencyMojo.java @@ -34,12 +34,11 @@ import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Collection; -import java.util.Iterator; import java.util.Properties; /** * Provides common services for all mojos of this plugin. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -49,7 +48,7 @@ public abstract class AbstractDependencyMojo /** * The current Maven project. - * + * * @parameter default-value="${project}" * @required * @readonly @@ -62,16 +61,16 @@ public abstract class AbstractDependencyMojo * this parameter to 1 to keep only the simple file name. The trimmed down paths will always use the forward slash * as directory separator. For non-positive values, the full/absolute path is returned, using the platform-specific * separator. - * + * * @parameter property="depres.significantPathLevels" */ private int significantPathLevels; /** * Writes the specified artifacts to the given output file. - * - * @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or - * empty if the output file should not be written. + * + * @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or + * empty if the output file should not be written. * @param artifacts The list of artifacts to write to the file, may be <code>null</code>. * @throws MojoExecutionException If the output file could not be written. */ @@ -96,9 +95,9 @@ public abstract class AbstractDependencyMojo if ( artifacts != null ) { - for ( Iterator it = artifacts.iterator(); it.hasNext(); ) + for ( Object artifact1 : artifacts ) { - Artifact artifact = (Artifact) it.next(); + Artifact artifact = (Artifact) artifact1; String id = getId( artifact ); writer.write( id ); writer.newLine(); @@ -134,9 +133,9 @@ public abstract class AbstractDependencyMojo /** * Writes the specified class path elements to the given output file. - * - * @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or - * empty if the output file should not be written. + * + * @param pathname The path to the output file, relative to the project base directory, may be <code>null</code> or + * empty if the output file should not be written. * @param classPath The list of class path elements to write to the file, may be <code>null</code>. * @throws MojoExecutionException If the output file could not be written. */ @@ -161,9 +160,9 @@ public abstract class AbstractDependencyMojo if ( classPath != null ) { - for ( Iterator it = classPath.iterator(); it.hasNext(); ) + for ( Object aClassPath : classPath ) { - String element = it.next().toString(); + String element = aClassPath.toString(); writer.write( stripLeadingDirs( element, significantPathLevels ) ); writer.newLine(); getLog().info( "[MAVEN-CORE-IT-LOG] " + element ); @@ -206,9 +205,9 @@ public abstract class AbstractDependencyMojo if ( classPath != null ) { - for ( Iterator it = classPath.iterator(); it.hasNext(); ) + for ( Object aClassPath : classPath ) { - String element = it.next().toString(); + String element = aClassPath.toString(); File jarFile = new File( element ); @@ -274,8 +273,7 @@ public abstract class AbstractDependencyMojo { MessageDigest digester = MessageDigest.getInstance( "SHA-1" ); - FileInputStream is = new FileInputStream( jarFile ); - try + try ( FileInputStream is = new FileInputStream( jarFile ) ) { DigestInputStream dis = new DigestInputStream( is, digester ); @@ -284,19 +282,14 @@ public abstract class AbstractDependencyMojo // just read it } } - finally - { - is.close(); - } byte[] digest = digester.digest(); - StringBuffer hash = new StringBuffer( digest.length * 2 ); + StringBuilder hash = new StringBuilder( digest.length * 2 ); - for ( int i = 0; i < digest.length; i++ ) + for ( byte aDigest : digest ) { - @SuppressWarnings( "checkstyle:magicnumber" ) - int b = digest[i] & 0xFF; + @SuppressWarnings( "checkstyle:magicnumber" ) int b = aDigest & 0xFF; if ( b < 0x10 ) { @@ -341,7 +334,7 @@ public abstract class AbstractDependencyMojo if ( pathname != null ) { - if ( pathname.indexOf( "@idx@" ) >= 0 ) + if ( pathname.contains( "@idx@" ) ) { // helps to distinguished forked executions of the same mojo pathname = pathname.replaceAll( "@idx@", String.valueOf( nextCounter() ) ); @@ -366,7 +359,7 @@ public abstract class AbstractDependencyMojo synchronized ( System.class ) { - counter = Integer.getInteger( key, 0 ).intValue(); + counter = Integer.getInteger( key, 0 ); System.setProperty( key, Integer.toString( counter + 1 ) ); } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java index ae4e9b4..38e8a8c 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/AggregateTestMojo.java @@ -19,24 +19,22 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.util.Iterator; -import java.util.List; - import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.util.List; + /** * Combines dependency resolution with aggregation. The path parameters of this mojo support the token * <code>@artifactId@</code> to dynamically adjust the output file for each project in the reactor whose * dependencies are dumped. - * + * + * @author Benjamin Bentmann + * @version $Id$ * @goal aggregate-test * @requiresDependencyResolution test * @aggregator true - * - * @author Benjamin Bentmann - * @version $Id$ */ public class AggregateTestMojo extends AbstractDependencyMojo @@ -47,7 +45,7 @@ public class AggregateTestMojo * UTF-8 encoded file specifies an artifact identifier. If not specified, the artifact list will not be written to * disk. Unlike the test artifacts, the collection of project artifacts additionally contains those artifacts that * do not contribute to the class path. - * + * * @parameter property="depres.projectArtifacts" */ private String projectArtifacts; @@ -56,7 +54,7 @@ public class AggregateTestMojo * The path to the output file for the test class path, relative to the project base directory. Each line of * this UTF-8 encoded file specifies the absolute path to a class path element. If not specified, the class path * will not be written to disk. - * + * * @parameter property="depres.testClassPath" */ private String testClassPath; @@ -65,14 +63,14 @@ public class AggregateTestMojo * The path to the properties file for the checksums of the test class path elements, relative to the project base * directory. The (trimmed) path to a JAR is used as the property key, the property value is the SHA-1 hash of the * JAR. If not specified, the class path checksums will not be calculated. - * + * * @parameter property="depres.testClassPathChecksums" */ private String testClassPathChecksums; /** * The Maven projects in the reactor. - * + * * @parameter default-value="${reactorProjects}" * @readonly */ @@ -80,7 +78,7 @@ public class AggregateTestMojo /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved. */ public void execute() @@ -88,9 +86,9 @@ public class AggregateTestMojo { try { - for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) + for ( Object reactorProject : reactorProjects ) { - MavenProject project = (MavenProject) it.next(); + MavenProject project = (MavenProject) reactorProject; writeArtifacts( filter( projectArtifacts, project ), project.getArtifacts() ); writeClassPath( filter( testClassPath, project ), project.getTestClasspathElements() ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java index 69dfd18..1f21b3c 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/InjectMojo.java @@ -19,25 +19,23 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Set; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Set; + /** * Injects artifacts from the plugin into the dependency artifacts of the project. - * - * @goal inject - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal inject */ public class InjectMojo extends AbstractMojo @@ -46,7 +44,7 @@ public class InjectMojo /** * The version-less keys in the form <code>groupId:artifactId</code> of the plugin artifacts to inject into * dependency artifacts of the project. - * + * * @parameter */ private String[] artifacts; @@ -59,7 +57,7 @@ public class InjectMojo /** * The current Maven project. - * + * * @parameter default-value="${project}" * @required * @readonly @@ -68,14 +66,14 @@ public class InjectMojo /** * The artifact factory. - * + * * @component */ private ArtifactFactory factory; /** * Runs this mojo. - * + * * @throws MojoExecutionException If an error occured. */ public void execute() @@ -99,16 +97,17 @@ public class InjectMojo dependencyArtifacts = new LinkedHashSet(); } - for ( Iterator it = pluginArtifacts.iterator(); it.hasNext(); ) + for ( Object pluginArtifact : pluginArtifacts ) { - Artifact artifact = (Artifact) it.next(); + Artifact artifact = (Artifact) pluginArtifact; String artifactKey = artifact.getGroupId() + ':' + artifact.getArtifactId(); if ( artifactKeys.remove( artifactKey ) ) { - artifact = factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion(), Artifact.SCOPE_COMPILE, artifact.getType() ); + artifact = + factory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), + Artifact.SCOPE_COMPILE, artifact.getType() ); getLog().info( "[MAVEN-CORE-IT-LOG] Injecting dependency artifact " + artifact ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/ResolveOneDependencyMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/ResolveOneDependencyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/ResolveOneDependencyMojo.java index 9a9e9d7..cc58125 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/ResolveOneDependencyMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-dependency-resolution/src/main/java/org/apache/maven/plugin/coreit/ResolveOneDependencyMojo.java @@ -19,11 +19,6 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.io.File; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -36,13 +31,17 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.io.File; +import java.util.HashSet; +import java.util.Set; + /** * Attempts to resolve a single artifact from dependencies, and logs the results for the Verifier to look at. - * - * @goal resolve-one-dependency - * @requiresDependencyResolution runtime + * * @author bimargulies * @version $Id$ + * @goal resolve-one-dependency + * @requiresDependencyResolution runtime */ public class ResolveOneDependencyMojo extends AbstractDependencyMojo @@ -50,42 +49,46 @@ public class ResolveOneDependencyMojo /** * Group ID of the artifact to resolve. - * + * * @parameter * @required */ private String groupId; + /** * Artifact ID of the artifact to resolve. - * + * * @parameter * @required */ private String artifactId; + /** * Version of the artifact to resolve. - * + * * @parameter * @required */ private String version; + /** * Type of the artifact to resolve. - * + * * @parameter * @required */ private String type; + /** * Classifier of the artifact to resolve. - * + * * @parameter */ private String classifier; /** * The scope to resolve for. - * + * * @parameter * @required */ @@ -111,7 +114,7 @@ public class ResolveOneDependencyMojo /** * The Maven session. - * + * * @parameter default-value="${session}" * @readonly * @required @@ -120,14 +123,14 @@ public class ResolveOneDependencyMojo /** * Metadata source object. - * + * * @component */ private ArtifactMetadataSource metadataSource; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved. */ public void execute() @@ -137,9 +140,8 @@ public class ResolveOneDependencyMojo Artifact projectArtifact = project.getArtifact(); if ( projectArtifact == null ) { - projectArtifact = - artifactFactory.createProjectArtifact( project.getGroupId(), project.getArtifactId(), - project.getVersion() ); + projectArtifact = artifactFactory.createProjectArtifact( project.getGroupId(), project.getArtifactId(), + project.getVersion() ); } Set depArtifacts = new HashSet(); @@ -152,10 +154,10 @@ public class ResolveOneDependencyMojo ArtifactResolutionResult result; try { - result = - resolver.resolveTransitively( depArtifacts, projectArtifact, project.getManagedVersionMap(), - session.getLocalRepository(), project.getRemoteArtifactRepositories(), - metadataSource, scopeFilter ); + result = resolver.resolveTransitively( depArtifacts, projectArtifact, project.getManagedVersionMap(), + session.getLocalRepository(), + project.getRemoteArtifactRepositories(), metadataSource, + scopeFilter ); } catch ( ArtifactResolutionException e ) { @@ -173,13 +175,12 @@ public class ResolveOneDependencyMojo else { Set resolvedArtifacts = result.getArtifacts(); - Iterator it = resolvedArtifacts.iterator(); /* * Assume that the user of this is not interested in transitive deps and such, just report the one. */ - while ( it.hasNext() ) + for ( Object resolvedArtifact : resolvedArtifacts ) { - Artifact a = (Artifact) it.next(); + Artifact a = (Artifact) resolvedArtifact; if ( a.equals( artifact ) ) { File file = a.getFile(); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/EvalMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/EvalMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/EvalMojo.java index ac69865..8d3ca75 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/EvalMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/EvalMojo.java @@ -26,7 +26,6 @@ import org.apache.maven.plugin.MojoFailureException; import java.io.File; import java.io.IOException; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Properties; @@ -37,7 +36,7 @@ import java.util.Properties; * value but can also be a collection/array or a bean-like object (from the Maven model). For example, the expression * "project/dependencies/0" would extract the first project dependency. In more detail, this example expression could * output the following keys to the properties file: - * + * <p/> * <pre> * project.dependencies.0.groupId = org.apache.maven * project.dependencies.0.artifactId = maven-project @@ -50,15 +49,14 @@ import java.util.Properties; * project.dependencies.0.exclusions.1.groupId = plexus * project.dependencies.0.exclusions.1.artifactId = plexus-container-default * </pre> - * + * <p/> * Expressions that reference non-existing objects or use invalid collection/array indices silently resolve to * <code>null</code>. For collections and arrays, the special index "*" can be used to iterate all elements. - * - * @goal eval - * @phase initialize - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal eval + * @phase initialize */ public class EvalMojo extends AbstractMojo @@ -66,7 +64,7 @@ public class EvalMojo /** * The project's base directory, used for manual path translation. - * + * * @parameter default-value="${basedir}" * @readonly */ @@ -76,28 +74,28 @@ public class EvalMojo * The path to the output file for the properties with the expression values. For each expression given by the * parameter {@link #expressions} an similar named properties key will be used to save the expression value. If an * expression evaluated to <code>null</code>, there will be no corresponding key in the properties file. - * + * * @parameter property="expression.outputFile" */ private File outputFile; /** * The set of expressions to evaluate. - * + * * @parameter */ private String[] expressions; /** * The comma separated set of expressions to evaluate. - * + * * @parameter property="expression.expressions" */ private String expressionList; /** * The current Maven project against which expressions are evaluated. - * + * * @parameter default-value="${project}" * @readonly */ @@ -105,7 +103,7 @@ public class EvalMojo /** * The forked Maven project against which expressions are evaluated. - * + * * @parameter default-value="${executedProject}" * @readonly */ @@ -113,7 +111,7 @@ public class EvalMojo /** * The merged user/global settings of the current build against which expressions are evaluated. - * + * * @parameter default-value="${settings}" * @readonly */ @@ -121,7 +119,7 @@ public class EvalMojo /** * The session context of the current build against which expressions are evaluated. - * + * * @parameter default-value="${session}" * @readonly */ @@ -129,7 +127,7 @@ public class EvalMojo /** * The local repository of the current build against which expressions are evaluated. - * + * * @parameter default-value="${localRepository}" * @readonly */ @@ -137,9 +135,9 @@ public class EvalMojo /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. - * @throws MojoFailureException If the output file has not been set. + * @throws MojoFailureException If the output file has not been set. */ public void execute() throws MojoExecutionException, MojoFailureException @@ -175,12 +173,11 @@ public class EvalMojo contexts.put( "session", session ); contexts.put( "localRepository", localRepository ); - for ( int i = 0; i < expressions.length; i++ ) + for ( String expression : expressions ) { - Map values = ExpressionUtil.evaluate( expressions[i], contexts ); - for ( Iterator it = values.keySet().iterator(); it.hasNext(); ) + Map values = ExpressionUtil.evaluate( expression, contexts ); + for ( Object key : values.keySet() ) { - Object key = it.next(); Object value = values.get( key ); PropertyUtil.store( expressionProperties, key.toString().replace( '/', '.' ), value ); } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java index be6a522..7c561b5 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Assists in evaluating expressions. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -55,11 +55,11 @@ class ExpressionUtil * objects are available. For instance, if <code>contexts</code> maps the token "project" to a Maven project * instance, the expression "project/build/resources/0/directory" specifies the first resource directory of the * project. - * + * * @param expression The expression to evaluate, may be <code>null</code>. - * @param context The object to start expression evaluation at, must not be <code>null</code>. + * @param context The object to start expression evaluation at, must not be <code>null</code>. * @return The values of the evaluation, indexed by expression, or an empty map if the segments could not be - * evaluated. + * evaluated. */ public static Map evaluate( String expression, Object context ) { @@ -76,12 +76,12 @@ class ExpressionUtil /** * Evaluates the given expression segments against the specified object. - * - * @param prefix The expression prefix that led to the current context, must not be <code>null</code>. + * + * @param prefix The expression prefix that led to the current context, must not be <code>null</code>. * @param segments The expression segments to evaluate, must not be <code>null</code>. - * @param context The object to evaluate the segments against, may be <code>null</code>. + * @param context The object to evaluate the segments against, may be <code>null</code>. * @return The values of the evaluation, indexed by expression, or an empty map if the segments could not be - * evaluated. + * evaluated. */ private static Map evaluate( String prefix, List segments, Object context ) { @@ -142,12 +142,12 @@ class ExpressionUtil } values = new LinkedHashMap(); - for ( Iterator it = targets.keySet().iterator(); it.hasNext(); ) + for ( Object key : targets.keySet() ) { - Object key = it.next(); Object target = targets.get( key ); - values.putAll( evaluate( concat( prefix, String.valueOf( key ) ), - segments.subList( 1, segments.size() ), target ) ); + values.putAll( + evaluate( concat( prefix, String.valueOf( key ) ), segments.subList( 1, segments.size() ), + target ) ); } } @@ -161,8 +161,8 @@ class ExpressionUtil /** * Gets the value of a (public) bean property from the specified object. - * - * @param context The object whose bean property should be retrieved, must not be <code>null</code>. + * + * @param context The object whose bean property should be retrieved, must not be <code>null</code>. * @param property The name of the bean property, must not be <code>null</code>. * @return The value of the bean property or <code>null</code> if the property does not exist. */ @@ -220,7 +220,7 @@ class ExpressionUtil method = type.getMethod( "get", OBJECT_PARAM ); } method.setAccessible( true ); - value = method.invoke( context, new Object[] { property } ); + value = method.invoke( context, new Object[]{ property } ); } catch ( NoSuchMethodException e3 ) { @@ -234,7 +234,7 @@ class ExpressionUtil { if ( "length".equals( property ) && type.isArray() ) { - value = new Integer( Array.getLength( context ) ); + value = Array.getLength( context ); } else { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java index 0d58f98..3929375 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/main/java/org/apache/maven/plugin/coreit/PropertyUtil.java @@ -35,7 +35,7 @@ import java.util.Properties; /** * Assists in serializing primitives and beans into properties for later inspection/verification. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -49,10 +49,10 @@ class PropertyUtil /** * Serializes the specified object into the given properties, using the provided key. The object may be a scalar * value like a string or some array/collection/map or a bean. - * + * * @param props The properties to serialize into, must not be <code>null</code>. - * @param key The key to use for serialization of the object data, must not be <code>null</code>. - * @param obj The object to serialize, may be <code>null</code>. + * @param key The key to use for serialization of the object data, must not be <code>null</code>. + * @param obj The object to serialize, may be <code>null</code>. */ public static void store( Properties props, String key, Object obj ) { @@ -62,12 +62,12 @@ class PropertyUtil /** * Serializes the specified object into the given properties, using the provided key. The object may be a scalar * value like a string or some array/collection/map or a bean. - * - * @param props The properties to serialize into, must not be <code>null</code>. - * @param key The key to use for serialization of the object data, must not be <code>null</code>. - * @param obj The object to serialize, may be <code>null</code>. + * + * @param props The properties to serialize into, must not be <code>null</code>. + * @param key The key to use for serialization of the object data, must not be <code>null</code>. + * @param obj The object to serialize, may be <code>null</code>. * @param visited The set/stack of already visited objects, used to detect back references in the object graph, must - * not be <code>null</code>. + * not be <code>null</code>. */ private static void store( Properties props, String key, Object obj, Collection visited ) { @@ -132,21 +132,19 @@ class PropertyUtil props.put( key + ".children", Integer.toString( children.length ) ); Map indices = new HashMap(); - for ( int i = 0; i < children.length; i++ ) + for ( Object child : children ) { - Object child = children[i]; - String name = (String) getName.invoke( child, NO_ARGS ); Integer index = (Integer) indices.get( name ); if ( index == null ) { - index = new Integer( 0 ); + index = 0; } store( props, key + ".children." + name + "." + index, child, visited ); - indices.put( name, new Integer( index.intValue() + 1 ) ); + indices.put( name, index + 1 ); } } catch ( Exception e ) @@ -158,13 +156,12 @@ class PropertyUtil { Class type = obj.getClass(); Method[] methods = type.getMethods(); - for ( int i = 0; i < methods.length; i++ ) + for ( Method method : methods ) { - Method method = methods[i]; if ( Modifier.isStatic( method.getModifiers() ) || method.getParameterTypes().length > 0 || !method.getName().matches( "(get|is)\\p{Lu}.*" ) || method.getName().endsWith( "AsMap" ) - || Class.class.isAssignableFrom( method.getReturnType() ) - || Object.class.equals( method.getReturnType() ) ) + || Class.class.isAssignableFrom( method.getReturnType() ) || Object.class.equals( + method.getReturnType() ) ) { continue; } @@ -186,7 +183,7 @@ class PropertyUtil /** * Derives the bean property name from the specified method for its getter. - * + * * @param methodName The method name of the property's getter, must not be <code>null</code>. * @return The property name, never <code>null</code>. */ @@ -206,9 +203,9 @@ class PropertyUtil /** * Writes the specified properties to the given file. - * + * * @param props The properties to write, must not be <code>null</code>. - * @param file The output file for the properties, must not be <code>null</code>. + * @param file The output file for the properties, must not be <code>null</code>. * @throws IOException If the properties could not be written to the file. */ public static void write( Properties props, File file ) http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java index 88e82f4..88f5bff 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java @@ -19,13 +19,13 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import junit.framework.TestCase; + import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; - /** * @author Benjamin Bentmann * @version $Id$ @@ -36,8 +36,8 @@ public class ExpressionUtilTest public void testEvaluate() { - Object array = new String[] { "one", "two", "three" }; - Object list = Arrays.asList( new String[] { "0", "-1", "-2" } ); + Object array = new String[]{ "one", "two", "three" }; + Object list = Arrays.asList( new String[]{ "0", "-1", "-2" } ); Object map = Collections.singletonMap( "some.key", "value" ); Object bean = new BeanTwo(); @@ -54,9 +54,9 @@ public class ExpressionUtilTest assertSame( bean, evaluate( "bean", contexts ) ); assertNull( evaluate( "no-root", contexts ) ); - assertEquals( new Integer( 3 ), evaluate( "array/length", contexts ) ); + assertEquals( 3, evaluate( "array/length", contexts ) ); assertEquals( "three", evaluate( "array/2", contexts ) ); - assertEquals( new Integer( 5 ), evaluate( "array/2/length", contexts ) ); + assertEquals( 5, evaluate( "array/2/length", contexts ) ); assertNull( evaluate( "array/invalid", contexts ) ); assertNull( evaluate( "array/-1", contexts ) ); assertNull( evaluate( "array/999", contexts ) ); @@ -65,7 +65,7 @@ public class ExpressionUtilTest assertEquals( "two", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/1" ) ); assertEquals( "three", ExpressionUtil.evaluate( "array/*", contexts ).get( "array/2" ) ); - assertEquals( new Integer( 3 ), evaluate( "list/size", contexts ) ); + assertEquals( 3, evaluate( "list/size", contexts ) ); assertEquals( "-2", evaluate( "list/2", contexts ) ); assertNull( evaluate( "list/invalid", contexts ) ); assertNull( evaluate( "list/-1", contexts ) ); @@ -75,7 +75,7 @@ public class ExpressionUtilTest assertEquals( "-1", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/1" ) ); assertEquals( "-2", ExpressionUtil.evaluate( "list/*", contexts ).get( "list/2" ) ); - assertEquals( new Integer( 1 ), evaluate( "map/size", contexts ) ); + assertEquals( 1, evaluate( "map/size", contexts ) ); assertEquals( "value", evaluate( "map/some.key", contexts ) ); assertNull( evaluate( "map/invalid", contexts ) ); @@ -104,7 +104,7 @@ public class ExpressionUtilTest assertEquals( bean2.field, ExpressionUtil.getProperty( bean2, "field" ) ); assertSame( bean2.bean, ExpressionUtil.getProperty( bean2, "bean" ) ); - assertEquals( new Integer( 0 ), ExpressionUtil.getProperty( new String[0], "length" ) ); + assertEquals( 0, ExpressionUtil.getProperty( new String[0], "length" ) ); } public static class BeanOne http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/PropertyUtilTest.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/PropertyUtilTest.java b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/PropertyUtilTest.java index d8ee3da..8b46cab 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/PropertyUtilTest.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-expression/src/test/java/org/apache/maven/plugin/coreit/PropertyUtilTest.java @@ -19,13 +19,13 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import junit.framework.TestCase; + import java.io.File; import java.util.Arrays; import java.util.Collections; import java.util.Properties; -import junit.framework.TestCase; - /** * @author Benjamin Bentmann * @version $Id$ @@ -40,7 +40,7 @@ public class PropertyUtilTest PropertyUtil.store( props, "null", null ); PropertyUtil.store( props, "string", "str" ); PropertyUtil.store( props, "boolean", Boolean.TRUE ); - PropertyUtil.store( props, "int", new Integer( 7 ) ); + PropertyUtil.store( props, "int", 7 ); PropertyUtil.store( props, "file", new File( "pom.xml" ) ); assertNull( props.get( "null" ) ); @@ -54,7 +54,7 @@ public class PropertyUtilTest public void testStoreArray() { Properties props = new Properties(); - PropertyUtil.store( props, "arr", new String[] { "one", "two" } ); + PropertyUtil.store( props, "arr", new String[]{ "one", "two" } ); assertEquals( "2", props.get( "arr" ) ); assertEquals( "one", props.get( "arr.0" ) ); @@ -65,7 +65,7 @@ public class PropertyUtilTest public void testStoreList() { Properties props = new Properties(); - PropertyUtil.store( props, "arr", Arrays.asList( new String[] { "one", "two" } ) ); + PropertyUtil.store( props, "arr", Arrays.asList( new String[]{ "one", "two" } ) ); assertEquals( "2", props.get( "arr" ) ); assertEquals( "one", props.get( "arr.0" ) ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java index 1683339..2b8a7a4 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java @@ -19,17 +19,15 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.util.Iterator; -import java.util.List; - import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.util.List; + /** * @goal fork-goal-aggregator * @aggregator true - * * @execute goal="touch" */ public class ForkGoalAggregatorMojo @@ -48,22 +46,23 @@ public class ForkGoalAggregatorMojo public void execute() throws MojoExecutionException { - for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) + for ( Object reactorProject : reactorProjects ) { - MavenProject executedProject = ( (MavenProject) it.next() ).getExecutionProject(); + MavenProject executedProject = ( (MavenProject) reactorProject ).getExecutionProject(); if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) ) { - throw new MojoExecutionException( "Unexpected result, final name of executed project " - + executedProject + " is " + executedProject.getBuild().getFinalName() + " (should be \'" - + TouchMojo.FINAL_NAME + "\')." ); + throw new MojoExecutionException( + "Unexpected result, final name of executed project " + executedProject + " is " + + executedProject.getBuild().getFinalName() + " (should be \'" + TouchMojo.FINAL_NAME + + "\')." ); } } if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) ) { - throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME - + "\')." ); + throw new MojoExecutionException( + "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME + "\')." ); } } } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java index 24fc3b3..038170d 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java @@ -19,17 +19,15 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.util.Iterator; -import java.util.List; - import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; +import java.util.List; + /** * @goal fork-lifecycle-aggregator * @aggregator true - * * @execute phase="generate-sources" lifecycle="foo" */ public class ForkLifecycleAggregatorMojo @@ -49,22 +47,23 @@ public class ForkLifecycleAggregatorMojo public void execute() throws MojoExecutionException { - for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) + for ( Object reactorProject : reactorProjects ) { - MavenProject executedProject = ( (MavenProject) it.next() ).getExecutionProject(); + MavenProject executedProject = ( (MavenProject) reactorProject ).getExecutionProject(); if ( !executedProject.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) ) { - throw new MojoExecutionException( "Unexpected result, final name of executed project " - + executedProject + " is " + executedProject.getBuild().getFinalName() + " (should be \'" - + TouchMojo.FINAL_NAME + "\')." ); + throw new MojoExecutionException( + "Unexpected result, final name of executed project " + executedProject + " is " + + executedProject.getBuild().getFinalName() + " (should be \'" + TouchMojo.FINAL_NAME + + "\')." ); } } if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) ) { - throw new MojoExecutionException( "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME - + "\')." ); + throw new MojoExecutionException( + "forked project was polluted. (should NOT be \'" + TouchMojo.FINAL_NAME + "\')." ); } } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java index dcf5f83..8cc7ee7 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-log-file/src/main/java/org/apache/maven/plugin/coreit/LogSeparatorMojo.java @@ -23,12 +23,11 @@ import org.apache.maven.plugin.MojoExecutionException; /** * Appends a separator line to the log file. - * - * @goal log-separator - * @phase initialize - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal log-separator + * @phase initialize */ public class LogSeparatorMojo extends AbstractLogMojo @@ -36,20 +35,20 @@ public class LogSeparatorMojo /** * The length of the separator line. - * + * * @parameter property="log.length" default-value="80" */ private int length; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() throws MojoExecutionException { - StringBuffer buffer = new StringBuffer( length ); + StringBuilder buffer = new StringBuilder( length ); for ( int i = 0; i < length; i++ ) { buffer.append( '-' ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-no-default-comp/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-no-default-comp/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-no-default-comp/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java index ad7016b..cd81f58 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-no-default-comp/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-no-default-comp/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java @@ -19,22 +19,21 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; - /** * Requires a component with a non-default role hint and dumps this hint to a properties file. - * - * @goal it - * @phase initialize - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal it + * @phase initialize */ public class ItMojo extends AbstractMojo @@ -42,21 +41,21 @@ public class ItMojo /** * The path to the output file. - * + * * @parameter property="touch.outputFile" default-value="target/comp.properties" */ private File outputFile; /** * NOTE: We don't specify a role hint here! - * + * * @component */ private Component component; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() @@ -72,15 +71,10 @@ public class ItMojo try { outputFile.getParentFile().mkdirs(); - FileOutputStream os = new FileOutputStream( outputFile ); - try + try ( FileOutputStream os = new FileOutputStream( outputFile ) ) { props.store( os, "MAVEN-CORE-IT-LOG" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/AppendMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/AppendMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/AppendMojo.java index 0302ec3..1417592 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/AppendMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/AppendMojo.java @@ -29,7 +29,7 @@ import java.io.OutputStreamWriter; /** * Appends a message to an UTF-8 encoded plain text file. - * + * * @author Benjamin Bentmann * @goal append */ @@ -58,16 +58,12 @@ public class AppendMojo getLog().info( "[MAVEN-CORE-IT-LOG] " + message ); - OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), "UTF-8" ); - try + try ( OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( outputFile, true ), + "UTF-8" ) ) { writer.write( message ); writer.write( "\n" ); } - finally - { - writer.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-parameter-implementation/src/main/java/org/apache/maven/plugin/coreit/ParameterImplementationMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-parameter-implementation/src/main/java/org/apache/maven/plugin/coreit/ParameterImplementationMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-parameter-implementation/src/main/java/org/apache/maven/plugin/coreit/ParameterImplementationMojo.java index 5118a3b..75fb15f 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-parameter-implementation/src/main/java/org/apache/maven/plugin/coreit/ParameterImplementationMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-parameter-implementation/src/main/java/org/apache/maven/plugin/coreit/ParameterImplementationMojo.java @@ -19,14 +19,14 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; - /** * Check that we correctly use the implementation parameter. * @@ -38,14 +38,14 @@ public class ParameterImplementationMojo /** * The path to the properties file for the parameter information. - * + * * @parameter */ private File outputFile; /** * A parameter whose type is an interface but with a default implementation class. - * + * * @parameter implementation="org.apache.maven.plugin.coreit.sub.AnImplementation" */ private AnInterface theParameter; @@ -69,15 +69,10 @@ public class ParameterImplementationMojo { outputFile.getParentFile().mkdirs(); - FileOutputStream os = new FileOutputStream( outputFile ); - try + try ( FileOutputStream os = new FileOutputStream( outputFile ) ) { props.store( os, "[MAVEN-CORE-IT-LOG]" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-project-interpolation/src/main/java/org/apache/maven/plugin/coreit/PropertyInterpolationVerifierMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-project-interpolation/src/main/java/org/apache/maven/plugin/coreit/PropertyInterpolationVerifierMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-project-interpolation/src/main/java/org/apache/maven/plugin/coreit/PropertyInterpolationVerifierMojo.java index 3e4a2bd..fb11cf1 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-project-interpolation/src/main/java/org/apache/maven/plugin/coreit/PropertyInterpolationVerifierMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-project-interpolation/src/main/java/org/apache/maven/plugin/coreit/PropertyInterpolationVerifierMojo.java @@ -19,15 +19,15 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import java.util.Enumeration; -import java.util.Properties; - import org.apache.maven.model.Model; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; +import java.util.Enumeration; +import java.util.Properties; + /** * @goal verify-property * @phase validate @@ -65,7 +65,7 @@ public class PropertyInterpolationVerifierMojo throw new MojoExecutionException( "Properties do not match: Name = " + name + ", Value = " + value ); } - if ( value.indexOf( "${" ) > -1 ) + if ( value.contains( "${" ) ) { throw new MojoExecutionException( "Unresolved value: Name = " + name + ", Value = " + value ); } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/AbstractPomMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/AbstractPomMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/AbstractPomMojo.java index 918cc4d..ec5cf66 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/AbstractPomMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/AbstractPomMojo.java @@ -38,7 +38,7 @@ public abstract class AbstractPomMojo /** * The project builder. - * + * * @component */ protected MavenProjectBuilder builder; @@ -69,15 +69,10 @@ public abstract class AbstractPomMojo { file.getParentFile().mkdirs(); - FileOutputStream os = new FileOutputStream( file ); - try + try ( FileOutputStream os = new FileOutputStream( file ) ) { props.store( os, "[MAVEN-CORE-IT-LOG]" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java index 1108325..b7c7770 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildLocalPomMojo.java @@ -28,9 +28,9 @@ import java.util.Properties; /** * Builds the local POMs. - * - * @goal local-pom + * * @author Benjamin Bentmann + * @goal local-pom */ public class BuildLocalPomMojo extends AbstractPomMojo @@ -38,14 +38,14 @@ public class BuildLocalPomMojo /** * The properties file to dump the POM info to. - * + * * @parameter default-value="target/pom.properties" */ private File propertiesFile; /** * The local repository. - * + * * @parameter default-value="${localRepository}" * @readonly * @required @@ -54,14 +54,14 @@ public class BuildLocalPomMojo /** * The POM files to build. - * + * * @parameter */ private File[] files; /** * Runs this mojo. - * + * * @throws MojoFailureException If the artifact file has not been set. */ public void execute() @@ -73,10 +73,8 @@ public class BuildLocalPomMojo if ( files != null ) { - for ( int i = 0; i < files.length; i++ ) + for ( File file : files ) { - File file = files[i]; - getLog().info( "[MAVEN-CORE-IT-LOG] Building " + file ); try http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildRemotePomMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildRemotePomMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildRemotePomMojo.java index 5ac3d5d..ca335f5 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildRemotePomMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-project/src/main/java/org/apache/maven/plugin/coreit/BuildRemotePomMojo.java @@ -32,11 +32,10 @@ import java.util.Properties; /** * Builds the remote POMs of user-specified artifacts. This mimics in part the Maven Remote Resources Plugin. - * - * @goal remote-pom - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal remote-pom */ public class BuildRemotePomMojo extends AbstractPomMojo @@ -44,14 +43,14 @@ public class BuildRemotePomMojo /** * The properties file to dump the POM info to. - * + * * @parameter default-value="target/pom.properties" */ private File propertiesFile; /** * The local repository. - * + * * @parameter default-value="${localRepository}" * @readonly * @required @@ -60,7 +59,7 @@ public class BuildRemotePomMojo /** * The remote repositories of the current Maven project. - * + * * @parameter default-value="${project.remoteArtifactRepositories}" * @readonly * @required @@ -69,21 +68,21 @@ public class BuildRemotePomMojo /** * The artifact factory. - * + * * @component */ private ArtifactFactory factory; /** * The dependencies to resolve. - * + * * @parameter */ private Dependency[] dependencies; /** * Runs this mojo. - * + * * @throws MojoFailureException If the artifact file has not been set. */ public void execute() @@ -95,10 +94,8 @@ public class BuildRemotePomMojo if ( dependencies != null ) { - for ( int i = 0; i < dependencies.length; i++ ) + for ( Dependency dependency : dependencies ) { - Dependency dependency = dependencies[i]; - Artifact artifact = factory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getType(), http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-singleton-component/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-singleton-component/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-singleton-component/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java index 5d535f9..a26a23a 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-singleton-component/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-singleton-component/src/main/java/org/apache/maven/plugin/coreit/ItMojo.java @@ -19,6 +19,9 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -26,17 +29,13 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; - /** * Requires a singleton component in various ways and dumps the ids to a properties file. - * - * @goal it - * @phase initialize - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal it + * @phase initialize */ public class ItMojo extends AbstractMojo @@ -44,42 +43,42 @@ public class ItMojo /** * The path to the output file. - * + * * @parameter property="touch.outputFile" default-value="target/comp.properties" */ private File outputFile; /** * Component lookup without role hint. - * + * * @component */ private Component componentWithoutRoleHint; /** * Component lookup with explicit role hint. - * + * * @component roleHint="default" */ private Component componentWithRoleHint; /** * Component lookup via active map. - * + * * @component role="org.apache.maven.plugin.coreit.Component" */ private Map componentMap; /** * Component lookup via active list. - * + * * @component role="org.apache.maven.plugin.coreit.Component" */ private List componentList; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() @@ -104,15 +103,10 @@ public class ItMojo try { outputFile.getParentFile().mkdirs(); - FileOutputStream os = new FileOutputStream( outputFile ); - try + try ( FileOutputStream os = new FileOutputStream( outputFile ) ) { props.store( os, "MAVEN-CORE-IT-LOG" ); } - finally - { - os.close(); - } } catch ( IOException e ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/GenerateMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/GenerateMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/GenerateMojo.java index 8126288..a733de1 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/GenerateMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-site/src/main/java/org/apache/maven/plugin/coreit/GenerateMojo.java @@ -34,13 +34,12 @@ import java.util.Locale; /** * Generates the available/configured reports. - * + * + * @author Benjamin Bentmann + * @version $Id$ * @goal generate * @phase site * @requiresReports true - * - * @author Benjamin Bentmann - * @version $Id$ */ public class GenerateMojo extends AbstractMojo @@ -48,28 +47,28 @@ public class GenerateMojo /** * The path to the output directory of the site. - * + * * @parameter default-value="${project.reporting.outputDirectory}" */ private File outputDirectory; /** * The language for the reports. - * + * * @parameter default-value="en" */ private String language = "en"; /** * A flag whether to ignore errors from reports and continue the generation. - * + * * @parameter default-value="false" */ private boolean ignoreErrors; /** * The reports configured for the current build. - * + * * @parameter default-value="${reports}" * @required * @readonly @@ -78,7 +77,7 @@ public class GenerateMojo /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() @@ -99,11 +98,11 @@ public class GenerateMojo } }; - Sink sink = (Sink) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] { Sink.class }, handler ); + Sink sink = (Sink) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[]{ Sink.class }, handler ); - for ( int i = 0; i < reports.size(); i++ ) + for ( Object report1 : reports ) { - MavenReport report = (MavenReport) reports.get( i ); + MavenReport report = (MavenReport) report1; if ( report.canGenerateReport() ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java index 3741ce3..7fa4452 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java @@ -19,6 +19,12 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.toolchain.ToolchainManagerPrivate; +import org.apache.maven.toolchain.ToolchainPrivate; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -29,12 +35,6 @@ import java.util.Arrays; import java.util.Iterator; import java.util.Properties; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.toolchain.ToolchainManagerPrivate; -import org.apache.maven.toolchain.ToolchainPrivate; - /** * @goal toolchain * @phase validate @@ -50,7 +50,7 @@ public class CoreItMojo /** * The current Maven session holding the selected toolchain. - * + * * @parameter default-value="${session}" * @required * @readonly @@ -59,28 +59,28 @@ public class CoreItMojo /** * The path to the output file for the properties. - * + * * @parameter property="toolchain.outputFile" default-value="${project.build.directory}/toolchains.properties" */ private File outputFile; /** * The type identifier of the toolchain, e.g. "jdk". - * + * * @parameter property="toolchain.type" */ private String type; /** * The name of the tool, e.g. "javac". - * + * * @parameter property="toolchain.tool" */ private String tool; /** * The zero-based index of the toolchain to select and store in the build context. - * + * * @parameter property="toolchain.selected" */ private int selected; @@ -101,8 +101,8 @@ public class CoreItMojo } else { - getLog().warn( "[MAVEN-CORE-IT-LOG] Toolchain #" + selected + " can't be selected, found only " - + tcs.length ); + getLog().warn( + "[MAVEN-CORE-IT-LOG] Toolchain #" + selected + " can't be selected, found only " + tcs.length ); } } @@ -157,28 +157,20 @@ public class CoreItMojo try { // try 2.x style API - Method oldMethod = managerClass.getMethod( "getToolchainsForType", new Class[] { String.class } ); + Method oldMethod = managerClass.getMethod( "getToolchainsForType", new Class[]{ String.class } ); - return (ToolchainPrivate[]) oldMethod.invoke( toolchainManager, new Object[] { type } ); + return (ToolchainPrivate[]) oldMethod.invoke( toolchainManager, new Object[]{ type } ); } catch ( NoSuchMethodException e ) { // try 3.x style API Method newMethod = - managerClass.getMethod( "getToolchainsForType", new Class[] { String.class, MavenSession.class } ); + managerClass.getMethod( "getToolchainsForType", new Class[]{ String.class, MavenSession.class } ); - return (ToolchainPrivate[]) newMethod.invoke( toolchainManager, new Object[] { type, session } ); + return (ToolchainPrivate[]) newMethod.invoke( toolchainManager, new Object[]{ type, session } ); } } - catch ( NoSuchMethodException e ) - { - throw new MojoExecutionException( "Incompatible toolchain API", e ); - } - catch ( IllegalAccessException e ) - { - throw new MojoExecutionException( "Incompatible toolchain API", e ); - } - catch ( InvocationTargetException e ) + catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e ) { throw new MojoExecutionException( "Incompatible toolchain API", e ); }