https://issues.apache.org/bugzilla/show_bug.cgi?id=49162

           Summary: incorrect duplicated project name warning when imports
                    from URL-providing resource
           Product: Ant
           Version: 1.8.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: [email protected]
        ReportedBy: [email protected]


I'am interesting in the new feature comes from ant 1.8.0:

"<import> can now import from any file- or URL-providing resource - this
includes <javaresource>."

Yesteday I had a try to import URL-providing ant xml file, I had some ant build
files like this :

-root of product
    - commom/
        + common.xml
        + ivy.xml
        + publish.xml
    - project1
        + build.xml
    - project2
        + build.xml

The build.xml files in project1/2/3/4... import the common.xml file, and
common.xml file imports all other xml files in common directory. This is very
common for multiple projects to share the common build targets.

These ant build file work well when I use normal file import. But when I move
common directory and all the ant xml file to a jar and then in
project1/2/3/4... import this common.xml as URL-providing resource. These ant
builf file work well except a warnning in ant log:

"Duplicated project name in import. Project *** defined first in **** and again
in null"

I'm sure that all the project name are not Duplicated.

And this warning will only appear in this specifical case: using <buildlist> to
get a build files list of project1/2/3/4...  and then execute the target in
each build file. If only one project's build.xml, this warning would not
happen.

I have download the source code of ant 1.8 and found the reason of this
warning:

1. in org.apache.tools.ant.helper.ProjectHelper2

                if (context.isIgnoringProjectTag() &&
!dupFile.equals(context.getBuildFile())) {
                    project.log("Duplicated project name in import. Project "
                            + context.getCurrentProjectName() + " defined first
in " + dup
                            + " and again in " + context.getBuildFile(),
Project.MSG_WARN);
                }

    Compare to the warning log "and again in null", we can know that 
context.getBuildFile() would return null. In this case,
!dupFile.equals(context.getBuildFile()) would always return true and cause the
incorrect warning.

2. in org.apache.tools.ant.helper.AntXMLContext

    public void setBuildFile(File buildFile) {
        this.buildFile = buildFile;
        ......
    }

    /**
     * @since Ant 1.8.0
     */
    public void setBuildFile(URL buildFile) throws MalformedURLException {
        this.buildFileURL = buildFile;
        ........
    }

    public File getBuildFile() {
        return buildFile;
    }

    Now we can see that if we use URL import, the setBuildFile(URL buildFile)
method will be invoked but it will set attibute buildFileURL, not attibute 
buildFile, so the method getBuildFile() will always return null.

    I think this would be a bug, the check logic for duplicated project name
would be updated for the new fearture URL-providing import added in ant 1.8.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to