Can I load a project from a String / InputStream?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Can I load a project from a String / InputStream?

Ioan Eugen Stan
Hello,

I would like to know if there is a ProjectHelper with Ant that allows me to load a project from a String/InputStream instead of a file.

I would like to embed ant in another tool and avoid to write files.

The InputStream/String is a much more generic abstraction than the file IMO.

I read https://ant.apache.org/manual/projecthelper.html and skimmed the sources but could not find something like this.

https://github.com/apache/ant/blob/master/src/main/org/apache/tools/ant/ProjectHelper.java
https://ant.apache.org/manual/api/org/apache/tools/ant/helper/ProjectHelper2.html

I am looking for something built in if possible before trying to build my own.

Thanks,
Eugen

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can I load a project from a String / InputStream?

Dave Brosius-5
it might be easier (depending on your needs) to just create the ant
objects directly, like

    Project p = new Project();
    MyTask t = new MyTask();
    t.setProject(p);
    t.setProperty("foo");
    t.execute();



On 12/31/20 12:32 AM, Ioan Eugen Stan wrote:

> Hello,
>
> I would like to know if there is a ProjectHelper with Ant that allows me to load a project from a String/InputStream instead of a file.
>
> I would like to embed ant in another tool and avoid to write files.
>
> The InputStream/String is a much more generic abstraction than the file IMO.
>
> I read https://urldefense.com/v3/__https://ant.apache.org/manual/projecthelper.html__;!!GqivPVa7Brio!LruDh-_D0EjX2u27tSPrZt06msXZ-JL72yyZzsQ2VuOszCjpMgX-jIt6sZnpe69MOQ$  and skimmed the sources but could not find something like this.
>
> https://urldefense.com/v3/__https://github.com/apache/ant/blob/master/src/main/org/apache/tools/ant/ProjectHelper.java__;!!GqivPVa7Brio!LruDh-_D0EjX2u27tSPrZt06msXZ-JL72yyZzsQ2VuOszCjpMgX-jIt6sZkyyJj0gA$
> https://urldefense.com/v3/__https://ant.apache.org/manual/api/org/apache/tools/ant/helper/ProjectHelper2.html__;!!GqivPVa7Brio!LruDh-_D0EjX2u27tSPrZt06msXZ-JL72yyZzsQ2VuOszCjpMgX-jIt6sZlKD0Gn2A$
>
> I am looking for something built in if possible before trying to build my own.
>
> Thanks,
> Eugen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: Can I load a project from a String / InputStream?

Eugen Stan
Thanks but I want/need to build the xml file dynamically and build the project from that and then maybe customize it.I think this feature should make it easier to test ant as well. Would this be ok for a PR?Add a parse function in ProjectHelper similar to the file api?
-------- Mesaj original --------De la: Dave Brosius <[hidden email]> Date: 31.12.2020  08:47  (GMT+02:00) Către: [hidden email] Subiect: Re: Can I load a project from a String / InputStream? it might be easier (depending on your needs) to just create the ant objects directly, like    Project p = new Project();    MyTask t = new MyTask();    t.setProject(p);    t.setProperty("foo");    t.execute();On 12/31/20 12:32 AM, Ioan Eugen Stan wrote:> Hello,>> I would like to know if there is a ProjectHelper with Ant that allows me to load a project from a String/InputStream instead of a file.>> I would like to embed ant in another tool and avoid to write files.>> The InputStream/String is a much more generic abstraction than the file IMO.>> I read https://urldefense.com/v3/__https://ant.apache.org/manual/projecthelper.html__;!!GqivPVa7Brio!LruDh-_D0EjX2u27tSPrZt06msXZ-JL72yyZzsQ2VuOszCjpMgX-jIt6sZnpe69MOQ$  and skimmed the sources but could not find something like this.>> https://urldefense.com/v3/__https://github.com/apache/ant/blob/master/src/main/org/apache/tools/ant/ProjectHelper.java__;!!GqivPVa7Brio!LruDh-_D0EjX2u27tSPrZt06msXZ-JL72yyZzsQ2VuOszCjpMgX-jIt6sZkyyJj0gA$> https://urldefense.com/v3/__https://ant.apache.org/manual/api/org/apache/tools/ant/helper/ProjectHelper2.html__;!!GqivPVa7Brio!LruDh-_D0EjX2u27tSPrZt06msXZ-JL72yyZzsQ2VuOszCjpMgX-jIt6sZlKD0Gn2A$>> I am looking for something built in if possible before trying to build my own.>> Thanks,> Eugen>> ---------------------------------------------------------------------> To unsubscribe, e-mail: [hidden email]> For additional commands, e-mail: [hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Can I load a project from a String / InputStream?

Stefan Bodewig
On 2020-12-31, Eugen Stan wrote:

> Thanks but I want/need to build the xml file dynamically and build the
> project from that and then maybe customize it.I think this feature
> should make it easier to test ant as well. Would this be ok for a
> PR?Add a parse function in ProjectHelper similar to the file api?

Note that ProjectHelper2 already supports Ant's own Resource abstraction
in a limited way - it supports it if the Resource can provide a File or
an URL.

If you want to start supporting InputStreams in addition then I'd
suggest you change the code in a way that works for arbitrary Resoures
(as they all provide InputStreams).

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

AW: Can I load a project from a String / InputStream?

Jan Matèrne (jhm)
Maybe Stefans 11 years old "JavaFront" could be helpful.
https://svn.apache.org/viewvc/ant/sandbox/javafront/
The "taskexec.*" scripts shows how to use
https://svn.apache.org/viewvc/ant/sandbox/javafront/taskexec.bat?view=markup
https://svn.apache.org/viewvc/ant/sandbox/javafront/taskexec.sh?view=markup



-----Ursprüngliche Nachricht-----
Von: Stefan Bodewig <[hidden email]>
Gesendet: Freitag, 1. Januar 2021 14:37
An: [hidden email]
Betreff: Re: Can I load a project from a String / InputStream?

On 2020-12-31, Eugen Stan wrote:

> Thanks but I want/need to build the xml file dynamically and build the
> project from that and then maybe customize it.I think this feature
> should make it easier to test ant as well. Would this be ok for a
> PR?Add a parse function in ProjectHelper similar to the file api?

Note that ProjectHelper2 already supports Ant's own Resource abstraction in a limited way - it supports it if the Resource can provide a File or an URL.

If you want to start supporting InputStreams in addition then I'd suggest you change the code in a way that works for arbitrary Resoures (as they all provide InputStreams).

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: AW: Can I load a project from a String / InputStream?

Eugen Stan-2
Hi,

Thank you all for the feedback.

I wrote some code to register a custom java.net.URLConnection
URLStreamHandler and stream the contents from memory however.

However I don't think I can avoid making a custom ProjectHelper.
I've noticed that I can't add instances to configure an ant project.

The only way it works as far as I know is if I supply class names that
and can load and
instantiate via reflection.

Can I supply task instances to an ant project?

TLDR

My goal is to integrate clojure with ant so I can call clojure functions
as ant tasks.

The ideal way to handle this would be if I can supply an instance of a
function (Callable/Runnable/AntTask).

That way I can avoid having to generate java sources from clojure
(clojure can ship sources and compile on the fly).


As I write this email I believe I will have to write a clojure ant task
that has to do this.

But other ideas/feedback is welcomed.


Regards,
--
Eugen Stan
+40720 898 747 / netdava.com



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]