khmarbaise commented on a change in pull request #3: [MJAR-260] Fail on invalid
automatic module name
URL: https://github.com/apache/maven-jar-plugin/pull/3#discussion_r234312461
##########
File path: src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
##########
@@ -223,6 +226,18 @@ public File createArchive()
archiver.createArchive( session, project, archive );
+ JarFile javaUtilJarFile = new JarFile( jarFile );
Review comment:
This will result in a resource leak cause javaUtilJarFile is never
closed....and doesn't it need to reread the file(I'm ot sure about)?
What about reusing the archive configuration part like this and do the check
before we create the real archive? (If I correctly seen that would result in
changing the IT as well)...
```java
if ( archive.getManifestEntries().containsKey(
AUTOMATIC_MODULE_NAME ) )
{
String automaticModuleName =
archive.getManifestEntries().get( AUTOMATIC_MODULE_NAME );
if ( automaticModuleName != null )
{
if ( !isValidModuleName( automaticModuleName ) )
{
throw new MojoExecutionException( "Invalid automatic
module name: '" + automaticModuleName
+ "'" );
}
}
}
archiver.createArchive( session, project, archive );
```
What do you think?
Furthermore we might keep that in maven-jar-plugin in the first step and
improve maven-archiver to make this check easier ? Or move that into
maven-archiver (could be done in createArchive() method ) which means can be
reused by other plugins as well...or even better will be checked already
there...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services