ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Al Le <al...@gmx.de>
Subject Re: How to define a task with nested elements in Ant?
Date Sun, 04 Jun 2017 23:41:07 GMT
Hrm...

It would be cool if there existed a task which would allow to construct 
the translation of the task in Ant into some other existing tasks, e.g. 
using XPath.

I.e. you'd

1. Define the syntax of a new task; not with 'attribute' and 'element' 
(like in macrodef) but via e.g. XSD.

2. Define how instances of this task should translate into existing Ant 
tasks, e.g. using XSL.

The first thing would be used by Ant to check whether the task is used 
properly. The second thing would be used to execute such a task: first, 
Ant would apply the XSL to the task instance which would yield a 
fragment consisting of known ant tasks; then Ant would execute this 
fragment.

Have such thought been played with in the Ant community? I think, it 
would be a powerful tool to create custom tasks without having to code 
in Java.

Just thinking aloud...



Am 03.06.2017 um 23:42 schrieb Jan Matèrne (jhm):
> I dont know any easy way.
> Simplest thing would be writing that kind in Java.
> And if you dont want to download that jar from your buildfile you could the jar creation
inline:
> - generate the code (<echo>)
> - compile (<javac>)
> - archive that (<jar>)
> - include that (<taskdef>)
> 
> Via <script> you have access to the Ant API so it could be possible to do that
this way.
> But I think, that's very hard ...
> 
> Jan
> 
>> -----Urspr√ľngliche Nachricht-----
>> Von: Al Le [mailto:al.le@gmx.de]
>> Gesendet: Samstag, 3. Juni 2017 23:21
>> An: Ant Users List
>> Betreff: How to define a task with nested elements in Ant?
>>
>> Hello,
>>
>> is it possible to define a task in Ant which would have some nested
>> elements? Sort of like how it's done with the macrodef task but with a
>> bit structure.
>>
>> For example, I'd like to define a task which would be used as follows:
>>
>> <mytask>
>>       <paramA value="AAA1"/>
>>       <paramA value="AAA2"/>
>>       <paramB value="BBB"/>
>> </mytask>
>>
>>
>> This should internally translate to
>>
>> <java classname="some.Class">
>>       <arg value="-parameterA"/> <arg value="AAA1"/>
>>       <arg value="-parameterA"/> <arg value="AAA2"/>
>>       <arg value="-parameterB"/> <arg value="BBB"/> </java>
>>
>>
>> I.e. a <paramA> in the custom task should result in two args for the
>> java task.
>>
>> I know I could write a custom task in Java using an instance of the
>> java task in the implementation. But I'd like to know whether (and how)
>> it's possible to do this directly in Ant (possibly with javascript),
>> i.e.
>> without having to have some external JARs.
>>
>> Thank you for any hints!
>>
>> AL
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 

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


Mime
View raw message