Apache Ant: turn off output for a specific task - ant

I have a build file that has different variety of tasks. Some of these are in-house tasks that I am able to control the amount of logging/output generated.
The other tasks are libraries that I have no control over. They do not provide a way to control the amount of output. There is one very trivial task and I am comfortable with turning off the output of the task all together.
My question is if there a way to turn off this specific tasks output in the ant execution. Or does ant provide a way to wrap this task in another task that has echo set to 'off' or something similar?
-Syam

Ant has no builtin feature to turn off output for specific task, but there are possibilities via buildlisteners. See Make ant quiet without the -q flag? for answers

outputproperty="devnull"
It works fine for me and allways you can print this var if you need.

Related

How do I crash Ant's <input> task?

We run Bamboo CI Server.
There are a number of misconfigured plans (who don't correctly inherit the build.xml from the template project in our version control, or who don't set -D properties correctly according to our internal standards) that will trigger an Ant's input task.
While my template project prevents inputs by detecting whether we are running or not in Bamboo, this is not developer-fail-proof.
I would like to ask if there is any way to either crash Ant, or redirect the stdin to /dev/null at Bamboo instance level.
Currently, plans stuck at inputs will simply wait indefinitely until the main plan timeout rings, which could be a great idea to reduce.

Running Jmeter multiple independent jmx tests in parallel

I have a scenario where there are several independent jmx files, each of them has their own threadgroup etc. Using JMeter Ant script I can fire them all in sequence and collect the result in a jtl file. My challenge here is to do the same thing but fire off the tests in parallel. Please note that Include Controller is not an option since I want to use(or honor) the ThreadGroup and User Defined Variables in each jmx files.
Thanks for your help
Perhaps Parallel Ant Task is what you're looking for.
However <parallel> directive is not thread safe so I wouldn't recommend to use it with JMeter Ant task and consider using i.e. command-line mode, maven plugin or custom Java class which will spawn individual JMeter tests with it.
See 5 Ways To Launch a JMeter Test without Using the JMeter GUI guide for details of the approaches, hope this helps to find the one which matches your environment.
Yes, Ant parallel solves this problem.

How can I trigger an ant task only if input is newer than output?

I have a build process in Java where I need to use the Ant exec task to launch an external program. That external program will then create some sources based on an abstract specification, i.e. a kind of code generation.
How can I get the exec task to execute only if the input to the code generation is newer than the output? I.e. when the input has been modified after the output was last created?
Use the Uptodate task to set a property and add an if or unless with that property to the target which contains your exec task.
Since I wanted to specify an arbitrary set of target files (which is cumbersome or impossible with Uptodate that only uses the Ant mapper element for multiple target files), I ended up using the ant-contrib OutOfDate task which supported what I wanted more intuitively.

schedule ant task

Is it possible "and how if you know", to schedule the execution of an ant task?
For example, i want my build.xml to be executed every 5 hours or every day at a certain time?
I have been looking around but no solution found
Thank you
For very simple requirements, I'd echo the use of cron.
If the reason for running ANT is to periodically perform a master build of your project's code, then you're effectively following a practice called "Continuous Integration". In that case I'd highly recommend running a continuous integration server, such as Jenkins.
Jenkins is a very useful piece of software, easy to install and can become your automation framework for more than just building your code.
Just use cron and call ant.sh from it.
If you are working on a windows environment, you can use the "task scheduler" and set the interval. If you are working in unix/linux, you may use cron for scheduling your job.

Run JUnit tests in parallel

When running unit tests, Gradle can execute multiple tests in parallel without any changes to the tests themselves (i.e. special annotations, test runners, etc.). I'd like to achieve the same thing with ant, but I'm not sure how.
I've seen this question but none of the answers really appeal to me. They either involve hacks with ant-contrib, special runners set up with the #RunWith annotation, some other special annotations, etc. I'm also aware of TestNG, but I can't make the Eclipse plug-in migrate our tests - and we have around 10,000 of them so I'm not doing it by hand!
Gradle doesn't need any of this stuff, so how do I do it in ant? I guess Gradle uses a special runner, but if so, it's set up as part of the JUnit setup, and not mentioned on every single test. If that's the case, then that's fine. I just don't really want to go and modify c. 10,000 unit tests!
Gradle doesn't use a special JUnit runner in the strict sense of the word. It "simply" has a sophisticated test task that knows how to spin up multiple JVMs, run a subset of test classes in each of them (by invoking JUnit), and report back the results to the JVM that executes the build. There the results get aggregated to make it look like a single-JVM, single-threaded test execution. This even works for builds that define their own test listeners.
To get parallel test execution in Ant, you would need an Ant task that supports this feature (not sure if one exists). An alternative is to import your Ant build into Gradle (ant.importBuild "build.xml") and add a test task on the Gradle side.

Resources