Maven 2.x Antrun Plugin

line.separator property not passed properly to ant

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.4
  • Component/s: None
  • Labels:
    None
  • Environment:
    maven 2.0.4
  • Number of attachments :
    2

Description

line.separator does not resolve properly inside an ant task (using maven-antrun-plugin).

E.g., using the 2 attached files, running

ant
produces the following output
Buildfile: build.xml

echo:
     [echo] 
     [echo] line.separator: --
     [echo] --
     [echo] os.name: --Linux--
     [echo]         

BUILD SUCCESSFUL
Total time: 0 seconds

which is all okay, so far (new line is being shown on the echo line).

However, when using

mvn initialize
, we get the following output

[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Maven Echo
[INFO]    task-segment: [initialize]
[INFO] ----------------------------------------------------------------------------
[INFO] [antrun:run {execution: echo-no-properties}]
[INFO] Executing tasks

echo:
     [echo] 
     [echo] line.separator: --${line.separator}--
     [echo] os.name: --${os.name}--
     [echo]         
[INFO] Executed tasks
[INFO] [antrun:run {execution: echo-with-properties}]
[INFO] Executing tasks

echo:
     [echo] 
     [echo] line.separator: -- --
     [echo] os.name: --Linux--
     [echo]         
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Nov 21 15:26:55 EST 2006
[INFO] Final Memory: 3M/508M
[INFO] ------------------------------------------------------------------------

I have two questions:

  1. Why do I have to specify all the properties one-by-one while calling the target?
  2. Why is the output for line.separator not what is expected?
  1. build.xml
    21/Nov/06 2:30 PM
    0.3 kB
    Corporate Gadfly
  2. pom.xml
    21/Nov/06 2:30 PM
    2 kB
    Corporate Gadfly

Activity

Hide
Corporate Gadfly added a comment -

Here are the 2 attached files (inline for easy perusal):

build.xml
<?xml version="1.0"?>

<project name="line.separator" default="echo" basedir=".">
    <target name="echo" description="echo some messages">
        <echo>
line.separator: --${line.separator}--
os.name: --${os.name}--
        </echo>
    </target>
</project>
and
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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>ca.utoronto</groupId>
  <artifactId>echo-app</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Echo</name>
  <build>
      <plugins>
          <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <executions>
                  <execution>
                      <id>echo-no-properties</id>
                      <phase>initialize</phase>
                      <configuration>
                          <tasks>
                              <ant inheritRefs="true" inheritAll="true">
                                  <target name="echo"/>
                              </ant>
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
                  <execution>
                      <id>echo-with-properties</id>
                      <phase>initialize</phase>
                      <configuration>
                          <tasks>
                              <ant inheritRefs="true" inheritAll="true">
                                  <target name="echo"/>
                                  <property name="line.separator"
                                      value="${line.separator}"/>
                                  <property name="os.name"
                                      value="${os.name}"/>
                              </ant>
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>
      </plugins>
  </build>
</project>

Show
Corporate Gadfly added a comment - Here are the 2 attached files (inline for easy perusal):
build.xml
<?xml version="1.0"?>

<project name="line.separator" default="echo" basedir=".">
    <target name="echo" description="echo some messages">
        <echo>
line.separator: --${line.separator}--
os.name: --${os.name}--
        </echo>
    </target>
</project>
and
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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>ca.utoronto</groupId>
  <artifactId>echo-app</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Echo</name>
  <build>
      <plugins>
          <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <executions>
                  <execution>
                      <id>echo-no-properties</id>
                      <phase>initialize</phase>
                      <configuration>
                          <tasks>
                              <ant inheritRefs="true" inheritAll="true">
                                  <target name="echo"/>
                              </ant>
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
                  <execution>
                      <id>echo-with-properties</id>
                      <phase>initialize</phase>
                      <configuration>
                          <tasks>
                              <ant inheritRefs="true" inheritAll="true">
                                  <target name="echo"/>
                                  <property name="line.separator"
                                      value="${line.separator}"/>
                                  <property name="os.name"
                                      value="${os.name}"/>
                              </ant>
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>
      </plugins>
  </build>
</project>
Hide
Basil James Whitehouse III added a comment -

This seems similar to my experience. I can't find any documentation or an issue that precisely captures my issue, but this entry is the closest. Adding my comment here rather than creating another issue.

I started prototyping delegation to an ant script by writing the ant tasks inline with the plugins configuration. Once that worked I extracted the ant code to a separate build.xml and delegated to it using the ant task as suggested in the plugin documentation: "...it's encouraged to move all your Ant tasks to a build.xml file and just call it from the POM using Ant's <ant/> task.".

Wanting to use Maven as the source of configuration I made heavy use of the Maven properties (project.build.sourceDirectory, project.build.outputDirectory, etc). The Maven property reference worked fine when I was using the inlined task but failed once it was extracted to a build.xml file. I was hoping that the Maven properties would be passed to the ant build transparently, or as long as the inhertiAll attribute was true. It surprised me that they weren't and that I'd have to essentially alias each value I needed, causing a lot of extra work.

Is it possible to correct this behavior? Am I just missing something?

Show
Basil James Whitehouse III added a comment - This seems similar to my experience. I can't find any documentation or an issue that precisely captures my issue, but this entry is the closest. Adding my comment here rather than creating another issue. I started prototyping delegation to an ant script by writing the ant tasks inline with the plugins configuration. Once that worked I extracted the ant code to a separate build.xml and delegated to it using the ant task as suggested in the plugin documentation: "...it's encouraged to move all your Ant tasks to a build.xml file and just call it from the POM using Ant's <ant/> task.". Wanting to use Maven as the source of configuration I made heavy use of the Maven properties (project.build.sourceDirectory, project.build.outputDirectory, etc). The Maven property reference worked fine when I was using the inlined task but failed once it was extracted to a build.xml file. I was hoping that the Maven properties would be passed to the ant build transparently, or as long as the inhertiAll attribute was true. It surprised me that they weren't and that I'd have to essentially alias each value I needed, causing a lot of extra work. Is it possible to correct this behavior? Am I just missing something?
Hide
Basil James Whitehouse III added a comment -

Pardon my ignorance, I missed MANTRUN-40 and MANTRUN-64 which seem to describe my issue. (Learn to search JIRA istead of using google =)

Show
Basil James Whitehouse III added a comment - Pardon my ignorance, I missed MANTRUN-40 and MANTRUN-64 which seem to describe my issue. (Learn to search JIRA istead of using google =)
Hide
Carlos Sanchez added a comment -

The need to pass all properties in covered in MANTRUN-40

Show
Carlos Sanchez added a comment - The need to pass all properties in covered in MANTRUN-40
Hide
Paul Gier added a comment -

This seems to be fixed now. Possibly as a result of MANTRUN-40

Show
Paul Gier added a comment - This seems to be fixed now. Possibly as a result of MANTRUN-40

People

Vote (7)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: