diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java index 4c2a4bf..477d192 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java @@ -105,8 +105,7 @@ public class PluginDescriptorGenerator // write plugin-help.xml help-descriptor MavenProject mavenProject = request.getProject(); String pluginHelpFilePath = - "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() - + "/plugin-help.xml"; + "META-INF/maven/" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() + "/plugin-help.xml"; f = new File( request.getProject().getBuild().getOutputDirectory(), pluginHelpFilePath ); writeDescriptor( f, request, true ); } @@ -153,8 +152,8 @@ public class PluginDescriptorGenerator XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null ); - w.writeMarkup( "\n\n\n" ); + w.writeMarkup( "\n\n\n" ); w.startElement( "plugin" ); @@ -174,7 +173,8 @@ public class PluginDescriptorGenerator { GeneratorUtils.element( w, "isolatedRealm", String.valueOf( pluginDescriptor.isIsolatedRealm() ) ); - GeneratorUtils.element( w, "inheritedByDefault", String.valueOf( pluginDescriptor.isInheritedByDefault() ) ); + GeneratorUtils.element( w, "inheritedByDefault", + String.valueOf( pluginDescriptor.isInheritedByDefault() ) ); } w.startElement( "mojos" ); @@ -218,8 +218,8 @@ public class PluginDescriptorGenerator } /** - * @param mojoDescriptor not null - * @param w not null + * @param mojoDescriptor not null + * @param w not null * @param helpDescriptor will clean html content from description fields */ protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, boolean helpDescriptor ) @@ -260,14 +260,16 @@ public class PluginDescriptorGenerator if ( StringUtils.isNotEmpty( mojoDescriptor.isDependencyResolutionRequired() ) ) { - GeneratorUtils.element( w, "requiresDependencyResolution", mojoDescriptor.isDependencyResolutionRequired() ); + GeneratorUtils.element( w, "requiresDependencyResolution", + mojoDescriptor.isDependencyResolutionRequired() ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - GeneratorUtils.element( w, "requiresDirectInvocation", String.valueOf( mojoDescriptor.isDirectInvocationOnly() ) ); + GeneratorUtils.element( w, "requiresDirectInvocation", + String.valueOf( mojoDescriptor.isDirectInvocationOnly() ) ); // ---------------------------------------------------------------------- // @@ -431,7 +433,7 @@ public class PluginDescriptorGenerator if ( extendedMojoDescriptor.getDependencyCollectionRequired() != null ) { GeneratorUtils.element( w, "requiresDependencyCollection", - extendedMojoDescriptor.getDependencyCollectionRequired() ); + extendedMojoDescriptor.getDependencyCollectionRequired() ); } GeneratorUtils.element( w, "threadSafe", String.valueOf( extendedMojoDescriptor.isThreadSafe() ) ); @@ -538,8 +540,8 @@ public class PluginDescriptorGenerator GeneratorUtils.element( w, "description", parameter.getDescription(), helpDescriptor ); - if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) - || StringUtils.isNotEmpty( parameter.getExpression() ) ) + if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) || StringUtils.isNotEmpty( + parameter.getExpression() ) ) { configuration.add( parameter ); } @@ -627,7 +629,7 @@ public class PluginDescriptorGenerator /** * Get the expression value, eventually surrounding it with ${ }. - * + * * @param parameter the parameter * @return the expression value */ @@ -663,15 +665,22 @@ public class PluginDescriptorGenerator rewriteHelpClassFile.getParentFile().mkdirs(); } + FileInputStream fileInputStream = null; + ClassReader cr = null; try { - cr = new ClassReader( new FileInputStream( helpClassFile ) ); + fileInputStream = new FileInputStream( helpClassFile ); + cr = new ClassReader( fileInputStream ); } catch ( IOException e ) { throw new GeneratorException( e.getMessage(), e ); } + finally + { + IOUtil.close( fileInputStream ); + } ClassWriter cw = new ClassWriter( 0 );