Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: plexus-archiver-1.2, plexus-archiver-2.0
-
Fix Version/s: plexus-archiver-2.0.2
-
Component/s: plexus-archiver
-
Labels:None
-
Environment:Windows 7
Maven WAR Plugin
Plexus Archiver 1.2 (with local modifications, see below)
-
Number of attachments :
Description
I'm trying to fix MWAR-248 and have found the problem, after some serious digging into the plexus-archiver code.
The WAR Plugin begins by creating a WarArchiver to which it adds the webapp directory, using warArchiver.addDirectory(...). This adds the files in the webapp directory as a PlexusIoFileResourceCollection. Each object in the collection is added to the archive as an ArchiveEntry with a target name that is platform dependent. On Windows the contents of the archive looks like this, when printing out each entry's name:
org org\web org\web\app WEB-INF WEB-INF\classes org\web\app\last-exile.jsp pansit.jsp WEB-INF\web.xml
When this is done the WAR Plugin tried to add the web.xml file, if one exists. This is added to the WarArchive as a file.
Problem 1
WarArchiver.setWebxml() (line 88) will add the file with the target name hard coded to "WEB-INF/web.xml". This results in an ArchiveEntry that is different from the one added in the earlier step, for the exact same file.
Proposed Solution 1
Replace the hard coded file separator with File.separatorChar.
Problem 2
AbstractArchiver.addFile() (line 362) replaces all '\' with '/' in the target name. Again this results in an ArchiveEntry that is different than in the earlier step.
Proposed solution
Remove the line that converts '\' to '/':
destFileName = destFileName.replace( '\\', '/' );
Summary
The first solution is a no brainer, but I'm not sure what impact the second one will have. Ideally it would be best to always use Java syntax paths, with '/'. But I haven't figured out how to do this for warArchiver.addDirectory(...).
I've tried my proposed solution locally on Windows and all tests pass both in plexus archiver and the WAR Plugin. If you approve my proposed solution, I'll conduct more tests, and provide a patch file.
Note
All testing and modifications have been done on the plexus-archiver-1.2 tag. I haven't yet tried to upgrading the WAR Plugin to use Plexus Archiver 2.0.1.
Issue Links
- is depended upon by
-
MWAR-248
Plugin warns about missing webxml attribute even if one exists
-