Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4956

Cygwin mvn script modifies CLASSPATH environment variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0.3
    • Command Line
    • None
    • Cygwin on Windowx

    Description

      When running in Cygwin, the apache-maven-3.0/bin/mvn script actually changed the user env CLASSPATH to an invalid Java classpath value, which is unexpected! To repeat this, try the following on Cygwin:

      Create this simple pom.xml in an project:

      <?xml version="1.0" encoding="utf-8"?>
      <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>deng</groupId>
        <artifactId>mvn-examples</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-antrun-plugin</artifactId>
              <version>1.6</version>
              <configuration>
                <target>
                  <echo message="Maven env.CLASSPATH: ${env.CLASSPATH}" />
                </target>
              </configuration>
            </plugin>
          </plugins>
        </build>
      </project>
      
      $ /apps/apache-maven-3.0/bin/mvn -v
      Apache Maven 3.0 (r1004208; 2010-10-04 07:50:56-0400)
      Java version: 1.6.0_19
      Java home: C:\apps\jdk1.6.0_19\jre
      Default locale: en_US, platform encoding: Cp1252
      OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
      
      $ export CLASSPATH="C:\\my-classes;C:\\my-lib\app.jar"
      
      $ echo $CLASSPATH
      C:\my-classes;C:\my-lib\app.jar
      
      $ /apps/apache-maven-3.0/bin/mvn antrun:run
      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building mvn-examples 1.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-antrun-plugin:1.6:run (default-cli) @ mvn-examples ---
      [INFO] Executing tasks
      
      main:
           [echo] Maven env.CLASSPATH: /cygdrive/c/my-classes:/cygdrive/c/my-lib/app.jar
      [INFO] Executed tasks
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 0.843s
      [INFO] Finished at: Wed Dec 29 23:37:41 EST 2010
      [INFO] Final Memory: 2M/15M
      [INFO] ------------------------------------------------------------------------
      

      NOTE 1: The CLASSPATH value has been modified with cygwin path prefix, which become an invalid Java classpath value!
      NOTE 2: If I use mvn.bat in cygwin shell, it will work as expected. So this only affect the mvn shell script only.
      NOTE 3: This only affect the variable "CLASSPATH", b/c if I use JAVA_CLASSPATH, the value didn't change.

      Attachments

        Activity

          People

            bentmann Benjamin Bentmann
            saltnlight5 Zemian Deng
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: