Details

    • Type: Bug
    • Status: In Progress
    • Priority: Critical
    • Resolution: Unresolved
    • Component/s: maven-plugin
    • Labels:
      None
    • Environment:
      Platform: All, OS: All

      Description

      Maven option specified through MAVEN_OPTS -DpropertyName=propertyValue has lower
      priority than property specified in the pom.xml itself.
      According to the Maven docs it should have higher priority.

        Activity

        Hide
        ulad ulad added a comment -

        http://maven.apache.org/maven-1.x/reference/command-line.html

        So, running same commands from command line and from hudson leads to different
        results.

        Show
        ulad ulad added a comment - http://maven.apache.org/maven-1.x/reference/command-line.html So, running same commands from command line and from hudson leads to different results.
        Hide
        kohsuke Kohsuke Kawaguchi added a comment -

        You are citing Maven1 documentation.

        Is there any chance you can create a test case? It's not obvious to me how such
        a behavior difference arises.

        Show
        kohsuke Kohsuke Kawaguchi added a comment - You are citing Maven1 documentation. Is there any chance you can create a test case? It's not obvious to me how such a behavior difference arises.
        Hide
        ulad ulad added a comment -

        Yes, the doc page is for Maven 1, but it applicable to Maven 2 too.
        I'm running Maven v2.0.9.

        Simple example i've created - i use next pom.xml
        <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">

        <properties>
        <hello>test</hello>
        </properties>

        <modelVersion>4.0.0</modelVersion>
        <groupId>krysko</groupId>
        <artifactId>myapp</artifactId>
        <packaging>jar</packaging>
        <version>1.0-$

        {hello}

        </version>
        <name>myapp</name>
        </project>

        Running command "mvn clean package" from the command line gives me
        myapp-1.0-test.jar, and running "mvn clean package -Dhello=lalala" gives me
        myapp-1.0-lalala.jar.

        Running this pom from hudson without options creates myapp-1.0-test.jar (as
        expected), and after adding -Dhello=lalala to the MAVEN_OPTS section hudson
        still builds myapp-1.0-test.jar.

        I've observed (in debug mode) the command line hudson use to run maven, in
        private ArgumentListBuilder buildMavenCmdLine(BuildListener listener,int
        tcpPort) method when I run it WITH -Dhello=lalala specified, and it gives me this:
        E:\Java\jdk1.6.0_06/bin/java -Dhello=lalala -cp
        E:\Java\apache-tomcat-5.5.23\webapps\hudson\WEB-INF\lib\maven-agent-1.243.jar;
        E:\Java\apache-maven-2.0.9\boot\classworlds-1.1.jar
        hudson.maven.agent.Main E:\Java\apache-maven-2.0.9
        E:\Java\apache-tomcat-5.5.23\webapps\hudson\WEB-INF\lib\remoting-1.243.jar
        E:\Java\apache-tomcat-5.5.23\webapps\hudson\WEB-INF\lib\maven-interceptor-1.243.jar
        2953

        Any ideas?
        Thank you.

        Show
        ulad ulad added a comment - Yes, the doc page is for Maven 1, but it applicable to Maven 2 too. I'm running Maven v2.0.9. Simple example i've created - i use next pom.xml <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 "> <properties> <hello>test</hello> </properties> <modelVersion>4.0.0</modelVersion> <groupId>krysko</groupId> <artifactId>myapp</artifactId> <packaging>jar</packaging> <version>1.0-$ {hello} </version> <name>myapp</name> </project> Running command "mvn clean package" from the command line gives me myapp-1.0-test.jar, and running "mvn clean package -Dhello=lalala" gives me myapp-1.0-lalala.jar. Running this pom from hudson without options creates myapp-1.0-test.jar (as expected), and after adding -Dhello=lalala to the MAVEN_OPTS section hudson still builds myapp-1.0-test.jar. I've observed (in debug mode) the command line hudson use to run maven, in private ArgumentListBuilder buildMavenCmdLine(BuildListener listener,int tcpPort) method when I run it WITH -Dhello=lalala specified, and it gives me this: E:\Java\jdk1.6.0_06/bin/java -Dhello=lalala -cp E:\Java\apache-tomcat-5.5.23\webapps\hudson\WEB-INF\lib\maven-agent-1.243.jar; E:\Java\apache-maven-2.0.9\boot\classworlds-1.1.jar hudson.maven.agent.Main E:\Java\apache-maven-2.0.9 E:\Java\apache-tomcat-5.5.23\webapps\hudson\WEB-INF\lib\remoting-1.243.jar E:\Java\apache-tomcat-5.5.23\webapps\hudson\WEB-INF\lib\maven-interceptor-1.243.jar 2953 Any ideas? Thank you.
        Hide
        bfos bfos added a comment -

        I think I'm seeing similar behavior, though not within the pom, but for filtered resources.

        If my pom looks like this:
        ...
        <properties>
        <build.number>localdev</build.number>
        </properties>

        <build>
        <finalName>something.$

        {build.number}</finalName>
        <resources>
        <resource>
        <directory>${basedir}/src/main/resources-filtered</directory>
        <filtering>true</filtering>
        </resource>
        </resources>
        ...

        A version.properties file in resources-filtered looks like this:
        buildNumber=${build.number}

        On the command line, mvn clean package -Dbuild.number=10, results in the proper final name
        (something.10), and version.properties is changed to buildNumber=10.

        However, if I set up a hudson job with maven goals: clean package -
        DbuildNumber=$

        {env.BUILD_NUMBER}

        , the final name is correct (something.10) but the
        version.properties is incorrect (buildNumber=localdev).

        Show
        bfos bfos added a comment - I think I'm seeing similar behavior, though not within the pom, but for filtered resources. If my pom looks like this: ... <properties> <build.number>localdev</build.number> </properties> <build> <finalName>something.$ {build.number}</finalName> <resources> <resource> <directory>${basedir}/src/main/resources-filtered</directory> <filtering>true</filtering> </resource> </resources> ... A version.properties file in resources-filtered looks like this: buildNumber=${build.number} On the command line, mvn clean package -Dbuild.number=10, results in the proper final name (something.10), and version.properties is changed to buildNumber=10. However, if I set up a hudson job with maven goals: clean package - DbuildNumber=$ {env.BUILD_NUMBER} , the final name is correct (something.10) but the version.properties is incorrect (buildNumber=localdev).

          People

          • Assignee:
            Unassigned
            Reporter:
            ulad ulad
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: