using maven, what does the wtpversion mean in the Eclipse plugin?
wtp adds web application support to eclipse. If you want to develop Maven based web applications with Eclipse, you should rather use Eclipse m2eclipse plugin.
As for wtpversions, this link has a mapping of wtpversion and eclipse versions.
This is the abbreviation of Eclipse Web Tools Project and you can use in maven > pom.xml under the <build> tag:
<!-- Eclipse project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Always download and attach dependencies source code -->
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<!-- Avoid type mvn eclipse:eclipse -Dwtpversion=2.0 -->
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
From: How To Create A Web Application Project With Maven
Related
When I run my web app inside eclipse using tomcat 7 maven plugin, I want an additional context to be deployed to tomcat. On the production enviroment this context is mapped to a directory outside tomcat dir using a context configuration
<Context path="/userimages" docBase="C:/test/userimages">
</Context>
And by this way is available in
http://wwww.myhost.com/userimages/test.jpg
How I achive the same on the development enviroment of the webapp (eclipse, tomcat7 maven plugin)?
In other words I want the contents of that folder to be accessible through
http://localhost:8080/userimages
or
http://localhost:8080/myapp/userimages
You should configure tomcat7-maven-plugin plugin.
Try this way:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>your_app_context_path</path>
<uriEncoding>utf-8</uriEncoding>
</configuration>
</plugin>
Then all your urls should start with http://wwww.myhost.com/your_app_context_path/...
More optional parameters for tomcat7:run goal can be found at apache tomcat maven plugin document
I found a workaround that doesn't do exactly what I originally wanted (publish another context using the tomcat maven plugin) but it solves my problem in a way. I add a folder "userimages" in the webapp folder of the application and this folder is used when developing. I prevent this folder from getting in the war and thus in the production server by using the "maven-war-plugin" with the following configuration in the pom.xml
<build>
....
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<packagingExcludes>userimages/</packagingExcludes>
</configuration>
</plugin>
....
</plugins>
....
</build>
Check also here and here
I am building a project against the CrEme VM Library. I want to configure maven and eclipse, to build only against this JAR. But m2eclipse "Update Project configuration" automatically adds the "JRE System library". I can fix it, by removing it in eclipse project classpath, but i want to configure it only in the pom.xml (and not checkin the eclipse settings).
I tried to do this:
// ...
<dependency>
<groupId>ch.sbb.cis-infra.mobile</groupId>
<artifactId>vmclasses</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
// ...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.3</source>
<target>1.3</target>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<debug>off</debug>
<compilerArguments>
<bootclasspath>''</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
But still, m2eclipse adds the "JRE System Library [JRE_1.3]".
Compilation on command line is correct, but in eclipse I can't see compile problems.
How can I remove the JRE in eclipse using the pom.xml configuration?
(Eclipse Helios SR2, m2e plugin 0.12.1)
Well, IMHO (I'm not sure) JRE container in Eclipse is because of Java nature of the project, not the Maven integration. Try to disable Maven nature of the project and JRE will be still there. If you have Maven-managed Java project (and your POM says that) Java nature in Eclipse is enabled causing JRE to be attached to the project.
How can I add the Versions-Maven-Plugin to my Eclipse projects ??
I tried the Add Plugins menu option but it doesn't seem to be able to find the plugin.
To check maven plugin version in eclipse:
Click Window –> Preferences –> Maven –> Installation . It will show you installation window with Maven version.
You have to add the versions maven plugin into the reporting part of your pom to create appropriate reports about dependency updates.
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>1.3.1</version>
<reportSets>
<reportSet>
<reports>
<report>dependency-updates-report</report>
<report>plugin-updates-report</report>
<report>property-updates-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
You can not install the versions-maven-plugin in Eclipse, cause the version-maven-plugin is a Maven plugin and not a Eclipse plugin. But not an bad idea.
From reading A Java web project created with Maven is not recognized as such by Eclipse
I add the below plugin to pom.xml to convert my maven project to a web project :
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
</plugin>
I then run "Update Project Configuration" but the maven project is not converted to a web project.
If I run the command mvn eclipse:eclipse -Dwtpversion=2.0 the project is then updated. Should updating the .pom file not suffice to convert the maven project to a web project ?
It will not suffice. The plugin configuration needs to be executed, which will not happen by just loading/refreshing it in Eclipse. It gets executed when mvn eclipse:eclipse is run.
I assume we do not have m2e, which does not need this configuration anway.
Using eclipse 3.5, when I create a new maven project, m2eclipse automatically adds J2SE1.4 to libraries and Compiler Compliance Level to 1.4 (Project properties > Java Compiler).
My JRE system library is 1.6 and my default compiler compliance level is 1.6. I don't even have 1.4 installed.
Can I make m2eclipse use my default settings and prevent it from modifying project settings?
It should follow the maven-compiler-plugin configuration:
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
(even if, as mentioned in this thread, it won't work for aspect-j)
This thread reminds us about the difference between m2eclipse within eclipse, and a maven script:
One thing worth to mention that this only applies to "the development mode" when m2eclipse is configuring Eclipse tools such as JDT, AJDT and WTP according to the configuration from pom.xml. This is how you normally code and debug your application, run unit tests (with Run as... / JUnit test) or run on web app server (Run as... / Server app).
However if you use Run as... / Maven build..., or create corresponding launch config from the Run/Debug menu, then you can select JVM that is used to launch Maven and all your compiler configuration will be respected in the same way it is respected in the command line.
So:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
</plugin>
</plugins>
m2e does not (and cannot) use external java compiler, so it will just ignore these configuration parameters. m2 only considers source/target maven-compiler-plugin parameters.
The JDK compliance level is derived from the maven project, not the other way around. In other words, you need to configure the maven compiler plugin for 1.6 level compliance and then m2eclipse will derive the appropriate settings under Eclipse:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
The pom.xml is the master, not m2eclipse.
In summary I did an mvn eclipse:eclipse on the project and an F5 refresh of the project in Eclipse and this configured the Java compliance setting correctly.
My set-up as follows. Using Kepler. Java 1.7 configured as default in preferences in Eclipse (as mentioned already, seems to be ignored anyway in deference to whatever is found in the pom.xml). I imported a bunch of Maven projects into Eclipse. All showed up as Java compliance level 1.4 and even the build path of the projects lists the Java 1.4 runtime. I double checked 1.7 is correctly specified in the pom.xml by requesting the effective pom on the command line to confirm the setting is present and correct in the pom:
mvn help:effective-pom -Doutput=eff.xml
This showed the correct setting was present:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
</configuration>
</plugin>
Guessing the problem is with the import part of the m2e plugin, version showing in Eclipse is:
1.4.0.20130601-0317