Run ant target multiple times but replace fileset it refers to - ant

I have an Ant target which runs unit tests on a fileset with a specific name, hardcoded inside of the target.
I would like to call that target multiple times, each time setting the fileset to a new value. I cannot change the name of the fileset which targets looks up, I can only define the fileset prior to calling a target.
Is it possible to call a target like this, and re-define same fileset during each target call?

Related

Will bazel truncate or append to an existing build_event_json_file?

We have a script which invokes bazel build for multiple targets (in this case, compiles some protos, then invokes the main build). In both invocations, we use the parameter --build_event_json_file, but we want the output of both runs. Is there a way to get bazel to append to the existing file, or will it always truncate?
The truncation of --build_event_json_file is not configurable.

How to create sources jars for java_library in bazel

As part of our efforts to create a bazel-maven transition interop tool (that creates maven sized jars from more granular sized bazel jars) there is a need to create sources jars.
For java_binary targets there is a mechanism to create it using -src.jar suffix
e.g., for a java_binary target called foo, run bazel build //:foo-src.jar
But, using the same mechanism for java_library target named bar I get:
ERROR: no such target '//:bar-src.jar': target 'bar-src.jar' not declared in package '' (did you mean 'libbar-src.jar'?) defined by /Users/.../java_project/BUILD.
Is there a another mechanism for java_library?
As indicated by the error, the source target is called //:libbar-src.jar (with the lib prefix). See the list of outputs of java_library for reference.

calling a target from a particular directory

I have script that call the below target but before calling this target i want that i should be at the following location which is stored in the below variable ..
todir="${release.deployment.tool}
the target that is called is shownb below..
<target name="deploy-ion" description="Used to deploy to a given aaa.">
so finally when my target deploy-ion is being called i should make sure that I should be in
directory stored in todir , please advise how to achieve this.
I meant you can use absolute path of your property reference while performing set of tasks inside your target, as by default it uses basedir default value as cur-dir or one which is specified at project level at beginning of your build.xml file.
Also alternatively you can use ant's ant task : https://ant.apache.org/manual/Tasks/ant.html with usage like
<ant dir="${release.deployment.tool}" target="deploy-ion" />

Alias/synonym for ant target

I have an ant target called "unittest" which I find clunky and I would like to use "test" instead. I need to keep the name "unittest" around though because other people also use the ant build file.
Is there a way that I could add aliases or synonyms for particular targets?
I tried using a comma separated list as possible in other attributes such as depends but that this not work. I get Target "test" does not exist in the project ...
<target name="test,unittest">
I know that I could simulate this using depends but I want to avoid the extra unnecessary output this produces.
<target name="test" depends="unittest">
Is there any way to achieve this? I will be fine with accepting the depends approach if there really is no better way.
Move the contents of the unittest target into a macrodef and replace the contents of the unittest target with a call to the macro. Create a test target calling the same macro. Job done.

How do I get the target as a property in Ant?

Possibly one of those really terrible beginner questions where the manual will tell you everything, but, anyway, take this line below:
ant -Dfoo=bar buildme
in my build script, what is the property that holds "buildme"?
The list of targets invoked is available in the property
ant.project.invoked-targets
If there is a default target specified, then that will be the invoked target. If one or more targets are specified on the command line, these appear comma-separated in the property. Note that the property only becomes set once execution passes to a target - if you try to read the property outside of any target, it will be unset.
So, if the project has a default target 'zero':
$ ant one two
# ant.project.invoked-targets is set to:
one,two
and
$ ant
# ant.project.invoked-targets is set to (default):
zero
Seems like ant.project.invoked-targets is not available in ant 1.7.1
Not sure I understand your question, but "buildme" is the target to execute, not a property.
ant [options] [target [target2 [target3] ...]]
You "pick it" by creating the corresponding target:
<target name="buildme">
<!-- tasks that will execute here -->
</target>
As for the foo property, you "pick it" by using ${foo}.

Resources