| Summary: | Adding Maven Dependencies to Deployment Assembly for webapp causes "provided" jars to appear in war file. | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | apfryer |
| Component: | m2e | Assignee: | Project Inbox <m2e.core-inbox> |
| Status: | CLOSED NOT_ECLIPSE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | fbricon, hanriseldon, igor, rocky_mm |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
apfryer
You SHOULD NOT do step 3, because you basically tell WTP to deploy all maven dependencies, regardless of their scope. Any change to the project dependencies is automatically handled by the m2eclipse-wtp configurator, so you don't have to do anything, seriously. Your real problem is you probably didn't specify the war packaging, when asking maven to manadependencies ...accidentaly hit enter too soon on last comment, sorry.
so, you need to set the packaging to war in your pom.xml, and since your project probably uses eclipse's convention -your web resources sitting in /WebContent-, you should either move them to src/main/webapp or configure your maven war plugin :
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
After changing the packaging type or the maven-war-plugin configuration, you'll need to run Maven Update Configuration.
Finally, be aware that any WTP related issues should be opened at https://issues.sonatype.org/browse/MECLIPSEWTP
Thanks for your comments. In response, I already DID have the war packaging specified and am using the standard maven directory layout for a web app (ie. src/main/java/webapp ). Following your advice, I removed "Maven Dependencies" from the "Deployment Assembly" for my web app and recreated the war file using eclipse (wtp). Unfortunately none of the jar files specified in my pom.xml are included in the generated war file. I'm wondering if i have something configured incorrectly if you're so sure that the jar file dependencies SHOULD appear in the wtp created war file. If so, then I'm not seeing that and perhaps should raise a bug for that issue? I don't know if this is an eclipse wtp issue, m2e issue or user issue. You might also wonder why I want to build via wtp. The reason is so I can quickly test code changes and run them in a tomcat server setup inside eclipse. This requires the eclipse build of the war file to get the jar file dependencies correct. I suspect this would be a common feature alot of developers would want. I'm using Eclipse Helios with "Maven Integration for Eclipse" 0.12.0.20101115-1102. My pom.xml is below... <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.pokersquid</groupId> <artifactId>leaguemanager</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>leaguemanager Web App</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.openejb</groupId> <artifactId>javaee-api</artifactId> <version>6.0-SNAPSHOT</version> <type>jar</type> <scope>provided</scope> </dependency> <dependency> <groupId>com.pokersquid.leaguemanager</groupId> <artifactId>poker-entities</artifactId> <version>0.0.1-SNAPSHOT</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>com.pokersquid</groupId> <artifactId>poker-ejbs</artifactId> <version>0.0.1-SNAPSHOT</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.8.3</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <!-- Latest 2.3.x (not 2.4.x), at least 2.3.16 --> <version>[2.3.16,2.4)</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> <finalName>leaguemanager</finalName> </build> <repositories> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2</url> </repository> </repositories> </project> Given that m2e/wtp integration is not part of m2e, I am tempted to close this bug as NOT_ECLIPSE and create corresponding issue under https://issues.sonatype.org/browse/MECLIPSEWTP. Any objections? I can confirm this bug. If you are to close this bug and open a new one please provide link to new bug report. Thank you! After searching carefully for any related bugs in m2e/wtp integration issue tracker I have encountered and issue report that resolved my problem: https://issues.sonatype.org/browse/MNGECLIPSE-714 Basically, what resolves the problem is the installation of WTP integration plug-in, which takes care of exporting dependencies. I did manage to solve it like that, but isn't the problem the fact that Maven isn't managing the dependencies itself? I assumed what I did was a workaround, not the solution. I assume that WTP projects need special care when mavenized, hence the existence of the Maven WTP plugin. m2e-wtp and related bugs should be filed in https://issues.sonatype.org/browse/MECLIPSEWTP |