Execute Ant task on save in IDEA - ant

How to execute Ant task on every document save in Intellij IDEA?
If you right-click on some task you can see Execute on -> After Compilation,
but I want to execute my task after each document save, how can I do it?

It's not possible and for a good reason. IDEA saves files automatically on many occasions and it would make your machine unusable.

Related

TFS vnext optional copy of folder step

In my build I need to occasionally copy a folder. i.e. If the folder's not there it's not a fail.
Currently I've used the copy task with "Continue on error" set which makes it look like my build has only partially succeeded.
I've also tried the "Command Line" task with robocopy/xcopy specified thus:
xcopy c:\here\ c:\there\ 2>NUL
Any tips on how I can fix this? e.g. inline powershell might do.
There is no way to change Partially Succeeded build to Succeeded status for now.
Instead of using the built-in Copy-File task. You could create your own task and overwrite the error info by yourself. How to create your own extension as your demands please follow this tutorial.
It's able to use Logging Commands to Log error or warning issue to timeline record of task.

TFS Online - Dont Zip empty folder

We're using TFS-Online to One-Click-Deploy our Software.
From time to time it happens, that we need to use some special scripts, we store in a folder. This basically means, most of the time said folder stays empty.
If i now go and trigger a build, i have there followings tasks
Now the question:
Is there any way to suppress these two tasks if the folder to be zipped/deleted is empty?
The tasks are the built in ones.
Note: This is NO on-premise TFS
You could specify conditions for running a task in VSTS. Express the condition as a nested set of functions. The agent evaluates the innermost function and works its way out. The final result is a boolean value that determines if the task is run or not.
In your case, a solution should be:
Add a powershell task prior to the Archive Files task.
Use the powershell task to judge the folder is empty or not.
If the folder is empty then fail the powershell task.(Remember to check Continue on error or always run option)
Add a condition for both Archive File and Delete File task such as Only when all previous tasks have succeeded
After this, those two task will not run when the special folder is empty during the build pipeline.
More details please refer this thread Specify conditions for running a task.

Apache Ant: turn off output for a specific task

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.

Wait for another ANT build/task to finish

I would like to make ANT process wait for another build or task to finish.
The situation is: I execute a few ANT builds simultaneously. In these builds there are tasks to test the apps. Unfortunately, only one flexunit task can be run at the same time, because it uses net socket to communicate with the AIR app.
The build process should wait for the end of the tasks from other build processes before starting its task.
How to achieve that?
Thank you for any hints,
Rafal
Use the <waitfor> task with your choice of synchronization.
I always use an "IGotTheResourceSoYouCantHaveIt" file that gets created after <waitfor> and deleted when I'm done with it.
Details:
delete the file in some higher-level "clean" so that if a build aborts it gets deleted eventually.
there's a small race condition between the <waitfor> and creating the file. In my use, it's not worth worrying about.

How to run Ant tasks even if build fails

I have an Ant task which runs if the lock file is not existing.
But if the build fails, then the lock file is not deleted at the end of the task and subsequently the task is not invoked from my scheduled jobs.
Is there anyway to handle such that even if build fails, I should be able to call my cleanUp task to delete the lock files?
Look at this: Testing and exception handling with Ant
There is macrodef with trycatch
This sounds to me like something that should be cleaned up at the beginning of any build.
Do you have an init task or some task on which all other tasks depend? I would just put the deletion of that file in there so that it always gets deleted even if a previous build failed.
However, it's a confusing requirement. It doesn't sound very idiomatic. Ordinarily, task execution is controlled through dependency and conditional properties. See the relevant section of the targets section of the manual for more details about if and unless. Creating a file is an expensive way to get the functionality already present in ant's core.

Resources