You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2016/01/22 08:58:14 UTC

[Bug 58908] New: "ant.project.invoked-targets" is not available to top level tasks

https://bz.apache.org/bugzilla/show_bug.cgi?id=58908

            Bug ID: 58908
           Summary: "ant.project.invoked-targets" is not available to top
                    level tasks
           Product: Ant
           Version: 1.9.6
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: notifications@ant.apache.org
          Reporter: robert.flaherty@oracle.com

This property is not yet available to tasks outside of a target.  It is
currently set in Project.java:


    public void executeTargets(final Vector<String> names) throws
BuildException {
        setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
                        CollectionUtils.flattenToString(names));
        getExecutor().executeTargets(this, names.toArray(new
String[names.size()]));
    }


and should be easily pushed out to the caller, Main.java:


    setProperties(project);
    ...
    ProjectHelper.configureProject(project, buildFile);
    ...
    project.executeTargets(targets);


ahead of the configureProject() call which eventually executes the top-level
tasks.  I think it can just be appended to the setProperties() method, where it
already does:


    project.setUserProperty(MagicNames.ANT_FILE,
                            buildFile.getAbsolutePath());
    project.setUserProperty(MagicNames.ANT_FILE_TYPE,
                            MagicNames.ANT_FILE_TYPE_FILE);

like:


    project.setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
                            CollectionUtils.flattenToString(targets));

Tried:

<project name="test" default="foobar">
    <echo message="${ant.project.default-target}" />
    <echo message="${ant.project.invoked-targets}" />
    <echo message="${ant.file}" />
    <echo message="${ant.file.type}" />
    <target name="foobar">
    </target>
</project>

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 58908] "ant.project.invoked-targets" is not available to top level tasks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58908

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Stefan Bodewig <bo...@apache.org> ---
almost.

There is the special case of having no target specified at the command line at
all - in this case Main adds the project's default target to the list which
isn't known before configureProject has been invoked.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 58908] "ant.project.invoked-targets" is not available to top level tasks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58908

--- Comment #2 from Robert Flaherty <ro...@oracle.com> ---
I saw that code in Main.java which could have been hoisted up, but since the
invocation on the command-line was nothing, I'd think that the property would
be empty since "ant.project.default-target" is available to the user.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 58908] "ant.project.invoked-targets" is not available to top level tasks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58908

--- Comment #3 from Stefan Bodewig <bo...@apache.org> ---
Well, that's the contract of the property.

Of course there is no such contract for top level tasks right now, so we could
set the property and overwrite it later before invoking the regular targets.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 58908] "ant.project.invoked-targets" is not available to top level tasks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58908

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |1.9.7

--- Comment #4 from Stefan Bodewig <bo...@apache.org> ---
implemented with git commit 494e865

-- 
You are receiving this mail because:
You are the assignee for the bug.