http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4415InheritedPluginOrderTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4415InheritedPluginOrderTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4415InheritedPluginOrderTest.java index 15914aa..fd686de 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4415InheritedPluginOrderTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4415InheritedPluginOrderTest.java @@ -19,7 +19,6 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; @@ -29,7 +28,7 @@ import java.util.Properties; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4415">MNG-4415</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4415InheritedPluginOrderTest @@ -62,7 +61,7 @@ public class MavenITmng4415InheritedPluginOrderTest Properties props = verifier.loadProperties( "target/it.properties" ); assertNotNull( props.getProperty( "project.build.plugins" ) ); - List<String> expected = new ArrayList<String>(); + List<String> expected = new ArrayList<>(); expected.add( "maven-it-plugin-error" ); expected.add( "maven-it-plugin-configuration" ); expected.add( "maven-it-plugin-dependency-resolution" ); @@ -72,7 +71,7 @@ public class MavenITmng4415InheritedPluginOrderTest expected.add( "maven-it-plugin-fork" ); expected.add( "maven-it-plugin-touch" ); - List<String> actual = new ArrayList<String>(); + List<String> actual = new ArrayList<>(); int count = Integer.parseInt( props.getProperty( "project.build.plugins" ) ); for ( int i = 0; i < count; i++ )
http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4416PluginOrderAfterProfileInjectionTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4416PluginOrderAfterProfileInjectionTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4416PluginOrderAfterProfileInjectionTest.java index e0d23d4..d8e90b1 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4416PluginOrderAfterProfileInjectionTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4416PluginOrderAfterProfileInjectionTest.java @@ -19,7 +19,6 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; @@ -29,7 +28,7 @@ import java.util.Properties; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4416">MNG-4416</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4416PluginOrderAfterProfileInjectionTest @@ -62,7 +61,7 @@ public class MavenITmng4416PluginOrderAfterProfileInjectionTest Properties props = verifier.loadProperties( "target/it.properties" ); assertNotNull( props.getProperty( "project.build.plugins" ) ); - List<String> expected = new ArrayList<String>(); + List<String> expected = new ArrayList<>(); expected.add( "maven-it-plugin-error" ); expected.add( "maven-it-plugin-configuration" ); expected.add( "maven-it-plugin-dependency-resolution" ); @@ -72,7 +71,7 @@ public class MavenITmng4416PluginOrderAfterProfileInjectionTest expected.add( "maven-it-plugin-fork" ); expected.add( "maven-it-plugin-touch" ); - List<String> actual = new ArrayList<String>(); + List<String> actual = new ArrayList<>(); int count = Integer.parseInt( props.getProperty( "project.build.plugins" ) ); for ( int i = 0; i < count; i++ ) http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4421DeprecatedPomInterpolationExpressionsTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4421DeprecatedPomInterpolationExpressionsTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4421DeprecatedPomInterpolationExpressionsTest.java index 159ed13..c480560 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4421DeprecatedPomInterpolationExpressionsTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4421DeprecatedPomInterpolationExpressionsTest.java @@ -19,7 +19,6 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; @@ -28,7 +27,7 @@ import java.util.Properties; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4421">MNG-4421</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4421DeprecatedPomInterpolationExpressionsTest @@ -60,19 +59,19 @@ public class MavenITmng4421DeprecatedPomInterpolationExpressionsTest assertEquals( "0.1", props.getProperty( "project.properties.property2" ) ); List<String> lines = verifier.loadLines( "log.txt", null ); - + boolean warnedPomPrefix = false; boolean warnedEmptyPrefix = false; - + for ( String line : lines ) { if ( line.startsWith( "[WARN" ) ) { - if ( line.indexOf( "${pom.version}" ) >= 0 ) + if ( line.contains( "${pom.version}" ) ) { warnedPomPrefix = true; } - if ( line.indexOf( "${version}" ) >= 0 ) + if ( line.contains( "${version}" ) ) { warnedEmptyPrefix = true; } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java index b8b08a9..616dcbb 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java @@ -19,17 +19,6 @@ package org.apache.maven.it; * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.it.utils.DeployedResource; import org.codehaus.plexus.util.StringUtils; @@ -44,9 +33,18 @@ import org.mortbay.jetty.security.ConstraintMapping; import org.mortbay.jetty.security.HashUserRealm; import org.mortbay.jetty.security.SecurityHandler; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4470">MNG-4470</a>. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -60,7 +58,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest private volatile boolean deployed; - List<DeployedResource> deployedResources = new ArrayList<DeployedResource>(); + List<DeployedResource> deployedResources = new ArrayList<>(); public MavenITmng4470AuthenticatedDeploymentToProxyTest() { @@ -138,7 +136,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest Constraint constraint = new Constraint(); constraint.setName( Constraint.__BASIC_AUTH ); - constraint.setRoles( new String[] { "deployer" } ); + constraint.setRoles( new String[]{ "deployer" } ); constraint.setAuthenticate( true ); ConstraintMapping constraintMapping = new ConstraintMapping(); @@ -151,7 +149,7 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest SecurityHandler securityHandler = new SecurityHandler(); securityHandler.setUserRealm( userRealm ); - securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } ); + securityHandler.setConstraintMappings( new ConstraintMapping[]{ constraintMapping } ); HandlerList handlerList = new HandlerList(); handlerList.addHandler( proxyHandler ); @@ -201,14 +199,14 @@ public class MavenITmng4470AuthenticatedDeploymentToProxyTest throws Exception { - deployedResources = new ArrayList<DeployedResource>(); + deployedResources = new ArrayList<>(); File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4470/" + project ); Verifier verifier = newVerifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); - verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", - Collections.singletonMap( "@port@", Integer.toString( port ) ) ); + verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", + Collections.singletonMap( "@port@", Integer.toString( port ) ) ); verifier.addCliOption( "--settings" ); verifier.addCliOption( "settings.xml" ); verifier.executeGoal( "validate" ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4555MetaversionResolutionOfflineTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4555MetaversionResolutionOfflineTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4555MetaversionResolutionOfflineTest.java index dac455d..1b1c853 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4555MetaversionResolutionOfflineTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4555MetaversionResolutionOfflineTest.java @@ -19,26 +19,23 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; +import org.mortbay.jetty.Handler; +import org.mortbay.jetty.Request; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.handler.AbstractHandler; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Properties; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.mortbay.jetty.Handler; -import org.mortbay.jetty.Request; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.handler.AbstractHandler; - /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4555">MNG-4555</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4555MetaversionResolutionOfflineTest @@ -58,7 +55,7 @@ public class MavenITmng4555MetaversionResolutionOfflineTest { File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4555" ); - final List<String> uris = new ArrayList<String>(); + final List<String> uris = new ArrayList<>(); Handler repoHandler = new AbstractHandler() { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4666CoreRealmImportTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4666CoreRealmImportTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4666CoreRealmImportTest.java index c22d400..22dada0 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4666CoreRealmImportTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4666CoreRealmImportTest.java @@ -19,18 +19,16 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Properties; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4666">MNG-4666</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4666CoreRealmImportTest @@ -97,10 +95,10 @@ public class MavenITmng4666CoreRealmImportTest private List<String> getTypes( Properties props ) { - List<String> types = new ArrayList<String>(); - for ( Iterator<?> it = props.keySet().iterator(); it.hasNext(); ) + List<String> types = new ArrayList<>(); + for ( Object o : props.keySet() ) { - String key = it.next().toString(); + String key = o.toString(); if ( key.startsWith( "core." ) ) { String type = key.substring( 5 ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4696MavenProjectDependencyArtifactsTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4696MavenProjectDependencyArtifactsTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4696MavenProjectDependencyArtifactsTest.java index bab45b7..8b47524 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4696MavenProjectDependencyArtifactsTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4696MavenProjectDependencyArtifactsTest.java @@ -19,7 +19,6 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; @@ -28,7 +27,7 @@ import java.util.Properties; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4696">MNG-4696</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4696MavenProjectDependencyArtifactsTest @@ -63,7 +62,7 @@ public class MavenITmng4696MavenProjectDependencyArtifactsTest Properties props = verifier.loadProperties( "target/artifact.properties" ); assertEquals( "3", props.getProperty( "project.dependencyArtifacts.size" ) ); - HashSet<String> ids = new HashSet<String>(); + HashSet<String> ids = new HashSet<>(); ids.add( props.getProperty( "project.dependencyArtifacts.0.artifactId" ) ); ids.add( props.getProperty( "project.dependencyArtifacts.1.artifactId" ) ); ids.add( props.getProperty( "project.dependencyArtifacts.2.artifactId" ) ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4745PluginVersionUpdateTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4745PluginVersionUpdateTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4745PluginVersionUpdateTest.java index 59ab072..e1c0c10 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4745PluginVersionUpdateTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4745PluginVersionUpdateTest.java @@ -19,15 +19,15 @@ package org.apache.maven.it; * under the License. */ -import java.io.File; -import java.util.Properties; - import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.shared.utils.io.FileUtils; +import java.io.File; +import java.util.Properties; + /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4745">MNG-4745</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4745PluginVersionUpdateTest @@ -142,7 +142,7 @@ public class MavenITmng4745PluginVersionUpdateTest private static void writeMetadata( File testdir, String version, String timestamp ) throws Exception { - StringBuffer content = new StringBuffer( 1024 ); + StringBuilder content = new StringBuilder( 1024 ); content.append( "<?xml version=\"1.0\"?>\n" ); content.append( "<metadata>\n" ); content.append( " <groupId>org.apache.maven.its.mng4745</groupId>\n" ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java index 3bb3579..ff5183d 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4814ReResolutionOfDependenciesDuringReactorTest.java @@ -19,7 +19,6 @@ package org.apache.maven.it; * under the License. */ -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; @@ -28,7 +27,7 @@ import java.util.List; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4814">MNG-4814</a>. - * + * * @author Benjamin Bentmann */ public class MavenITmng4814ReResolutionOfDependenciesDuringReactorTest @@ -57,7 +56,7 @@ public class MavenITmng4814ReResolutionOfDependenciesDuringReactorTest verifier.addCliOption( "-s" ); verifier.addCliOption( "settings.xml" ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() ); - List<String> goals = new ArrayList<String>(); + List<String> goals = new ArrayList<>(); goals.add( "org.apache.maven.its.plugins:maven-it-plugin-dependency-resolution:2.1-SNAPSHOT:aggregate-test" ); goals.add( "validate" ); verifier.executeGoals( goals ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5214DontMapWsdlToJar.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5214DontMapWsdlToJar.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5214DontMapWsdlToJar.java index 541625b..19708a6 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5214DontMapWsdlToJar.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5214DontMapWsdlToJar.java @@ -1,11 +1,10 @@ package org.apache.maven.it; +import org.apache.maven.it.util.ResourceExtractor; + import java.io.File; -import java.util.Iterator; import java.util.List; -import org.apache.maven.it.util.ResourceExtractor; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -26,22 +25,23 @@ import org.apache.maven.it.util.ResourceExtractor; */ -public class MavenITmng5214DontMapWsdlToJar extends AbstractMavenIntegrationTestCase +public class MavenITmng5214DontMapWsdlToJar + extends AbstractMavenIntegrationTestCase { public MavenITmng5214DontMapWsdlToJar() { super( "[3.1,)" ); } - + /** - * Test that the code that allows test-jar and ejb-client dependencies to resolve to the + * Test that the code that allows test-jar and ejb-client dependencies to resolve to the * target/classes or target/test-class is *not* applies to other types, e.g. wsdl. */ public void testitTestPhase() throws Exception { File setupDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5214/dependency" ); - + Verifier setupVerifier = newVerifier( setupDir.getAbsolutePath() ); setupVerifier.setAutoclean( false ); setupVerifier.setMavenDebug( true ); @@ -52,7 +52,7 @@ public class MavenITmng5214DontMapWsdlToJar extends AbstractMavenIntegrationTest setupVerifier.executeGoal( "generate-resources" ); File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5214" ); - + Verifier verifier = newVerifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); verifier.deleteDirectory( "consumer/target" ); @@ -61,12 +61,11 @@ public class MavenITmng5214DontMapWsdlToJar extends AbstractMavenIntegrationTest verifier.executeGoal( "test" ); verifier.verifyErrorFreeLog(); List<String> lines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false ); - Iterator<String> lineIt = lines.iterator(); - // RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT $ /tmp/it.repo/org/apache/maven/its/mng5214/dependency/1.0-SNAPSHOT/dependency-1.0-SNAPSHOT.wsdl - while ( lineIt.hasNext() ) + // RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT $ /tmp/it + // .repo/org/apache/maven/its/mng5214/dependency/1.0-SNAPSHOT/dependency-1.0-SNAPSHOT.wsdl + for ( String line : lines ) { - String line = (String) lineIt.next(); - if ( line.contains( "RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT" ) ) + if ( line.contains( "RESOLVE-ONE-DEPENDENCY org.apache.maven.its.mng5214:dependency:wsdl:1.0-SNAPSHOT" ) ) { assertFalse( line.contains( "classes-main" ) ); assertTrue( line.endsWith( ".wsdl" ) ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5224InjectedSettings.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5224InjectedSettings.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5224InjectedSettings.java index 04990b3..306a6db 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5224InjectedSettings.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5224InjectedSettings.java @@ -99,7 +99,7 @@ public class MavenITmng5224InjectedSettings </profiles> **/ - List<String> profileIds = new ArrayList<String>( 4 ); + List<String> profileIds = new ArrayList<>( 4 ); for ( Xpp3Dom node : profileNodes ) { @@ -149,7 +149,7 @@ public class MavenITmng5224InjectedSettings assertEquals( 1, activeProfilesNode.getChildCount() ); } - List<String> activeProfiles = new ArrayList<String>( 2 ); + List<String> activeProfiles = new ArrayList<>( 2 ); for ( Xpp3Dom node : activeProfilesNode.getChildren() ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5452MavenBuildTimestampUTCTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5452MavenBuildTimestampUTCTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5452MavenBuildTimestampUTCTest.java index 77d58c2..1107994 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5452MavenBuildTimestampUTCTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5452MavenBuildTimestampUTCTest.java @@ -19,12 +19,11 @@ package org.apache.maven.it; * under the License. */ +import org.apache.maven.it.util.ResourceExtractor; + import java.io.File; -import java.util.List; import java.util.Properties; -import org.apache.maven.it.util.ResourceExtractor; - /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5452">MNG-5452</a> * Make sure that the maven.build.timestamp is in UTC. http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java index 4cf3c10..a9ae769 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java @@ -19,13 +19,12 @@ package org.apache.maven.it; * under the License. */ +import org.apache.maven.it.util.ResourceExtractor; + import java.io.File; import java.util.List; -import java.util.Properties; import java.util.regex.Pattern; -import org.apache.maven.it.util.ResourceExtractor; - /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5608">MNG-5608</a>: * Profile activation warning test when file specification contains <code>${project.basedir}</code> @@ -63,12 +62,13 @@ public class MavenITmng5608ProfileActivationWarningTest private void assertFileExists( File dir, String filename ) { File file = new File( dir, filename ); - assertTrue( "expected file: " + file , file.exists() ); + assertTrue( "expected file: " + file, file.exists() ); } private String findWarning( List<String> logLines, String profileId ) { - Pattern pattern = Pattern.compile( "(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" ); + Pattern pattern = Pattern.compile( + "(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" ); for ( String logLine : logLines ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5639ImportScopePomResolutionTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5639ImportScopePomResolutionTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5639ImportScopePomResolutionTest.java index b9603a8..4bcba92 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5639ImportScopePomResolutionTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5639ImportScopePomResolutionTest.java @@ -22,9 +22,6 @@ package org.apache.maven.it; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; -import java.util.List; -import java.util.Properties; -import java.util.regex.Pattern; /** * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5639">MNG-5639</a>: @@ -60,5 +57,4 @@ public class MavenITmng5639ImportScopePomResolutionTest } - } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-suite/src/test/java/org/apache/maven/it/TunnelingProxyServer.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TunnelingProxyServer.java b/core-it-suite/src/test/java/org/apache/maven/it/TunnelingProxyServer.java index 4e084b3..d860b8e 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/TunnelingProxyServer.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/TunnelingProxyServer.java @@ -30,7 +30,7 @@ import java.util.regex.Pattern; /** * A simple HTTP proxy that only understands the CONNECT method to check HTTPS tunneling. - * + * * @author Benjamin Bentmann */ public class TunnelingProxyServer @@ -166,7 +166,7 @@ public class TunnelingProxyServer private String readLine( PushbackInputStream is ) throws IOException { - StringBuffer buffer = new StringBuffer( 1024 ); + StringBuilder buffer = new StringBuilder( 1024 ); while ( true ) { @@ -217,7 +217,7 @@ public class TunnelingProxyServer { try { - for ( byte[] buffer = new byte[1024 * 8];; ) + for ( byte[] buffer = new byte[1024 * 8]; ; ) { int n = is.read( buffer ); if ( n < 0 ) http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java b/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java index 6c41bf7..9284011 100644 --- a/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java +++ b/core-it-support/core-it-component/src/main/java/org/apache/maven/coreit/component/DefaultStatefulSingleton.java @@ -25,7 +25,7 @@ import java.io.IOException; import java.util.Properties; /** - * + * */ public class DefaultStatefulSingleton implements StatefulSingleton @@ -48,15 +48,10 @@ public class DefaultStatefulSingleton { propertiesFile.getParentFile().mkdirs(); - FileOutputStream os = new FileOutputStream( propertiesFile ); - try + try ( FileOutputStream os = new FileOutputStream( propertiesFile ) ) { properties.store( os, "MAVEN-CORE-IT" ); } - finally - { - os.close(); - } } } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java index c45a708..3ce6076 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/CheckThreadSafetyMojo.java @@ -26,7 +26,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -34,11 +33,10 @@ import java.util.Vector; /** * Checks the thread-safe retrieval of components from active component collections. - * + * + * @author Benjamin Bentmann * @goal check-thread-safety * @phase validate - * - * @author Benjamin Bentmann */ public class CheckThreadSafetyMojo extends AbstractMojo @@ -46,7 +44,7 @@ public class CheckThreadSafetyMojo /** * Project base directory used for manual path alignment. - * + * * @parameter default-value="${basedir}" * @readonly */ @@ -54,28 +52,28 @@ public class CheckThreadSafetyMojo /** * The available components, as a map. - * + * * @component role="org.apache.maven.plugin.coreit.Component" */ private Map componentMap; /** * The available components, as a list. - * + * * @component role="org.apache.maven.plugin.coreit.Component" */ private List componentList; /** * The path to the properties file to create. - * + * * @parameter property="collections.outputFile" */ private File outputFile; /** * Runs this mojo. - * + * * @throws MojoFailureException If the output file could not be created. */ public void execute() @@ -114,13 +112,13 @@ public class CheckThreadSafetyMojo { try { - for ( Iterator it = map.values().iterator(); it.hasNext(); ) + for ( Object o : map.values() ) { - it.next().toString(); + o.toString(); } - for ( Iterator it = list.iterator(); it.hasNext(); ) + for ( Object aList : list ) { - it.next().toString(); + aList.toString(); } } catch ( Exception e ) @@ -135,15 +133,15 @@ public class CheckThreadSafetyMojo } go.add( null ); - for ( int i = 0; i < threads.length; i++ ) + for ( Thread thread : threads ) { try { - threads[i].join(); + thread.join(); } catch ( InterruptedException e ) { - getLog().warn( "[MAVEN-CORE-IT-LOG] Interrupted while joining " + threads[i] ); + getLog().warn( "[MAVEN-CORE-IT-LOG] Interrupted while joining " + thread ); } } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java index 7aa7fb3..6750a82 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-active-collection/src/main/java/org/apache/maven/plugin/coreit/DumpRepoLayoutsMojo.java @@ -27,18 +27,16 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; /** * Dumps the role hints of the available repository layouts to a properties file. - * + * + * @author Benjamin Bentmann * @goal dump-repo-layouts * @phase validate - * - * @author Benjamin Bentmann */ public class DumpRepoLayoutsMojo extends AbstractMojo @@ -46,7 +44,7 @@ public class DumpRepoLayoutsMojo /** * Project base directory used for manual path alignment. - * + * * @parameter default-value="${basedir}" * @readonly */ @@ -54,28 +52,28 @@ public class DumpRepoLayoutsMojo /** * The available repository layouts, as a map. - * + * * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" */ private Map repositoryLayouts; /** * The available repository layouts, as a list. - * + * * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout" */ private List repoLayouts; /** * The path to the properties file used to dump the repository layouts. - * + * * @parameter property="collections.layoutsFile" */ private File layoutsFile; /** * Runs this mojo. - * + * * @throws MojoFailureException If the output file could not be created. */ public void execute() @@ -87,9 +85,9 @@ public class DumpRepoLayoutsMojo layoutProperties.setProperty( "layouts", Integer.toString( repositoryLayouts.size() ) ); - for ( Iterator it = repositoryLayouts.keySet().iterator(); it.hasNext(); ) + for ( Object o : repositoryLayouts.keySet() ) { - String roleHint = (String) it.next(); + String roleHint = (String) o; Object repoLayout = repositoryLayouts.get( roleHint ); if ( repoLayout != null ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java index 4402c0c..a82a639 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CollectMojo.java @@ -36,11 +36,10 @@ import java.util.Set; /** * Collects user-specified artifacts. This mimics in part the Maven Assembly Plugin. - * - * @goal collect - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal collect */ public class CollectMojo extends AbstractMojo @@ -48,7 +47,7 @@ public class CollectMojo /** * The local repository. - * + * * @parameter default-value="${localRepository}" * @readonly * @required @@ -57,7 +56,7 @@ public class CollectMojo /** * The remote repositories of the current Maven project. - * + * * @parameter default-value="${project.remoteArtifactRepositories}" * @readonly * @required @@ -66,35 +65,35 @@ public class CollectMojo /** * The artifact collector. - * + * * @component */ private ArtifactCollector collector; /** * The artifact factory. - * + * * @component */ private ArtifactFactory factory; /** * The metadata source. - * + * * @component */ private ArtifactMetadataSource metadataSource; /** * The dependencies to resolve. - * + * * @parameter */ private Dependency[] dependencies; /** * Runs this mojo. - * + * * @throws MojoFailureException If the artifact file has not been set. */ public void execute() @@ -110,10 +109,8 @@ public class CollectMojo 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-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java index b39c017..a519741 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/CustomRepositoryLayout.java @@ -36,7 +36,7 @@ public class CustomRepositoryLayout { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); - StringBuffer path = new StringBuffer(); + StringBuilder path = new StringBuilder(); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java index b91c3bc..4f4e376 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/DeployMojo.java @@ -24,16 +24,13 @@ import org.apache.maven.artifact.deployer.ArtifactDeployer; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.MojoExecutionException; -import java.util.Iterator; - /** * Deploys the project artifacts to the distribution repository. This is the essence of the Maven Deploy Plugin. - * - * @goal deploy - * @phase deploy - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal deploy + * @phase deploy */ public class DeployMojo extends AbstractRepoMojo @@ -41,7 +38,7 @@ public class DeployMojo /** * The distribution repository. - * + * * @parameter default-value="${project.distributionManagementArtifactRepository}" * @readonly * @required @@ -50,14 +47,14 @@ public class DeployMojo /** * The artifact deployer. - * + * * @component */ private ArtifactDeployer deployer; /** * Runs this mojo. - * + * * @throws MojoExecutionException If any artifact could not be installed. */ public void execute() @@ -78,9 +75,9 @@ public class DeployMojo if ( attachedArtifacts != null ) { - for ( Iterator it = attachedArtifacts.iterator(); it.hasNext(); ) + for ( Object attachedArtifact1 : attachedArtifacts ) { - Artifact attachedArtifact = (Artifact) it.next(); + Artifact attachedArtifact = (Artifact) attachedArtifact1; deployer.deploy( attachedArtifact.getFile(), attachedArtifact, deploymentRepository, localRepository ); } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java index 5865be4..1f07910 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallArtifactsMojo.java @@ -32,7 +32,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import java.io.File; -import java.util.Iterator; import java.util.List; /** @@ -87,9 +86,9 @@ public class InstallArtifactsMojo ArtifactRepository artifactRepository = artifactRepositoryFactory.createDeploymentArtifactRepository( "appassembler", "file://" + assembleDirectory.getAbsolutePath() + "/" + repositoryName, artifactRepositoryLayout, false ); - for ( Iterator it = artifacts.iterator(); it.hasNext(); ) + for ( Object artifact1 : artifacts ) { - Artifact artifact = (Artifact) it.next(); + Artifact artifact = (Artifact) artifact1; installArtifact( artifactRepository, artifact ); } @@ -115,7 +114,7 @@ public class InstallArtifactsMojo } /** - * + * */ public static class FlatRepositoryLayout implements ArtifactRepositoryLayout @@ -128,7 +127,7 @@ public class InstallArtifactsMojo { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); - StringBuffer path = new StringBuffer(); + StringBuilder path = new StringBuilder(); path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); @@ -152,7 +151,7 @@ public class InstallArtifactsMojo private String pathOfRepositoryMetadata( String filename ) { - StringBuffer path = new StringBuffer(); + StringBuilder path = new StringBuilder(); path.append( filename ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java index 3ea0592..28e1ded 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/InstallMojo.java @@ -23,16 +23,13 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.installer.ArtifactInstaller; import org.apache.maven.plugin.MojoExecutionException; -import java.util.Iterator; - /** * Installs the project artifacts into the local repository. This is the essence of the Maven Install Plugin. - * - * @goal install - * @phase install - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal install + * @phase install */ public class InstallMojo extends AbstractRepoMojo @@ -40,14 +37,14 @@ public class InstallMojo /** * The artifact installer. - * + * * @component */ private ArtifactInstaller installer; /** * Runs this mojo. - * + * * @throws MojoExecutionException If any artifact could not be installed. */ public void execute() @@ -68,9 +65,9 @@ public class InstallMojo if ( attachedArtifacts != null ) { - for ( Iterator it = attachedArtifacts.iterator(); it.hasNext(); ) + for ( Object attachedArtifact1 : attachedArtifacts ) { - Artifact attachedArtifact = (Artifact) it.next(); + Artifact attachedArtifact = (Artifact) attachedArtifact1; installer.install( attachedArtifact.getFile(), attachedArtifact, localRepository ); } } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java index a3faf5a..af76279 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java @@ -35,11 +35,10 @@ import java.util.Properties; /** * Resolves user-specified artifacts. This mimics in part the Maven Dependency Plugin and the Maven Surefire Plugin. - * - * @goal resolve - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal resolve */ public class ResolveMojo extends AbstractMojo @@ -47,7 +46,7 @@ public class ResolveMojo /** * The local repository. - * + * * @parameter default-value="${localRepository}" * @readonly * @required @@ -56,7 +55,7 @@ public class ResolveMojo /** * The remote repositories of the current Maven project. - * + * * @parameter default-value="${project.remoteArtifactRepositories}" * @readonly * @required @@ -65,35 +64,35 @@ public class ResolveMojo /** * The artifact resolver. - * + * * @component */ private ArtifactResolver resolver; /** * The artifact factory. - * + * * @component */ private ArtifactFactory factory; /** * The dependencies to resolve. - * + * * @parameter */ private Dependency[] dependencies; /** * The path to a properties file to store the resolved artifact paths in. - * + * * @parameter */ private File propertiesFile; /** * Runs this mojo. - * + * * @throws MojoFailureException If the artifact could not be resolved */ public void execute() @@ -107,10 +106,8 @@ public class ResolveMojo { 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(), @@ -142,15 +139,10 @@ public class ResolveMojo { propertiesFile.getParentFile().mkdirs(); - FileOutputStream fos = new FileOutputStream( propertiesFile ); - try + try ( FileOutputStream fos = new FileOutputStream( propertiesFile ) ) { props.store( fos, "MAVEN-CORE-IT" ); } - finally - { - fos.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-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java index d842f47..dd1b1d1 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveTransitiveMojo.java @@ -31,7 +31,6 @@ import org.apache.maven.plugin.MojoExecutionException; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Properties; @@ -40,10 +39,9 @@ import java.util.Set; /** * Resolves user-specified artifacts transitively. As an additional exercise, the resolution happens in a forked thread * to test access to any shared session state. - * - * @goal resolve-transitive - * + * * @author Benjamin Bentmann + * @goal resolve-transitive */ public class ResolveTransitiveMojo extends AbstractMojo @@ -51,7 +49,7 @@ public class ResolveTransitiveMojo /** * The local repository. - * + * * @parameter default-value="${localRepository}" * @readonly * @required @@ -60,7 +58,7 @@ public class ResolveTransitiveMojo /** * The remote repositories of the current Maven project. - * + * * @parameter default-value="${project.remoteArtifactRepositories}" * @readonly * @required @@ -69,42 +67,42 @@ public class ResolveTransitiveMojo /** * The artifact resolver. - * + * * @component */ private ArtifactResolver resolver; /** * The artifact factory. - * + * * @component */ private ArtifactFactory factory; /** * The metadata source. - * + * * @component */ private ArtifactMetadataSource metadataSource; /** * The dependencies to resolve. - * + * * @parameter */ private Dependency[] dependencies; /** * The path to a properties file to store the resolved artifact paths in. - * + * * @parameter */ private File propertiesFile; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the artifacts couldn't be resolved. */ public void execute() @@ -140,15 +138,10 @@ public class ResolveTransitiveMojo { propertiesFile.getParentFile().mkdirs(); - FileOutputStream fos = new FileOutputStream( propertiesFile ); - try + try ( FileOutputStream fos = new FileOutputStream( propertiesFile ) ) { thread.props.store( fos, "MAVEN-CORE-IT" ); } - finally - { - fos.close(); - } } catch ( IOException e ) { @@ -179,30 +172,27 @@ public class ResolveTransitiveMojo { Set artifacts = new LinkedHashSet(); - 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(), dependency.getClassifier() ); - getLog().info( "[MAVEN-CORE-IT-LOG] Resolving " - + ResolveTransitiveMojo.this.getId( artifact ) ); + getLog().info( + "[MAVEN-CORE-IT-LOG] Resolving " + ResolveTransitiveMojo.this.getId( artifact ) ); artifacts.add( artifact ); } Artifact origin = factory.createArtifact( "it", "it", "0.1", null, "pom" ); - artifacts = - resolver.resolveTransitively( artifacts, origin, remoteRepositories, localRepository, - metadataSource ).getArtifacts(); + artifacts = resolver.resolveTransitively( artifacts, origin, remoteRepositories, localRepository, + metadataSource ).getArtifacts(); - for ( Iterator it = artifacts.iterator(); it.hasNext(); ) + for ( Object artifact1 : artifacts ) { - Artifact artifact = (Artifact) it.next(); + Artifact artifact = (Artifact) artifact1; if ( artifact.getFile() != null ) { http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java index 4c1e1e0..8275024 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AbstractLoadMojo.java @@ -30,13 +30,12 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Properties; /** * Loads classes and/or resources from a class loader and records the results in a properties file. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -50,7 +49,7 @@ public abstract class AbstractLoadMojo * key will be the hash code of the requested class. In addition, a key named <code>QCN.methods</code> holds the * comma separated list of all public methods declared directly in that class, in alphabetic order and possibly with * duplicates to account for overloaded methods. - * + * * @parameter property="clsldr.classNames" */ protected String classNames; @@ -60,15 +59,15 @@ public abstract class AbstractLoadMojo * successfully loaded, the generated properties files will contain a key named <code>ARP</code> whose value gives * the URL to the resource. In addition, the keys <code>ARP.count</code>, <code>ARP.0</code>, <code>ARP.1</code> * etc. will enumerate all URLs matching the resource name. - * + * * @parameter property="clsldr.resourcePaths" */ protected String resourcePaths; /** * Loads the classes/resources. - * - * @param outputFile The path to the properties file to generate, must not be <code>null</code>. + * + * @param outputFile The path to the properties file to generate, must not be <code>null</code>. * @param classLoader The class loader to use, must not be <code>null</code>. * @throws MojoExecutionException If the output file could not be created. */ @@ -94,9 +93,8 @@ public abstract class AbstractLoadMojo if ( classNames != null && classNames.length() > 0 ) { String[] names = classNames.split( "," ); - for ( int i = 0; i < names.length; i++ ) + for ( String name : names ) { - String name = names[i]; getLog().info( "[MAVEN-CORE-IT-LOG] Loading class " + name ); // test ClassLoader.loadClass(String) and (indirectly) ClassLoader.loadClass(String, boolean) @@ -120,22 +118,22 @@ public abstract class AbstractLoadMojo Method[] methods = type.getDeclaredMethods(); List methodNames = new ArrayList(); - for ( int j = 0; j < methods.length; j++ ) + for ( Method method : methods ) { - if ( Modifier.isPublic( methods[j].getModifiers() ) ) + if ( Modifier.isPublic( method.getModifiers() ) ) { - methodNames.add( methods[j].getName() ); + methodNames.add( method.getName() ); } } Collections.sort( methodNames ); - StringBuffer buffer = new StringBuffer( 1024 ); - for ( Iterator it = methodNames.iterator(); it.hasNext(); ) + StringBuilder buffer = new StringBuilder( 1024 ); + for ( Object methodName : methodNames ) { if ( buffer.length() > 0 ) { buffer.append( ',' ); } - buffer.append( it.next() ); + buffer.append( methodName ); } loaderProperties.setProperty( name + ".methods", buffer.toString() ); @@ -156,9 +154,8 @@ public abstract class AbstractLoadMojo if ( resourcePaths != null && resourcePaths.length() > 0 ) { String[] paths = resourcePaths.split( "," ); - for ( int i = 0; i < paths.length; i++ ) + for ( String path : paths ) { - String path = paths[i]; getLog().info( "[MAVEN-CORE-IT-LOG] Loading resource " + path ); // test ClassLoader.getResource() http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AssignmentCompatibleMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AssignmentCompatibleMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AssignmentCompatibleMojo.java index 3a2c306..c11f18b 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AssignmentCompatibleMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/AssignmentCompatibleMojo.java @@ -29,11 +29,10 @@ import java.util.Properties; /** * Checks whether API classes exported by the Maven core are assignment-compatible with types loaded from the plugin * class loader. In other words, checks that types shared with the core realm are imported into the plugin realm. - * + * + * @author Benjamin Bentmann * @goal assignment-compatible * @phase initialize - * - * @author Benjamin Bentmann */ public class AssignmentCompatibleMojo extends AbstractMojo @@ -41,21 +40,21 @@ public class AssignmentCompatibleMojo /** * The path to the properties file used to track the results of the assignment compatibility tests. - * + * * @parameter property="clsldr.assigncompatPropertiesFile" */ private File assigncompatPropertiesFile; /** * The qualified names of the types to check. - * + * * @parameter */ private String[] classNames; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() @@ -73,9 +72,8 @@ public class AssignmentCompatibleMojo if ( classNames != null ) { - for ( int i = 0; i < classNames.length; i++ ) + for ( String className : classNames ) { - String className = classNames[i]; String result; getLog().info( "[MAVEN-CORE-IT-LOG] Loading class " + className ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java index 9f32f8b..8acd60f 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/ExpressionUtil.java @@ -29,7 +29,7 @@ import java.util.Map; /** * Assists in evaluating expressions. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -52,10 +52,11 @@ class ExpressionUtil * root 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 contexts The possible root objects for the expression evaluation, indexed by their identifying token, must - * not be <code>null</code>. + * @param contexts The possible root objects for the expression evaluation, indexed by their identifying token, + * must + * not be <code>null</code>. * @return The value of the expression or <code>null</code> if the expression could not be evaluated. */ public static Object evaluate( String expression, Map contexts ) @@ -80,8 +81,8 @@ class ExpressionUtil /** * Evaluates the given expression segments against the specified object. - * - * @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>. * @param segments The expression segments to evaluate, must not be <code>null</code>. * @return The value of the evaluation or <code>null</code> if the segments could not be evaluated. */ @@ -137,8 +138,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. */ @@ -192,7 +193,7 @@ class ExpressionUtil { method = type.getMethod( "get", OBJECT_PARAM ); } - value = method.invoke( context, new Object[] { property } ); + value = method.invoke( context, new Object[]{ property } ); } catch ( NoSuchMethodException e3 ) { @@ -205,7 +206,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-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/InstanceofMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/InstanceofMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/InstanceofMojo.java index dda908d..253a84d 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/InstanceofMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/main/java/org/apache/maven/plugin/coreit/InstanceofMojo.java @@ -25,7 +25,6 @@ import org.apache.maven.plugin.MojoFailureException; import java.io.File; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -33,12 +32,11 @@ import java.util.Properties; /** * Checks whether objects obtained from the Maven core are assignment-compatible with types loaded from the plugin class * loader. In other words, checks that types shared with the core realm are imported into the plugin realm. - * - * @goal instanceof - * @phase initialize - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal instanceof + * @phase initialize */ public class InstanceofMojo extends AbstractMojo @@ -46,7 +44,7 @@ public class InstanceofMojo /** * The path to the properties file used to track the results of the instanceof tests. - * + * * @parameter property="clsldr.instanceofPropertiesFile" */ private File instanceofPropertiesFile; @@ -54,28 +52,28 @@ public class InstanceofMojo /** * The qualified name of the type to which the objects should be assignment-compatible. This type will be loaded * from the plugin class loader, just like as if it was imported in the plugin source code. - * + * * @parameter property="clsldr.className" */ private String className; /** * A list of expressions that denote the object instances that should be type-checked. - * + * * @parameter */ private String[] objectExpressions; /** * A list of injected component instances that should be type-checked. - * + * * @component role="org.apache.maven.plugin.coreit.Component" */ private List components; /** * The current Maven project against which expressions are evaluated. - * + * * @parameter default-value="${project}" * @readonly */ @@ -83,7 +81,7 @@ public class InstanceofMojo /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() @@ -109,9 +107,8 @@ public class InstanceofMojo contexts.put( "project", project ); contexts.put( "pom", project ); - for ( int i = 0; i < objectExpressions.length; i++ ) + for ( String expression : objectExpressions ) { - String expression = objectExpressions[i]; getLog().info( "[MAVEN-CORE-IT-LOG] Evaluating expression " + expression ); Object object = ExpressionUtil.evaluate( expression, contexts ); getLog().info( "[MAVEN-CORE-IT-LOG] Checking object " + object ); @@ -127,9 +124,8 @@ public class InstanceofMojo if ( components != null && !components.isEmpty() ) { - for ( Iterator it = components.iterator(); it.hasNext(); ) + for ( Object object : components ) { - Object object = it.next(); getLog().info( "[MAVEN-CORE-IT-LOG] Checking component " + object ); getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class " + object.getClass().getName() ); getLog().info( "[MAVEN-CORE-IT-LOG] Loaded class from " + object.getClass().getClassLoader() ); http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/3987b9fd/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java index fe79740..6459cd3 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/src/test/java/org/apache/maven/plugin/coreit/ExpressionUtilTest.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-class-loader/maven-it-plugin-class-loader/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,20 +54,20 @@ public class ExpressionUtilTest assertSame( bean, ExpressionUtil.evaluate( "bean", contexts ) ); assertNull( ExpressionUtil.evaluate( "no-root", contexts ) ); - assertEquals( new Integer( 3 ), ExpressionUtil.evaluate( "array/length", contexts ) ); + assertEquals( 3, ExpressionUtil.evaluate( "array/length", contexts ) ); assertEquals( "three", ExpressionUtil.evaluate( "array/2", contexts ) ); - assertEquals( new Integer( 5 ), ExpressionUtil.evaluate( "array/2/length", contexts ) ); + assertEquals( 5, ExpressionUtil.evaluate( "array/2/length", contexts ) ); assertNull( ExpressionUtil.evaluate( "array/invalid", contexts ) ); assertNull( ExpressionUtil.evaluate( "array/-1", contexts ) ); assertNull( ExpressionUtil.evaluate( "array/999", contexts ) ); - assertEquals( new Integer( 3 ), ExpressionUtil.evaluate( "list/size", contexts ) ); + assertEquals( 3, ExpressionUtil.evaluate( "list/size", contexts ) ); assertEquals( "-2", ExpressionUtil.evaluate( "list/2", contexts ) ); assertNull( ExpressionUtil.evaluate( "list/invalid", contexts ) ); assertNull( ExpressionUtil.evaluate( "list/-1", contexts ) ); assertNull( ExpressionUtil.evaluate( "list/999", contexts ) ); - assertEquals( new Integer( 1 ), ExpressionUtil.evaluate( "map/size", contexts ) ); + assertEquals( 1, ExpressionUtil.evaluate( "map/size", contexts ) ); assertEquals( "value", ExpressionUtil.evaluate( "map/some.key", contexts ) ); assertNull( ExpressionUtil.evaluate( "map/invalid", contexts ) ); @@ -91,7 +91,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-configuration/src/main/java/org/apache/maven/plugin/coreit/ConfigMojo.java ---------------------------------------------------------------------- diff --git a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/ConfigMojo.java b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/ConfigMojo.java index 268d258..9d61d6b 100644 --- a/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/ConfigMojo.java +++ b/core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/ConfigMojo.java @@ -19,6 +19,10 @@ package org.apache.maven.plugin.coreit; * under the License. */ +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.configuration.PlexusConfiguration; + import java.io.File; import java.net.URI; import java.net.URL; @@ -28,18 +32,13 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.codehaus.plexus.configuration.PlexusConfiguration; - /** * Dumps this mojo's configuration into a properties file. - * - * @goal config - * @phase validate - * + * * @author Benjamin Bentmann * @version $Id$ + * @goal config + * @phase validate */ public class ConfigMojo extends AbstractMojo @@ -47,7 +46,7 @@ public class ConfigMojo /** * The current project's base directory, used for path alignment. - * + * * @parameter default-value="${basedir}" * @readonly */ @@ -55,210 +54,210 @@ public class ConfigMojo /** * The path to the properties file into which to save the mojo configuration. - * + * * @parameter property="config.propertiesFile" */ private File propertiesFile; /** * A parameter with an alias. - * + * * @parameter alias="aliasParamLegacy" */ private String aliasParam; /** * A parameter with a constant default value. - * + * * @parameter default-value="maven-core-it" */ private String defaultParam; /** * A parameter with a default value using multiple expressions. - * + * * @parameter default-value="${project.groupId}:${project.artifactId}:${project.version}" */ private String defaultParamWithExpression; /** * A parameter that combines all of the annotations. - * + * * @parameter alias="fullyAnnotatedParam" property="config.aliasDefaultExpressionParam" default-value="test" */ private String aliasDefaultExpressionParam; /** * A simple parameter of type {@link java.lang.Boolean}. - * + * * @parameter property="config.booleanParam" */ private Boolean booleanParam; /** * A simple parameter of type {@link java.lang.Boolean#TYPE}. - * + * * @parameter property="config.primitiveBooleanParam" */ private boolean primitiveBooleanParam; /** * A simple parameter of type {@link java.lang.Byte}. - * + * * @parameter property="config.byteParam" */ private Byte byteParam; /** * A simple parameter of type {@link java.lang.Short}. - * + * * @parameter property="config.shortParam" */ private Short shortParam; /** * A simple parameter of type {@link java.lang.Integer}. - * + * * @parameter property="config.intergerParam" */ private Integer integerParam; /** * A simple parameter of type {@link java.lang.Integer#TYPE}. - * + * * @parameter property="config.primitiveIntegerParam" */ private int primitiveIntegerParam; /** * A simple parameter of type {@link java.lang.Long}. - * + * * @parameter property="config.longParam" */ private Long longParam; /** * A simple parameter of type {@link java.lang.Float}. - * + * * @parameter property="config.floatParam" */ private Float floatParam; /** * A simple parameter of type {@link java.lang.Double}. - * + * * @parameter property="config.doubleParam" */ private Double doubleParam; /** * A simple parameter of type {@link java.lang.Character}. - * + * * @parameter property="config.characterParam" */ private Character characterParam; /** * A simple parameter of type {@link java.lang.String}. - * + * * @parameter property="config.stringParam" */ private String stringParam; /** * A simple parameter of type {@link java.io.File}. - * + * * @parameter property="config.fileParam" */ private File fileParam; /** * A simple parameter of type {@link java.util.Date}. - * + * * @parameter property="config.dateParam" */ private Date dateParam; /** * A simple parameter of type {@link java.net.URL}. - * + * * @parameter property="config.urlParam" */ private URL urlParam; /** * A simple parameter of type {@link java.net.URI} (requires Maven 3.x). - * + * * @parameter */ private URI uriParam; /** * An array parameter of component type {@link java.lang.String}. - * + * * @parameter */ private String[] stringParams; /** * An array parameter of component type {@link java.io.File}. - * + * * @parameter */ private File[] fileParams; /** * A collection parameter of type {@link java.util.List}. - * + * * @parameter */ private List listParam; /** * A collection parameter of type {@link java.util.Set}. - * + * * @parameter */ private Set setParam; /** * A collection parameter of type {@link java.util.Map}. - * + * * @parameter */ private Map mapParam; /** * A collection parameter of type {@link java.util.Properties}. - * + * * @parameter */ private Properties propertiesParam; /** * A complex parameter with an alias. - * + * * @parameter alias="aliasStringParamsLegacy" */ private String[] aliasStringParams; /** * A complex parameter of type {@link org.apache.maven.plugin.coreit.Bean}. - * + * * @parameter */ private Bean beanParam; /** * A raw DOM snippet. - * + * * @parameter */ private PlexusConfiguration domParam; /** * Runs this mojo. - * + * * @throws MojoExecutionException If the output file could not be created. */ public void execute() @@ -289,7 +288,7 @@ public class ConfigMojo /** * Dumps the mojo configuration into the specified properties. - * + * * @param props The properties to dump the configuration into, must not be <code>null</code>. */ private void dumpConfiguration( Properties props ) @@ -306,14 +305,14 @@ public class ConfigMojo PropertiesUtil.serialize( props, "booleanParam", booleanParam ); if ( primitiveBooleanParam ) { - PropertiesUtil.serialize( props, "primitiveBooleanParam", Boolean.valueOf( primitiveBooleanParam ) ); + PropertiesUtil.serialize( props, "primitiveBooleanParam", primitiveBooleanParam ); } PropertiesUtil.serialize( props, "byteParam", byteParam ); PropertiesUtil.serialize( props, "shortParam", shortParam ); PropertiesUtil.serialize( props, "integerParam", integerParam ); if ( primitiveIntegerParam != 0 ) { - PropertiesUtil.serialize( props, "primitiveIntegerParam", new Integer( primitiveIntegerParam ) ); + PropertiesUtil.serialize( props, "primitiveIntegerParam", primitiveIntegerParam ); } PropertiesUtil.serialize( props, "longParam", longParam ); PropertiesUtil.serialize( props, "floatParam", floatParam ); @@ -336,7 +335,7 @@ public class ConfigMojo { PropertiesUtil.serialize( props, "beanParam.fieldParam", beanParam.fieldParam ); PropertiesUtil.serialize( props, "beanParam.setterParam", beanParam.setterParam ); - PropertiesUtil.serialize( props, "beanParam.setterCalled", Boolean.valueOf( beanParam.setterCalled ) ); + PropertiesUtil.serialize( props, "beanParam.setterCalled", beanParam.setterCalled ); } }