Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 407100

Summary: Renamed jars cause file handle leaks in windows. Use IClasspathDependencyConstants.CLASSPATH_ARCHIVENAME_ATTRIBUTE instead
Product: [Technology] M2E-WTP Reporter: Fred Bricon <fbricon>
Component: CoreAssignee: Project Inbox <m2e-wtp.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: fbricon, manderse, snjezana.peco
Version: 0.17.0   
Target Milestone: Kepler M7   
Hardware: PC   
OS: Windows 7   
URL: https://issues.sonatype.org/browse/MECLIPSEWTP-215
Whiteboard:
Bug Depends on: 359385    
Bug Blocks: 406173    

Description Fred Bricon CLA 2013-05-02 14:42:11 EDT
m2e-wtp configures the Maven Classpath Library for export, when dealing with Web projects. When jars from a classpath library are exported /published, the original file name is used. 
When using pure maven, you have the possibility to export referenced jars under a different name. For instance, my web app references some-external-library-x.y.z.jar but I want to deploy it under WEB-INF/lib/some-external-library.jar instead.

Current workaround in m2e-wtp is to copy some-external-library-x.y.z.jar from the original local maven repository to a temporary location (project/target/some-external-library.jar), change the path directly in the classpath entry in the maven library, so that the source file name is the same as the deployed name. 

This workaround causes file handle leaks on windows, in certain circumstances, preventing the target folder to be deleted (by issueing a mvn clean command). as mentioned in bug 382080 and https://issues.sonatype.org/browse/MECLIPSEWTP-215

A proper solution requires bug 359385 to be fixed. After adding the deployed name under as a classpath entry attribute under the IClasspathDependencyConstants.CLASSPATH_ARCHIVENAME_ATTRIBUTE, copying the jars under target/* won't be necessary.

This solution will work for WTP > 3.5.0 (Kepler), unless IClasspathDependencyConstants.CLASSPATH_ARCHIVENAME_ATTRIBUTE is backported to 3.4.x. When IClasspathDependencyConstants.CLASSPATH_ARCHIVENAME_ATTRIBUTE is not available, the previous workaround will be used.
Comment 1 Fred Bricon CLA 2013-05-02 14:46:08 EDT
Do'h the correct m2e-wtp bug reference is bug 406173
Comment 2 Fred Bricon CLA 2013-05-05 10:02:05 EDT
Fixed with http://git.eclipse.org/c/m2e-wtp/org.eclipse.m2e.wtp.git/commit/?id=bb7621b265fd2f8a82c666aeb3be69b3ae8967e5

Tests https://github.com/jbosstools/m2e-wtp-tests/commit/4e76da3a9c097d68c84a95b6413beaafb5c7c743

Falls back on old copy to target/ mechanism if IClasspathDependencyConstants.CLASSPATH_ARCHIVENAME_ATTRIBUTE is not supported