You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by jonathan doklovic <jd...@sysbliss.com> on 2008/01/11 18:07:23 UTC

import file from jar (or classpath)

Hi,

I know there's not currently a way to do this, but I think it would be
very helpful to be able to use the import task to import a file from a
jar.

This way, when I have a handful of projects, all with common targets, I
can put the common.xml build file in a jar and have each project depend
on that jar.

Combined with something like ivy, I think this would be a pretty good
way to share common targets among multiple projects that may not have
anything to do with each other.

Any thoughts?

Any way to do this now?

- Jonathan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import file from jar (or classpath)

Posted by Steve Loughran <st...@apache.org>.
jonathan doklovic wrote:
> [this should probably move to the dev list?]

yes

> After writing the patch for the import task, I also noticed that DefBase
> includes most of the methods needed to load a classpath resource,
> however, it extends AntlibDefinition. I think it would be a useful
> refactoring to create a ResourceBase that other classes including
> AntLibDefinition can subclass when the task needs to load a classpath
> resource.
> 


seems reasonable..classpath loading is so common it should be a base 
type independent of most others.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import file from jar (or classpath)

Posted by jonathan doklovic <jd...@sysbliss.com>.
[this should probably move to the dev list?]

After writing the patch for the import task, I also noticed that DefBase
includes most of the methods needed to load a classpath resource,
however, it extends AntlibDefinition. I think it would be a useful
refactoring to create a ResourceBase that other classes including
AntLibDefinition can subclass when the task needs to load a classpath
resource.

- Jonathan

On Mon, 2008-01-14 at 13:14 +0000, Steve Loughran wrote:
> jonathan doklovic wrote:
> > Hi,
> > 
> > I know there's not currently a way to do this, but I think it would be
> > very helpful to be able to use the import task to import a file from a
> > jar.
> > 
> > This way, when I have a handful of projects, all with common targets, I
> > can put the common.xml build file in a jar and have each project depend
> > on that jar.
> > 
> > Combined with something like ivy, I think this would be a pretty good
> > way to share common targets among multiple projects that may not have
> > anything to do with each other.
> > 
> > Any thoughts?
> > 
> > Any way to do this now?
> > 
> 
> this has been discussed for a while, and its something I'd like to do 
> for Ant1.8...I've started making some of the changes in uncommitted 
> code, primarily working on the base interfaces.
> 
> The goal would be to let you import any suitable resource, be it 
> something on a classpath, remote URL, etc.
> 
> Before we can do that, bear in mind that when you import a file, it has 
> a location, that can be used for relative locations. If I import a bit 
> of xml from org,example.somewhere, that file should have the right to 
> import ../something/else.xml. Same for URL-based imports. The code you 
> import should not have to know how you found it, to pull in relative files.
> 
> What I'm planning for this is a new interface for some resources to 
> support, a RelativeResourceFactory. Resources that implement it can 
> create new relative resources by taking in the current location and a 
> relative path. We'd retrofit this to file, URL and classpath resources, 
> all of which could then be a resource source.
> 
> -steve
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import file from jar (or classpath)

Posted by Steve Loughran <st...@apache.org>.
jonathan doklovic wrote:
> Hi,
> 
> I know there's not currently a way to do this, but I think it would be
> very helpful to be able to use the import task to import a file from a
> jar.
> 
> This way, when I have a handful of projects, all with common targets, I
> can put the common.xml build file in a jar and have each project depend
> on that jar.
> 
> Combined with something like ivy, I think this would be a pretty good
> way to share common targets among multiple projects that may not have
> anything to do with each other.
> 
> Any thoughts?
> 
> Any way to do this now?
> 

this has been discussed for a while, and its something I'd like to do 
for Ant1.8...I've started making some of the changes in uncommitted 
code, primarily working on the base interfaces.

The goal would be to let you import any suitable resource, be it 
something on a classpath, remote URL, etc.

Before we can do that, bear in mind that when you import a file, it has 
a location, that can be used for relative locations. If I import a bit 
of xml from org,example.somewhere, that file should have the right to 
import ../something/else.xml. Same for URL-based imports. The code you 
import should not have to know how you found it, to pull in relative files.

What I'm planning for this is a new interface for some resources to 
support, a RelativeResourceFactory. Resources that implement it can 
create new relative resources by taking in the current location and a 
relative path. We'd retrofit this to file, URL and classpath resources, 
all of which could then be a resource source.

