diff --git a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java index aa1c80c0319..508db353f2a 100644 --- a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java +++ b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/DependencyEmbedder.java @@ -21,7 +21,6 @@ import java.io.File; import java.util.Collection; -import java.util.Iterator; import java.util.LinkedHashSet; import org.apache.maven.artifact.Artifact; @@ -91,13 +90,13 @@ public void processHeaders( Analyzer analyzer ) throws MojoExecutionException processInstructions( embedDependencyHeader ); - for ( Iterator i = m_inlinedPaths.iterator(); i.hasNext(); ) + for ( String path : m_inlinedPaths ) { - inlineDependency( i.next(), includeResource ); + inlineDependency( path, includeResource ); } - for ( Iterator i = m_embeddedArtifacts.iterator(); i.hasNext(); ) + for ( Artifact artifact : m_embeddedArtifacts ) { - embedDependency( i.next(), includeResource, bundleClassPath, embeddedArtifacts ); + embedDependency( artifact, includeResource, bundleClassPath, embeddedArtifacts ); } } @@ -125,9 +124,9 @@ protected void processDependencies( Collection dependencies, String in } else { - for ( Iterator i = dependencies.iterator(); i.hasNext(); ) + for ( Artifact dependency : dependencies ) { - addInlinedPaths( i.next(), inline, m_inlinedPaths ); + addInlinedPaths( dependency, inline, m_inlinedPaths ); } } } @@ -145,11 +144,11 @@ private static void addInlinedPaths( Artifact dependency, String inline, Collect else { String[] filters = inline.split( "\\|" ); - for ( int i = 0; i < filters.length; i++ ) + for ( String filter : filters ) { - if ( filters[i].length() > 0 ) + if ( filter.length() > 0 ) { - inlinedPaths.add( path + "!/" + filters[i] ); + inlinedPaths.add( path + "!/" + filter ); } } } @@ -169,14 +168,14 @@ private void embedDependency( Artifact dependency, StringBuffer includeResource, embedDirectory = null; } - if ( false == Boolean.valueOf( m_embedStripGroup ).booleanValue() ) + if ( !Boolean.valueOf( m_embedStripGroup ) ) { embedDirectory = new File( embedDirectory, dependency.getGroupId() ).getPath(); } - StringBuffer targetFileName = new StringBuffer(); + StringBuilder targetFileName = new StringBuilder(); targetFileName.append( dependency.getArtifactId() ); - if ( false == Boolean.valueOf( m_embedStripVersion ).booleanValue() ) + if ( !Boolean.valueOf( m_embedStripVersion ) ) { targetFileName.append( '-' ).append( dependency.getVersion() ); if ( StringUtils.isNotEmpty( dependency.getClassifier() ) ) @@ -265,7 +264,7 @@ private static void appendDependencies( Analyzer analyzer, String directiveName, final String instruction = analyzer.getProperty( directiveName ); if ( StringUtils.isNotEmpty( instruction ) ) { - if ( instruction.indexOf( MAVEN_DEPENDENCIES ) >= 0 ) + if ( instruction.contains( MAVEN_DEPENDENCIES ) ) { // if there are no embeddded dependencies, we do a special treatment and replace // every occurance of MAVEN_DEPENDENCIES and a following comma with an empty string diff --git a/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/ArtifactStubFactory.java b/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/ArtifactStubFactory.java index 688acc6e359..00d7af4f6af 100644 --- a/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/ArtifactStubFactory.java +++ b/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/ArtifactStubFactory.java @@ -29,7 +29,6 @@ /** * Fixed version of class that uses stable set ordering for reliable testing. */ -@SuppressWarnings( { "rawtypes", "unchecked" } ) class ArtifactStubFactory extends org.apache.maven.plugin.testing.ArtifactStubFactory { @@ -39,9 +38,9 @@ public ArtifactStubFactory( File workingDir, boolean createFiles ) } @Override - public Set getClassifiedArtifacts() throws IOException + public Set getClassifiedArtifacts() throws IOException { - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet<>(); set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", "one" ) ); set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", "two" ) ); set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "jar", "three" ) ); @@ -50,9 +49,9 @@ public Set getClassifiedArtifacts() throws IOException } @Override - public Set getScopedArtifacts() throws IOException + public Set getScopedArtifacts() throws IOException { - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet<>(); set.add( createArtifact( "g", "compile", "1.0", Artifact.SCOPE_COMPILE ) ); set.add( createArtifact( "g", "provided", "1.0", Artifact.SCOPE_PROVIDED ) ); set.add( createArtifact( "g", "test", "1.0", Artifact.SCOPE_TEST ) ); @@ -62,9 +61,9 @@ public Set getScopedArtifacts() throws IOException } @Override - public Set getTypedArtifacts() throws IOException + public Set getTypedArtifacts() throws IOException { - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet<>(); set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) ); set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) ); set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "sources", null ) );