You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Hilco Wijbenga <hi...@gmail.com> on 2006/09/27 02:50:09 UTC

Java system properties not set?

Hi all,

I ran into something funny. I created a very simple Ant build:

build.xml:
<project>
        <echoproperties/>
        <echo>${user.home}</echo>
</project>

Running 'ant' yields lots of properties and it prints my home
directory, as expected.

Buildfile: build.xml
[echoproperties] #Ant properties
[echoproperties] #Tue Sep 26 17:45:52 PDT 2006
[echoproperties] java.runtime.name=Java(TM) 2 Runtime Environment,
Standard Edition
:
<snip/>
:
[echoproperties] user.home=/home/userid
:
<snip/>
:
[echoproperties] sun.cpu.isalist=
     [echo] /home/userid

BUILD SUCCESSFUL
Total time: 0 seconds

I then tried to set up Maven2 as a wrapper around this Ant build.

pom.xml:
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>a</groupId>
    <artifactId>a</artifactId>
    <version>1</version>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <ant/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>optional</artifactId>
                        <version>1.5.4</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

Running 'mvn package' yields surprisingly little output:
[INFO] Scanning for projects...
:
<snip/>
:
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
[echoproperties] #Ant properties
[echoproperties] #Tue Sep 26 17:42:31 PDT 2006
[echoproperties] ant.file=/home/userid/maven_puzzle/build.xml
[echoproperties] ant.file.null=/home/userid/maven_puzzle/build.xml
[echoproperties] ant.project.name=DummyProject
[echoproperties] ant.java.version=1.4
[echoproperties] basedir=/home/userid/maven_puzzle
     [echo] ${user.home}
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Sep 26 17:42:31 PDT 2006
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------

None of the Java system properties are available! Does anyone know why
this is happening? Am I missing an Ant dependency (I thought this was
core Ant functionality)?

Very puzzled,
Hilco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Java system properties not set?

Posted by Hilco Wijbenga <hi...@gmail.com>.
Hi all,

I kinda worked around it for the user.home property by doing (in pom.xml)

<ant>
    <property name="user.home" value="${user.home}"/>
</ant>

This makes the user.home property available to Ant. Doesn't anyone no
a better solution?

I also tried to add a simple <javac> in my build.xml but running the
build now gives a very unpleasant error:

<snip/>
:
[INFO] Executing tasks
     [echo] JAVA_HOME="/home/userid/bin/jdk/current"

all:
    [javac] Compiling 1 source file to /home/userid/maven_puzzle/target/classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing ant tasks

Embedded error: The following error occurred while executing this line:
/home/userid/maven_puzzle/build.xml:12: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
:
<snip/>

Obviously, JAVA_HOME is just fine. And the Ant build works like a
charm outside of Maven. Running with --debug doesn't reveal anything
useful.

I'd *really* appreciate some help. I'm sure I'm forgetting something
obvious as this should be really simple. I get the impression that my
classpath is incomplete (tools.jar is missing?) but I would expect the
antrun plugin to take care of that? And that still leaves the missing
Java system properties.

And here I was thinking that just wrapping the Maven build around the
existing Ant build wouldn't take much longer than a few minutes. :-)

Cheers,
Hilco

On 9/26/06, Hilco Wijbenga <hi...@gmail.com> wrote:
> Hi all,
>
> I ran into something funny. I created a very simple Ant build:
>
> build.xml:
> <project>
>         <echoproperties/>
>         <echo>${user.home}</echo>
> </project>
>
> Running 'ant' yields lots of properties and it prints my home
> directory, as expected.
>
> Buildfile: build.xml
> [echoproperties] #Ant properties
> [echoproperties] #Tue Sep 26 17:45:52 PDT 2006
> [echoproperties] java.runtime.name=Java(TM) 2 Runtime Environment,
> Standard Edition
> :
> <snip/>
> :
> [echoproperties] user.home=/home/userid
> :
> <snip/>
> :
> [echoproperties] sun.cpu.isalist=
>      [echo] /home/userid
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
> I then tried to set up Maven2 as a wrapper around this Ant build.
>
> pom.xml:
> <project>
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>a</groupId>
>     <artifactId>a</artifactId>
>     <version>1</version>
>     <build>
>         <plugins>
>             <plugin>
>                 <artifactId>maven-antrun-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <phase>package</phase>
>                         <configuration>
>                             <tasks>
>                                 <ant/>
>                             </tasks>
>                         </configuration>
>                         <goals>
>                             <goal>run</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                 <dependencies>
>                     <dependency>
>                         <groupId>ant</groupId>
>                         <artifactId>optional</artifactId>
>                         <version>1.5.4</version>
>                     </dependency>
>                 </dependencies>
>             </plugin>
>         </plugins>
>     </build>
> </project>
>
> Running 'mvn package' yields surprisingly little output:
> [INFO] Scanning for projects...
> :
> <snip/>
> :
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
> [echoproperties] #Ant properties
> [echoproperties] #Tue Sep 26 17:42:31 PDT 2006
> [echoproperties] ant.file=/home/userid/maven_puzzle/build.xml
> [echoproperties] ant.file.null=/home/userid/maven_puzzle/build.xml
> [echoproperties] ant.project.name=DummyProject
> [echoproperties] ant.java.version=1.4
> [echoproperties] basedir=/home/userid/maven_puzzle
>      [echo] ${user.home}
> [INFO] Executed tasks
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 2 seconds
> [INFO] Finished at: Tue Sep 26 17:42:31 PDT 2006
> [INFO] Final Memory: 4M/8M
> [INFO] ------------------------------------------------------------------------
>
> None of the Java system properties are available! Does anyone know why
> this is happening? Am I missing an Ant dependency (I thought this was
> core Ant functionality)?
>
> Very puzzled,
> Hilco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org