-steve

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import file from jar (or classpath)

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Which up and coming Ant release will this be included?  I have a real 
need for this as I have many Ant XML files that would be better suited 
to live in  a Jar and be Ivy-tized ;)

kermitt wrote:
> This is really good progress. Is there any technical issue to enable remote
> ant build file by http or whatever?
> The goal is to enable to start writting a build just referencing a remote
> build file (may be cached in a temp that would be used if remote
> unavailable) and to share build among several project easily...
>
>
>
> jonathan doklovic-2 wrote:
>   
>> I added a bug to the bug database and attached a patch that adds the
>> same classpath functionality as taskdef to the import task.
>>
>> http://issues.apache.org/bugzilla/show_bug.cgi?id=44214
>>
>> - Jonathan
>>
>> On Fri, 2008-01-11 at 09:40 -0800, kermitt wrote:
>>     
>>> In a previous post I suggest this:
>>>
>>> I wish Ant import would support URL + jar like that :
>>>
>>> <project ...>
>>>    <import url="http://repo/build.jar!common-build.xml"/>
>>> </project>
>>>
>>> As ivy became a sub project, it would make sense to have a closer
>>> integration like :
>>>
>>> <project ...>
>>>    <import url="ivy://settings.xml:org/module/artifact@MyResolver" />
>>> <!--
>>> would locate the settings.xml file and seek a build-common.xml file using
>>> MyResolver resolver.
>>> -->
>>> </project>
>>>
>>> we could imagine deeper integration :
>>>
>>> <project ...>
>>>    <import url="ivy://settings.xml:org/module/artifact@MyResolver"
>>> ivyFile="${basedir]/ivy.xml"/>
>>> <!--
>>> configure ivy / read the ivy file
>>> would map each ivy configuration to a path ( path could use a lazy
>>> resolve
>>> proxy: resolve only when it get used)
>>> would import resolved artifcat as an ant build file
>>>
>>> -->
>>> </project> 
>>>
>>> jonathan doklovic-2 wrote:
>>>       
>>>> Hi,
>>>>
>>>> I know there's not currently a way to do this, but I think it would be
>>>> very helpful to be able to use the import task to import a file from a
>>>> jar.
>>>>
>>>> This way, when I have a handful of projects, all with common targets, I
>>>> can put the common.xml build file in a jar and have each project depend
>>>> on that jar.
>>>>
>>>> Combined with something like ivy, I think this would be a pretty good
>>>> way to share common targets among multiple projects that may not have
>>>> anything to do with each other.
>>>>
>>>> Any thoughts?
>>>>
>>>> Any way to do this now?
>>>>
>>>> - Jonathan
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>> For additional commands, e-mail: user-help@ant.apache.org
>>>>
>>>>
>>>>
>>>>         
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>>     
>
>   

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros


Re: import file from jar (or classpath)

Posted by kermitt <he...@genesys.com>.
This is really good progress. Is there any technical issue to enable remote
ant build file by http or whatever?
The goal is to enable to start writting a build just referencing a remote
build file (may be cached in a temp that would be used if remote
unavailable) and to share build among several project easily...



jonathan doklovic-2 wrote:
> 
> I added a bug to the bug database and attached a patch that adds the
> same classpath functionality as taskdef to the import task.
> 
> http://issues.apache.org/bugzilla/show_bug.cgi?id=44214
> 
> - Jonathan
> 
> On Fri, 2008-01-11 at 09:40 -0800, kermitt wrote:
>> In a previous post I suggest this:
>> 
>> I wish Ant import would support URL + jar like that :
>> 
>> <project ...>
>>    <import url="http://repo/build.jar!common-build.xml"/>
>> </project>
>> 
>> As ivy became a sub project, it would make sense to have a closer
>> integration like :
>> 
>> <project ...>
>>    <import url="ivy://settings.xml:org/module/artifact@MyResolver" />
>> <!--
>> would locate the settings.xml file and seek a build-common.xml file using
>> MyResolver resolver.
>> -->
>> </project>
>> 
>> we could imagine deeper integration :
>> 
>> <project ...>
>>    <import url="ivy://settings.xml:org/module/artifact@MyResolver"
>> ivyFile="${basedir]/ivy.xml"/>
>> <!--
>> configure ivy / read the ivy file
>> would map each ivy configuration to a path ( path could use a lazy
>> resolve
>> proxy: resolve only when it get used)
>> would import resolved artifcat as an ant build file
>> 
>> -->
>> </project> 
>> 
>> jonathan doklovic-2 wrote:
>> > 
>> > Hi,
>> > 
>> > I know there's not currently a way to do this, but I think it would be
>> > very helpful to be able to use the import task to import a file from a
>> > jar.
>> > 
>> > This way, when I have a handful of projects, all with common targets, I
>> > can put the common.xml build file in a jar and have each project depend
>> > on that jar.
>> > 
>> > Combined with something like ivy, I think this would be a pretty good
>> > way to share common targets among multiple projects that may not have
>> > anything to do with each other.
>> > 
>> > Any thoughts?
>> > 
>> > Any way to do this now?
>> > 
>> > - Jonathan
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> > For additional commands, e-mail: user-help@ant.apache.org
>> > 
>> > 
>> > 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/import-file-from-jar-%28or-classpath%29-tp14760992p14768063.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import file from jar (or classpath)

