Community
Participate
Working Groups
I have a Maven WAR project that uses the js-import-maven-plugin to handle Javascript dependency management. For various reasons (desired URL structure, easier Spring Security configuration, JAWR integration), I want all my JS files to end up under /js in the WAR. The js-import plugin will merge project local JS files (from src/main/js) and resolved JS dependencies and put them into a single directory (by default WEB-INF/classes/js). Since JAWR won't serve the files out of /WEB-INF, I had to reconfigure the js-import plugin to output the merged fileset into a different directory (target/js-import/js) using this POM snippet (the "js" subdirectory is added by default by the js-import plugin): <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>js-import-maven-plugin</artifactId> <version>${version.plugin.js-import-maven}</version> <!-- have the js-import plugin go to a unique directory so the maven WAR - plugin will include these files in the right place in the WAR (/js/**). --> <configuration> <targetFolder>${project.build.directory}/js-import</targetFolder> </configuration> <executions> <execution> <goals> <goal>import-js</goal> <goal>test-import-js</goal> <goal>generate-html</goal> <goal>test-generate-html</goal> </goals> </execution> </executions> </plugin> To get the command-line Maven WAR plug-in to pick up these files and package them in the /js directory of the WAR file, I use this snippet: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>${project.build.directory}/js-import</directory> </resource> </webResources> </configuration> </plugin> </plugins> </build> This works great and results in exactly the WAR file I need. However, using m2e-wtp does not copy the "js" directory from target/js-import into the wtpwebapps folder. The files correctly exist under the target directory after an Eclipse build (and the Maven Lifecycle Mappings for the js-import plugin goals are correctly tagged as "execute" with a source of "maven plugin" in the project properties). Cheers, Brien
Can you please attach a standalone sample project reporducing the issue? My initial feeling is the generated folder is not seen by Eclipse, thus can't be deployed. This is expected as m2e as no knowledge of what folders need to be refreshed after a plugin execution. you need to either write a m2e connector or make that plugin m2e friendly : http://wiki.eclipse.org/M2E_compatible_maven_plugins Anyway you can try to manually refresh the target/ folder and redeploy on your server.
Take a look at http://mojo.codehaus.org/build-helper-maven-plugin/ as a possible solution to this problem. If you can not rewrite the plugin js-import-maven-plugin or make an m2e connector for this plugin. Then you can add an entry into your project to use build-helper-maven-plugin and use the add-source and add-resource. Note the order of the plugins maybe important, the build-helper would be configured after your js-import and before your war. Just in case they operated in the same maven phase.
Could someone try to fix this ? I can CONFIRM that this bug from 2013 are currently on current version and it's very annoying, as make pretty impossible using maven plugins like maven-front-plugin that allow to use a modern frontend pipeline with Eclipse WTP.