rfscholte commented on a change in pull request #4: [MJAR-254] Finish the fix
of MJAR-198.
URL: https://github.com/apache/maven-jar-plugin/pull/4#discussion_r248425774
##########
File path: src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
##########
@@ -272,11 +275,25 @@ public void execute()
private boolean projectHasAlreadySetAnArtifact()
{
- final File artifact = getProject().getArtifact().getFile();
- if ( artifact != null )
+ if ( getProject().getArtifact().getFile() != null )
{
- final String defaultArtifactName = artifact.getName().replace(
".jar", "" );
- return artifact.isFile() && defaultArtifactName.equals( finalName
);
+ if ( getProject().getArtifact().getFile().isFile() )
+ {
+ try
+ {
+ JarFile existingJarFile = new JarFile(
getProject().getArtifact().getFile() );
+ Attributes existingJarFileAttr =
existingJarFile.getManifest().getMainAttributes();
Review comment:
Sorry for confusing you. I've only added the check with the MANIFEST file in
the integration test to make it succeed on to explain how to verify resources
in a jar.
Back to my biggest concern: I'm afraid that if users play with final names
that the check it not good and might install the wrong artifact. I want to
ensure that the first one (no matter the final name) always wins. Using the
same classifier with different final names should also lead to an exception.
I hope this makes it a bit more clear.
----------------------------------------------------------------
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