Posted by jonathan doklovic <jd...@sysbliss.com>.
I added a bug to the bug database and attached a patch that adds the
same classpath functionality as taskdef to the import task.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44214

- Jonathan

On Fri, 2008-01-11 at 09:40 -0800, kermitt wrote:
> In a previous post I suggest this:
> 
> I wish Ant import would support URL + jar like that :
> 
> <project ...>
>    <import url="http://repo/build.jar!common-build.xml"/>
> </project>
> 
> As ivy became a sub project, it would make sense to have a closer
> integration like :
> 
> <project ...>
>    <import url="ivy://settings.xml:org/module/artifact@MyResolver" />
> <!--
> would locate the settings.xml file and seek a build-common.xml file using
> MyResolver resolver.
> -->
> </project>
> 
> we could imagine deeper integration :
> 
> <project ...>
>    <import url="ivy://settings.xml:org/module/artifact@MyResolver"
> ivyFile="${basedir]/ivy.xml"/>
> <!--
> configure ivy / read the ivy file
> would map each ivy configuration to a path ( path could use a lazy resolve
> proxy: resolve only when it get used)
> would import resolved artifcat as an ant build file
> 
> -->
> </project> 
> 
> jonathan doklovic-2 wrote:
> > 
> > Hi,
> > 
> > I know there's not currently a way to do this, but I think it would be
> > very helpful to be able to use the import task to import a file from a
> > jar.
> > 
> > This way, when I have a handful of projects, all with common targets, I
> > can put the common.xml build file in a jar and have each project depend
> > on that jar.
> > 
> > Combined with something like ivy, I think this would be a pretty good
> > way to share common targets among multiple projects that may not have
> > anything to do with each other.
> > 
> > Any thoughts?
> > 
> > Any way to do this now?
> > 
> > - Jonathan
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> > 
> > 
> > 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: import file from jar (or classpath)

Posted by kermitt <he...@genesys.com>.
In a previous post I suggest this:

I wish Ant import would support URL + jar like that :

<project ...>
   <import url="http://repo/build.jar!common-build.xml"/>
</project>

As ivy became a sub project, it would make sense to have a closer
integration like :

<project ...>
   <import url="ivy://settings.xml:org/module/artifact@MyResolver" />
<!--
would locate the settings.xml file and seek a build-common.xml file using
MyResolver resolver.
-->
</project>

we could imagine deeper integration :

<project ...>
   <import url="ivy://settings.xml:org/module/artifact@MyResolver"
ivyFile="${basedir]/ivy.xml"/>
<!--
configure ivy / read the ivy file
would map each ivy configuration to a path ( path could use a lazy resolve
proxy: resolve only when it get used)
would import resolved artifcat as an ant build file

-->
</project> 

jonathan doklovic-2 wrote:
> 
> Hi,
> 
> I know there's not currently a way to do this, but I think it would be
> very helpful to be able to use the import task to import a file from a
> jar.
> 
> This way, when I have a handful of projects, all with common targets, I
> can put the common.xml build file in a jar and have each project depend
> on that jar.
> 
> Combined with something like ivy, I think this would be a pretty good
> way to share common targets among multiple projects that may not have
> anything to do with each other.
> 
> Any thoughts?
> 
> Any way to do this now?
> 
> - Jonathan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/import-file-from-jar-%28or-classpath%29-tp14760992p14761600.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org