Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse and maven-war-plugin explode

I'm running against a brick with Eclipse.

I will try to explain. I'm working on a project that "abused" of maven overlays and have many modules that have Javascript and LESS files inside the webapp.

We managed to config maven to explode the dependencies on a directory where maven-frontend-plugin would process (using nodejs) to generate the final compiled JS and CSS files.

This is working perfectly when I'm using pure maven. However, on Eclipse, this not ends to work correctly. The main reason is that Eclipse simple ignores the execution config of maven-war-plugin that explodes the dependencies. Instead, it simple executes the default maven-war-plugin:explode.

I need to fix it, as is the biggest roadblock to get a modern frontend develop environment (using nodejs, npm and gulp to transpile JS and LESS).

Extracted from our main pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>make-webapp-compress</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <mkdir dir="${project.build.directory}/webapp-exploded" />
                    <mkdir dir="${project.build.directory}/webapp-compress" />
                </tasks>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <executions>
        <execution>
            <id>parent-resources-less</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>exploded</goal>
            </goals>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <warSourceExcludes>**/*.ftl,**/*.vm,**/*.xml,WEB-INF/,META-INF/</warSourceExcludes>
                <warSourceIncludes>**/*.css,**/*.less,**/*.js</warSourceIncludes>
                <webappDirectory>${project.build.directory}/webapp-exploded</webappDirectory>
                <webResources>
                    <resource>
                        <directory>src/main/webapp</directory>
                    </resource>
                </webResources>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
        <lifecycleMappingMetadata>
            <pluginExecutions>
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <versionRange>[1.8,]</versionRange>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </pluginExecutionFilter>
                    <action>
                        <execute />
                    </action>
                </pluginExecution>
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <versionRange>[3.0.0,]</versionRange>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                    </pluginExecutionFilter>
                    <action>
                        <execute />
                    </action>
                </pluginExecution>
            </pluginExecutions>
        </lifecycleMappingMetadata>
    </configuration>
</plugin>
like image 497
Zardoz89 Avatar asked Oct 18 '18 15:10

Zardoz89


1 Answers

You can try using the plugin "maven-dependency-plugin". I used this in my project to copy the dependencies to the desired specific output destination. I am attaching the sample config, update this as per your requirement.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/pipeline/lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>
like image 148
Jibran Avatar answered Oct 19 '22 01:10

Jibran