This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Linux diff command failing from ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Linux diff command failing from ANT" Watch "Linux diff command failing from ANT" New topic
Author

Linux diff command failing from ANT

Ajay Vikas
Ranch Hand

Joined: Nov 08, 2006
Posts: 66
Hi All,

I am trying to run a Linux command from ant and facing the following errors,

Script Task:

<exec executable="/usr/bin/diff" failonerror="true" output="Main_Agg_diff.log">
<arg line="TAOuput.log TLPOuput.log"/>
</exec>

Error is :

[exec] Current OS is Linux
[exec] Output redirected to /home/ajay/TATest/Main_Agg_diff.log
[exec] Executing '/usr/bin/diff' with arguments:
[exec] 'TAOuput.log'
[exec] 'TLPOuput.log'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.

BUILD FAILED
/home/ajay/TATest/build.xml:36: exec returned: 1
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:591)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:617)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:452)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Please help me over this.

Thanks in advance.

--
Ajay.
SCJP 1.4.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17040
    
  26

You set "failOnError" true. If diff detects that 2 files are different, it returns non-zero (specifically, it returned 1). This was detected as failure, which terminated Ant.

From what I can see, Ant did exactly what you told it to.


An IDE is no substitute for an Intelligent Developer.
Ajay Vikas
Ranch Hand

Joined: Nov 08, 2006
Posts: 66
Thanks a Ton Tim. It has worked for me now.

--
Ajay.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Linux diff command failing from ANT
 
It's not a secret anymore!