A little background first.
I've been using Maven even before the 1.0 release, and have been very happy
with it. I've created very complex builds and have a very good working
knowledge of Maven 1.x. The structure I describe below, is precisely how
I've successfully built projects with Maven 1.x countless times.

I'm starting a whole new project, and would like to see if Maven 2 is going
to be something I want to use.

Now on to my problem. Maven 2 cannot find the Javac Compiler that I believe
I pointed it to.

I'm running the latest Maven download, version 2.0, on Windows XP

I've created two project modules :

csi_build
csi_common

csi_common  contains my first simple project I'd like to build with Maven 2

csi_build  contains my Maven 2 binaries, AND a number of JDKs I use for
builds. I store my JDKs in version control (Subversion), as some deployments
require different versions of the JDK and because I want anyone to be able
to pull down the latest code from the repository and immediately be able to
execute a build, even if they don't have the JDK installed.

I simply go to the csi_common directory and execute the following build.batfile
===============================================
echo off
set
JAVA_HOME=C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\jdk\jdk1.5.0_04
set
MAVEN_HOME=C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\maven\maven-2.0
set PATH=%JAVA_HOME%\bin;%MAVEN_HOME%\bin;%PATH%
echo PATH=%PATH%
mvn package -e
===============================================

Here's my simple pom.xml for csi_common
===============================================
<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/maven-v4_0_0.xsd";>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.csi.common</groupId>
  <artifactId>csi_common</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Quick Start Archetype</name>
  <url>http://maven.apache.org</url>
  <build>
      <sourceDirectory>src/java</sourceDirectory>
  </build>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
===============================================

The output complains "Unable to locate the Javac Compiler in:
C:\jre1.5.0_04\..\lib\tools.jar"
Here's the output:
===============================================
C:\CSI\eclipse_workspaces\CSI\csi_common>echo off
PATH=C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\jdk\jdk1.5.0_04\bin;
C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\maven\maven-2.0\bin;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
----------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype
[INFO]    task-segment: [package]
[INFO]
----------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 4 source files to
C:\CSI\eclipse_workspaces\CSI\csi_common\target\classes
[INFO]
----------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]
----------------------------------------------------------------------------
[INFO] Compilation failure

Unable to locate the Javac Compiler in:
  C:\jre1.5.0_04\..\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.

[INFO]
----------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
DefaultLifecycleExecutor.java:540)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle
(DefaultLifecycleExecutor.java:469)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(
DefaultLifecycleExecutor.java:448)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:301)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
DefaultLifecycleExecutor.java:268)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(
DefaultLifecycleExecutor.java:137)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:113)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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
    at org.apache.maven.plugin.AbstractCompilerMojo.execute(
AbstractCompilerMojo.java:429)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:110)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(
DefaultPluginManager.java:399)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
DefaultLifecycleExecutor.java:519)
    ... 16 more
[INFO]
----------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Dec 02 08:50:54 CST 2005
[INFO] Final Memory: 3M/6M
[INFO]
----------------------------------------------------------------------------
===============================================

Why in the world is the Maven code looking for anything in C:\jre1.5.0_04
???

if I issue "set JAVA_HOME" from the command line, I get:
===============================================
C:\CSI\eclipse_workspaces\CSI\csi_common>set JAVA_HOME
JAVA_HOME=C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\jdk\jdk1.5.0_04
===============================================

and here's my path:
===============================================
C:\CSI\eclipse_workspaces\CSI\csi_common>set PATH
Path=C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\jdk\jdk1.5.0_04\bin;
C:\CSI\eclipse_workspaces\CSI\csi_build\src\tools\maven\maven-2.0\bin;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
===============================================

Also, if I issue "javac" from the command line, I get:
===============================================
C:\CSI\eclipse_workspaces\CSI\csi_common>javac
Usage: javac <options> <source files>
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 <path>          Specify where to find user class files
  -cp <path>                 Specify where to find user class files
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -d <directory>             Specify where to place generated class files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified
release
  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
===============================================

So, I KNOW javac is in the path.

Can anyone shed some light on what I may be doing wrong?

Sincerely,
Matthew Wheaton

Reply via email to