How to use the Array property in ant task?

I created an Ant task in which I would like to have an array of properties? First of all, is this possible? Ant allows us to have an array of properties?

public class MyTask extends Task {
    private String tokens[] = null;
    public void setTokens(String[] _tokens) {
        //...
    }
    public void execute() {
     // iterator over the conditions
    }
}

Now, how to set tokens in the Ant build <file? >

+3
source share
2 answers

It sounds like you want to set some internal tags.

Writing your own task gives some recommendations. The section you are in is support for nested elements. It is pretty simple. I would be inclined to use something like the following

List tokens = new ArrayList();

public void addConfiguredToken(NestedElement token) {
    tokens.add(token);
}

Then you can use it using the following:

<task>
    <token value="XXX" />
    <token value="YYY" />
</task>
+1
source

Ant , DirList FileSet, - , , , . , , Ant, , FileSet .

0

Source: https://habr.com/ru/post/1764443/


All Articles