Bug 397176 - m2e-wtp doesn't seem to respect maven war plugin's <webResources> configuration element
Summary: m2e-wtp doesn't seem to respect maven war plugin's <webResources> configurati...
Status: UNCONFIRMED
Alias: None
Product: M2E-WTP
Classification: Technology
Component: Core (show other bugs)
Version: 0.16.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-26 23:24 EST by Brien Wheeler CLA
Modified: 2020-06-03 18:46 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brien Wheeler CLA 2012-12-26 23:24:20 EST
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
Comment 1 Fred Bricon CLA 2012-12-31 09:01:46 EST
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.
Comment 2 Darryl Miles CLA 2013-04-21 10:34:57 EDT
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.
Comment 3 Luis Panadero Guardeño CLA 2019-01-09 04:05:05 EST
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.