Bug 41701 - [PATCH] <import> should be able to load .xmls from classpath
Summary: [PATCH] <import> should be able to load .xmls from classpath
Status: RESOLVED DUPLICATE of bug 29251
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.0
Hardware: All All
: P2 enhancement (vote)
Target Milestone: 1.8.0
Assignee: Ant Notifications List
Keywords: PatchAvailable
: 44214 (view as bug list)
Depends on: 44239
  Show dependency tree
Reported: 2007-02-26 01:34 UTC by Gregory Mostizky
Modified: 2009-11-05 05:43 UTC (History)
2 users (show)

Patch file (10.06 KB, patch)
2007-02-26 01:37 UTC, Gregory Mostizky
Details | Diff
Updated patch with formatting preserved (6.25 KB, patch)
2007-02-27 05:33 UTC, Gregory Mostizky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gregory Mostizky 2007-02-26 01:34:01 UTC
Proposed patch enhances standart <import> task with following parameters:

<import resource="common-targets.xml"/>
Will import "common-targets.xml" from ant's classpath

<import resource="common-targets.xml" classpath="ant-common.jar"/>
Will import "common-targets.xml" from specified classpath, in this case


This patch will allow loading common targets/properties from pre-packaged jar.
This is useful when the build system for several projects shares some common
targets/properties and perhaps ant extensions, and this build system is used as
separate project to build a number of other projects.
Comment 1 Gregory Mostizky 2007-02-26 01:37:39 UTC
Created attachment 19635 [details]
Patch file
Comment 2 Gregory Mostizky 2007-02-26 01:38:21 UTC
The patch was done against SVN trunk revision: 511767
Comment 3 Steve Loughran 2007-02-26 08:04:09 UTC
This is useful; it is something we've discussed. However, we have two problems

1. how to specify the classpath (use case: dynamically load a build file from an
ivy downloaded JAR)

2. what the base dir of a project is in this situation

Regarding the patch -did you reformat the code before submitting it? That makes
it needlessly hard to determine what's changed. 

Please submit patches against the code without doing a format first. Apache has
very strict layout rules to stop this from happening.
Comment 4 Gregory Mostizky 2007-02-27 05:31:22 UTC
The enhanced <import> task allows specifying classpath from which to load the
resource. This classpath is resolved when <import> is executed. I am not
familiar with ivy so I am not sure if this solves the use case or not.

Regarding the base dir for imported project, I am not sure it can have any
meaningful value assigned when using <import resource=""/>. 

The way we use ant in our build system is to have one main build.xml responsible
for setting all project properties and then have it import individual .xmls that
each knows how to build a specific thing, such as XDoclet, Hibernate SQLs etc.. 

To borrow from OOP terminology, the imported projects are a kind of a "mixin"
projects that cannot function as a standalone projects on their own since they
depend on properties set by root build.xml, so not having base dir set for
imported .xmls is making sense in our use case. And this is the use case the
enhanced <import> allows.

Comment 5 Gregory Mostizky 2007-02-27 05:33:43 UTC
Created attachment 19644 [details]
Updated patch with formatting preserved

I've recreated the patch with formatting preserved.
Comment 6 Steve Loughran 2008-01-15 02:43:59 UTC
*** Bug 44214 has been marked as a duplicate of this bug. ***
Comment 7 Steve Loughran 2008-01-15 02:54:37 UTC
linking to the changes needed in the resources to start enabling this
Comment 8 Stefan Bodewig 2009-11-05 05:43:00 UTC
a resource on the classpath has an URL - and in svn trunk Ant's javaresoucre provides URLs, so right now

  <javaresource name="common-targets.xml">
    <classpath location="ant-common.jar"/>

should work

*** This bug has been marked as a duplicate of bug 29251 ***