Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] m2e-wtp, war overlays and shared resources

Hi,

referencing an older thread of mine...

I'm having problems with m2e-wtp on a multi-module project that produces a few EARs with WARs that use overlays: Deploying such a WAR on Tomcat 8.5.x or the corresponding EAR to Wildfly 10.1 is unsuccessful, the application doesn't start correctly because of missing resources in the WAR's WEB-INF folder.

Basic structure of my project:

app-main
+- app-form-resources
+- app-xsl-resources
+- app-jar
   +- mvn-p1
   +- mvn-p2
   +- ...
   \- mvn-pn
+- app-war
   +- app-jar
   +- mvn-p1-resources
   +- mvn-p2-resources
   +- ...
   \- mvn-pn-resources
+- app-ear
   \- app-war

The other mentioned WARs and EARs are basically the same as app-war/app-ear, but with a few customized files under WEB-INF. Anyway.

P1...n are legacy projects in our Subversion repository containing both Java sources and resource files (_javascript_, HTML, XML, XSL etc.) and are used in other applications built in our department. So far I have created a Maven-compatible "layer" for each of these projects and factored out Java files and resources:
* mvn-pX contains only the Java sources from project X (under src/main/java)
* mvn-pX-resources contains the legacy project's resources (directly under src/main/resources)

The same holds for app-form-resources and app-xsl-resources: two projects that contain resources from the legacy project for which I'm building the Maven layer.

All resource projects are of type "jar" and used as dependency with scope "provided" in app-war:

<dependency>
        <groupId>mygroup</groupId>
        <artifactId>mvn-p1-resources</artifactId>
        <version>...</version>
        <scope>provided</scope>
</dependency>

