Issue Details (XML | Word | Printable)

Key: MANTRUN-62
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Corporate Gadfly
Votes: 7
Watchers: 7
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Antrun Plugin

line.separator property not passed properly to ant

Created: 21/Nov/06 02:30 PM   Updated: Wednesday 03:11 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.4

Time Tracking:
Not Specified

File Attachments: 1. XML File build.xml (0.3 kB)
2. XML File pom.xml (2 kB)

Environment: maven 2.0.4


 Description  « Hide
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?


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Corporate Gadfly added a comment - 21/Nov/06 02:33 PM
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>

Basil James Whitehouse III added a comment - 06/Sep/07 02:04 PM
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?


Basil James Whitehouse III added a comment - 06/Sep/07 02:07 PM
Pardon my ignorance, I missed MANTRUN-40 and MANTRUN-64 which seem to describe my issue. (Learn to search JIRA istead of using google =)

Carlos Sanchez added a comment - 15/Jul/08 05:19 PM
The need to pass all properties in covered in MANTRUN-40

Paul Gier added a comment - 01/Jul/09 03:11 PM
This seems to be fixed now. Possibly as a result of MANTRUN-40