Something along these lines is documented in the Wiki: http://docs.codehaus.org/display/MAVENUSER/Compile+and+Test+with+Different+JDK+Versions
My suggestion would be to simply upgrade to JDK5 for all projects (set JAVA_HOME etc), and then specify <source/> and <target/> so your 1.5 compiler uses 1.4 targets etc. Wayne On 4/20/07, Petr V. <[EMAIL PROTECTED]> wrote:
If I change environment variable JAVA_HOME to point to jdk1.5, I can run my tests but I can not change it because many applications are dependent on jdk1.4. I defined the property JAVA_HOME in profile if maven could pick value of JAVA_HOME from there but no luck. Is there any way to ask mvn to run the tests with jdk 1.5 as we asked mvn to compile with jdk 1.5 ? Thanks Petr "Petr V." <[EMAIL PROTECTED]> wrote: Thanks Wayne, I was able to compile code then I issued mvn package and it tried to run tests and I got [INFO] [surefire:test] [INFO] Surefire report directory: C:\P4\NCP\main\component\CPServer\core\target\surefire-reports org.apache.maven.surefire.booter.SurefireExecutionException: com/comp/cp/CompanyDaoTest (Unsupported major.minor version 49.0); nested exception is java.lang.UnsupportedClassVersionError: com/comp/cp/CompanyDaoTest (Unsupported major.minor version 49.0) java.lang.UnsupportedClassVersionError: com/comp/cp/CompanyDaoTest (Unsupported major.minor version 49.0) So unsupported error has come I guess because I compiled code with jdk1.5 and my system has jre1.4 as well as jre 1.5 so I guess it is trying to use jre1.4 to run the test. How can I ask mvn to use jre 1.5 to run the tests Thanks Wayne Fay wrote: This is asked and answered repeatedly on this list, plus it is very well documented on the Maven website. http://maven.apache.org Plugins by category "compile" plugin At the bottom of that page is a couple links to example configs for specifying JDKs etc. Wayne On 4/20/07, Petr V. wrote: > All, > > I have this project which successfully build with jdk1.5. > > Now I am trying to make project on build machine. This build machine does not have access to outside world so I copied all dependencies in C:\maven_repository and define the repository location in m2 folder. I hope it won't complain. > > Now this build machine has jdk1.4 and seems like that I can not use that and mvn 2 needs 1.5. My other projects want 1.4 . > > So even if Installed jdk1.5, how can I tell mvn to use jdk1.5 and not jdk 1.4. > > Any help is appreciated. Log is attached if the error is due to some other reason. Please have a look. Thanks > > > > > > C:\P4\NCP\main>mvn -e compile > + Error stacktraces are turned on. > [INFO] Scanning for projects... > [INFO] Reactor build order: > [INFO] The New CP Project > [INFO] component > [INFO] CPServer > [INFO] Authentication Module > [INFO] Core Module > [INFO] Authorization Module > [INFO] Inventory Module > [INFO] Performance Module > [INFO] CPWebService > [INFO] ---------------------------------------------------------------------------- > [INFO] Building The New CP Project > [INFO] task-segment: [compile] > [INFO] ---------------------------------------------------------------------------- > [INFO] No goals needed for project - skipping > [INFO] ---------------------------------------------------------------------------- > [INFO] Building component > [INFO] task-segment: [compile] > [INFO] ---------------------------------------------------------------------------- > [INFO] No goals needed for project - skipping > [INFO] ---------------------------------------------------------------------------- > [INFO] Building CPServer > [INFO] task-segment: [compile] > [INFO] ---------------------------------------------------------------------------- > [INFO] No goals needed for project - skipping > [INFO] ---------------------------------------------------------------------------- > [INFO] Building Authentication Module > [INFO] task-segment: [compile] > [INFO] ---------------------------------------------------------------------------- > [INFO] [resources:resources] > [INFO] Using default encoding to copy filtered resources. > Downloading: http://repo1.maven.org/maven2/axis/axis-jaxrpc/1.4/axis-jaxrpc-1.4.pom > [WARNING] Unable to get resource 'axis:axis-jaxrpc:pom:1.4' from repository central (http://repo1.maven.org/maven2) > [INFO] [compiler:compile] > [INFO] Compiling 2 source files to C:\P4\NCP\main\component\CPServer\authn\target\classes > [INFO] ------------------------------------------------------------------------ > [ERROR] BUILD FAILURE > [INFO] ------------------------------------------------------------------------ > [INFO] Compilation failure > Failure executing javac, but could not parse the error: > javac: invalid target release: 1.5 > Usage: javac > where possible options include: > -g Generate all debugging info > -g:none Generate no debugging info > -g:{lines,vars,source} Generate only some debugging info > -nowarn Generate no warnings > -verbose Output messages about what the compiler is doing > -deprecation Output source locations where deprecated APIs are used > -classpath Specify where to find user class files > -sourcepath Specify where to find input source files > -bootclasspath Override location of bootstrap class files > -extdirs Override location of installed extensions > -d Specify where to place generated class files > -encoding Specify character encoding used by source files > -source Provide source compatibility with specified release > -target Generate class files for specific VM version > -help Print a synopsis of standard options > > > > > Failure executing javac, but could not parse the error: > javac: invalid target release: 1.5 > Usage: javac > where possible options include: > -g Generate all debugging info > -g:none Generate no debugging info > -g:{lines,vars,source} Generate only some debugging info > -nowarn Generate no warnings > -verbose Output messages about what the compiler is doing > -deprecation Output source locations where deprecated APIs are used > -classpath Specify where to find user class files > -sourcepath Specify where to find input source files > -bootclasspath Override location of bootstrap class files > -extdirs Override location of installed extensions > -d Specify where to place generated class files > -encoding Specify character encoding used by source files > -source Provide source compatibility with specified release > -target Generate class files for specific VM version > -help Print a synopsis of standard options > > > > [INFO] ------------------------------------------------------------------------ > [INFO] Trace > org.apache.maven.BuildFailureException: Compilation failure > Failure executing javac, but could not parse the error: > javac: invalid target release: 1.5 > Usage: javac > where possible options include: > -g Generate all debugging info > -g:none Generate no debugging info > -g:{lines,vars,source} Generate only some debugging info > -nowarn Generate no warnings > -verbose Output messages about what the compiler is doing > -deprecation Output source locations where deprecated APIs are used > -classpath Specify where to find user class files > -sourcepath Specify where to find input source files > -bootclasspath Override location of bootstrap class files > -extdirs Override location of installed extensions > -d Specify where to place generated class files > -encoding Specify character encoding used by source files > -source Provide source compatibility with specified release > -target Generate class files for specific VM version > -help Print a synopsis of standard options > > > > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:560) > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480) > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459) > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311) > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278) > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:330) > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:123) > at org.apache.maven.cli.MavenCli.main(MavenCli.java:272) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) > at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) > at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) > at org.codehaus.classworlds.Launcher.main(Launcher.java:375) > Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure > Failure executing javac, but could not parse the error: > javac: invalid target release: 1.5 > Usage: javac > where possible options include: > -g Generate all debugging info > -g:none Generate no debugging info > -g:{lines,vars,source} Generate only some debugging info > -nowarn Generate no warnings > -verbose Output messages about what the compiler is doing > -deprecation Output source locations where deprecated APIs are used > -classpath Specify where to find user class files > -sourcepath Specify where to find input source files > -bootclasspath Override location of bootstrap class files > -extdirs Override location of installed extensions > -d Specify where to place generated class files > -encoding Specify character encoding used by source files > -source Provide source compatibility with specified release > -target Generate class files for specific VM version > -help Print a synopsis of standard options > > > > 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:420) > at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539) > ... 16 more > [INFO] ------------------------------------------------------------------------ > [INFO] Total time: 23 seconds > [INFO] Finished at: Fri Apr 20 11:41:02 PDT 2007 > [INFO] Final Memory: 5M/9M > [INFO] ------------------------------------------------------------------------ > > C:\P4\NCP\main> > > --------------------------------- > Ahhh...imagining that irresistible "new car" smell? > Check outnew cars at Yahoo! Autos. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos. --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