To put the resources in the correct place I'm using overlays:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
                <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>

                <overlays>
                        <overlay>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>app-xsl-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/WEB-INF/xsl</targetPath>
                        </overlay>
                        <overlay>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>app-form-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/form</targetPath>
                        </overlay>

                        <overlay>
                                <groupId>group1</groupId>
                                <artifactId>mvn-p1-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/</targetPath>
                                <includes>
                                        <include>**/*.css</include>
                                        <include>**/*.js</include>
                                </includes>
                        </overlay>
                        <overlay>
                                <groupId>group1</groupId>
                                <artifactId>mvn-p1-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/WEB-INF</targetPath>
                                <includes>
                                        <include>**/*.x*</include>
                                        <include>**/*.js</include>
                                </includes>
                        </overlay>

                        <overlay>
                                <groupId>group2</groupId>
                                <artifactId>mvn-p2-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/form</targetPath>
                                <includes>
                                        <include>**/*.css</include>
                                        <include>**/*.js</include>
                                </includes>
                        </overlay>

                        <overlay>
                                <groupId>group3</groupId>
                                <artifactId>mvn-p3-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/form</targetPath>
                                <includes>
                                        <include>**/*.js</include>
                                </includes>
                        </overlay>
                        <overlay>
                                <groupId>group3</groupId>
                                <artifactId>mvn-p3-resources</artifactId>
                                <type>jar</type>
                                <targetPath>/WEB-INF/xsl</targetPath>
                                <excludes>
                                        <exclude>**/*.js</exclude>
                                        <exclude>META-INF/**</exclude>
                                </excludes>
                        </overlay>

                        ...
                </overlays>
        </configuration>
</plugin>


My problem is that the EAR builds successfully on the command line and contains all specified resources in their correct place, but with WTP / m2e-wtp problems arise:

* Deploying app-war to Tomcat or app-ear to Wildfly doesn't work; the resources from app-form-resources, app-xsl-resources and mvn-p1...3-resources are completely missing
* When I right-click in the package explorer view on app-war and open the properties, I see a few warnings in the deployment assembly dialog page:
  Cannot find entry: app-form-resources
  The same warning entry for app-xsl-resources and mvn-p1...3-resources
  Other referenced (resource) projects are correctly listed without errors/warnings.
* Starting app-ear in Wildfly and having a look in the folder <wildfly-home>/standalone/deployments you can see that all other resource projects are correctly contained/deployed.

All resource projects have the same structure and basically differ only in their GAV coordinates and referenced resource files.
Changing the order of the overlay entries doesn't make any difference, by the way.


Do you have any idea what can cause this strange behaviour?


Regards

Thorsten



m2e-users-bounces@xxxxxxxxxxx schrieb am 26.02.2015 19:14:47:

> Von: Fred Bricon <fbricon@xxxxxxxxx>

> An: Maven Integration for Eclipse users mailing list <m2e-users@xxxxxxxxxxx>
> Datum: 26.02.2015 19:15
> Betreff: Re: [m2e-users] m2e-wtp, war overlays and shared resources
> Gesendet von: m2e-users-bounces@xxxxxxxxxxx
>
> m2e-wtp currently doesn't support artifacts generated by maven-assembly-
> plugin within the workspace. i.e a workspace project cannot reference a
> zip classifier artifact matching another workspace project. 

>
> You basically have 2 solutions : 

> - force the consumers to reference the zip file directly : either disable
> workspace resolution for projects consuming your zip (project > maven >
> disable worskpace resolution)  or delete mvn-Q-resources from your
> workspace. The big drawback of that approach is you'll have to execute
> mvn install on mvn-Q-resources everytime a file changes

> - change mvn-Q-resources type to jar. Move all your web resources to src/
> main/resources and reference :

>
>        <overlay> 
>           <groupId>mygroup</groupId> 
>           <artifactId>mvn-Q-resources</artifactId> 
>           <type>jar</type> 
>           <targetPath>/WEB-INF</targetPath> 
>           <includes> 
>             <include>/xsl/**</include> 
>           </includes> 
>         </overlay> 

>
> That solution should allow you to keep working/deploying stuff incrementally

>
> On Thu, Feb 26, 2015 at 11:25 AM, Thorsten Heit <thorsten.heit@xxxxxx> wrote:

> Hi,
>
> I'm in the process of creating Maven builds for a few applications. These
> applications use Ant build scripts to create WAR and EAR files.
>
>
> Initial situation:
>
> * All source code is stored in our Subversion repository.
> * Each application depends on several internal projects P1, P2, ... that
> all have a non-Maven-like structure.
> * Most, but not all of them not only contain Java code, but also web
> resources (HTML, _javascript_, XSL, ...) that have to be placed directly
> under "/" or under "/WEB-INF" in the resulting application WAR(s).
>
>
>
> Actual situation:
>
> * For each internal project P that contains only Java code I have created
> a new Maven project mvn-P using Maven conventions and directory layout;
> Java code is referenced under src/main/java via svn:externals.
> * For each project Q that contains both Java sources and resource files,
> I have created two Maven projects mvn-Q and mvn-Q-resources; as above
> Java code and resources are referenced via svn:externals. The mvn-Q-
> resources project is of type pom and uses the assembly plugin to create a
> zip archive containing the resources; i.e. builds an artifact named mvn-
> Q-resources-<version>-zip.zip
>
>
> For one of the WAR and EAR projects I created a multi-module Maven
> project to build the same WAR and EAR via Maven as the legacy Ant script.
> The structure is basically the following:
>
> app-main
> +- app-jar
>    +- mvn-p
>    \- mvn-q
> +- app-war
>    +- app-jar
>    \- mvn-q-resources
> +- app-ear
>    \- app-war
>
>
> The app-war pom.xml contains the following:
>
> <plugins>
>   <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-war-plugin</artifactId>
>     <configuration>
>       <!-- web resources -->
>       <overlays>
>         <overlay>
>           <groupId>mygroup</groupId>
>           <artifactId>mvn-Q-resources</artifactId>
>           <type>zip</type>
>           <classifier>zip</classifier>
>           <targetPath>/WEB-INF</targetPath>
>           <includes>
>             <include>/xsl/**</include>
>           </includes>
>         </overlay>
>         ...
>       </overlays>
>     </configuration>
>   </plugin>
>   ...
> </plugins>
>
> <dependencies>
>   <dependency>
>     <groupId>mygroup</groupId>
>     <artifactId>mvn-Q-resources</artifactId>
>     <version>1.0-SNAPSHOT</version>
>     <type>zip</type>
>     <classifier>zip</classifier>
>     <scope>runtime</scope>
>   </dependency>
>   ...
> </dependencies>
>
> So far, this works pretty fine using command-line Maven.
>
>
>
> The problem:
>
> My Eclipse workspace contains all necessary projects, i.e. mvn-P, mvn-Q,
> mvn-Q-resources, app-main, app-jar, app-war and app-ear. In the server
> view I created a new instance using a locally installed Tomcat. After
> adding app-war to it I see all the project's jar dependencies in the view. But:
> Although I can start the server and debug in the referenced dependencies,
> the WAR application doesn't run correctly because the referenced
> resources are not available, i.e. everything I added to m-war-p via
> overlays/overlay.
>
> I'm using the following:
>
> * Eclipse Mars 4.5 (Build id: I20150203-1300)
> * Java EE Developer Tools 3.7.0.v201501282120
> * m2e 1.6.0.20150220-1952
> * m2e-wtp 1.2.0.20150212-1712
> * Tomcat v8.0.20
> * Java 7u76
>
> Do you have any hints on how to solve this?
> Do I need to change something?
> Is m-assembly-p the right way to create an archive containing resources
> that are shared between other applications?
>
>
>
> Regards
>
> Thorsten
> _______________________________________________
> m2e-users mailing list
> m2e-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
>
https://dev.eclipse.org/mailman/listinfo/m2e-users
>

>
> --

> "Have you tried turning it off and on again" - The IT Crowd
> _______________________________________________
> m2e-users mailing list
> m2e-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
>
https://dev.eclipse.org/mailman/listinfo/m2e-users

Back to the top