Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 0.0.12
-
Fix Version/s: 0.9.3
-
Component/s: Maven Launcher
-
Labels:None
-
Environment:Eclipse 3.2.2, jre1.5.0_11 (jdk -jre1.5.0-11), Windows XP
Description
I would like to use project created with Maven Integration Plugin to be compiled using 'mvn compile' goal from Eclipse IDE, or from command line. My projects would require to use jdk 1.5 and up. Unfortunetly I can't do it without manually changing pom to use 'plexus-eclipse-compiler' plugin when I am trying to compile project in Eclipse IDE, or 'maven-compiler-plugin' when I would like to do it from command line. Is there any way to do it without changing manually pom before to execute mvn compile goal?
In Eclipse IDE I would always get an error(see build errors shown below) if I would not use 'plexus-eclipse-compiler' for mvn compile goal, and of course 'mvn compile from command line would not work with eclipse compiler. I tried to use -vm that you recomended in FAQ section, it doesn't work I am still getting an error (shown below) if I comented out 'plexus-eclipse-compiler' plugin
To reproduce an issue that I am seeing, I created very simple project and simplified set of dependencies to the minimum compare to the original project dependencies. See attached zip file.
So as you can see fom zip that project pom(simplified one) listed two compiler plugins: 'plexus-eclipse-compiler' and 'maven-compiler-plugin', and I have always manually comented one of the plugin to be able to compile without an error. So when I am using Eclipse IDE to avoid "can't find compiler error'' I would require to use plexus-eclipse-compiler and commented out maven-eclipse-compiler, or if I would like to use command line mvn compile for same project I need to comment out eclipse compiler plugin and us it maven compiler. So I can avoid manual modification of project pom, and got work maven compile either from Eclipse IDE or command line?
ERRORS:
[INFO] Build for project: myPureMaven:myPureMaven:jar:0.0.1-SNAPSHOT failed during execution of mojo: org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
org.apache.maven.ProjectBuildFailureException: Build for project: myPureMaven:myPureMaven:jar:0.0.1-SNAPSHOT failed during execution of mojo: org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:334)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:151)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:220)
at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:813)
at org.maven.ide.eclipse.embedder.Maven2Executor.main(Maven2Executor.java:85)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.5.0_11\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:578)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:508)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:328)
... 4 more
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Sun Dec 02 22:16:27 EST 2007
[INFO] Memory 0M/5M
[INFO] ------------------------------------------------------------------------
This is actually not a problem with the plugin but with the eclipse launcher. Here is the solution that worked for me (and maybe this should be added to the FAQ some place): FYI - I put in a bug for this issue as well a while ago and was told that it wasn't a problem with the plugin (which was correct but not well explained at the time).
Eclipse uses the default JRE when it launches. It locates it using whatever installation magic they both have, however its the wrong one for the the maven compiler plugin needs. To fix this try editing your eclipse.ini file and including the vm you want to use. Make sure it's before the -vmargs param or the launcher will think its an argument for the VM and not for the launcher. I have included a copy of my actual ini file which works (obviously restart eclipse after editing it):
==== eclipse.ini ====
-vm
C:\java\jdk1.6.0\jre\bin\client\jvm.dll
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=256m
=================
In case I've goofed and that doesn't work (a small possibility) I can tell you the only other thing I did befroe it worked was add a JAVA_HOME variable to:
Window -> Preferences -> General -> Workspace -> Linked Resources
I haven't removed it yet to check (too lazy and glad things are working) but I'm fairly sure that was not the fix that did the trick.