Solved

using ant for non-compiling

Posted on 2006-10-20
4
248 Views
Last Modified: 2010-03-31
In MS windows, I have a set of source files that I convert to another format using a .bat file and then combine into a single file.
I would like to be able to reprocess by only converting the source files that changed, and then combining the files. This seems
really similar to how ant processes javac, but I don't know how to make this work for .bat files instead. How would I create
an ant build.xml to do this?
for example, I have
aaa.txt
bbb.txt
ccc.txt
...
zzz.txt
using convert.bat on each separate file, I create
aaa.out
bbb.out
ccc.out
...
zzz.out
then
copy aaa.out+bbb.out+ccc.out+...+zzz.out myfile
but I only want to convert.bat the .txt files that have changed, so
that if the ggg.out timestamp is after the ggg.txt timestamp, just
use ggg.out.
 
0
Comment
Question by:lfrohman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:valipotor
ID: 17779300
Hi

On native Unix systems, you should be able to run shell scripts directly. On systems running a Unix-type shell (for example, Cygwin on Windows) execute the (command) shell instead - cmd  for batch files, sh for shell scripts - then pass the batch file or shell script (plus any arguments to the script) as a single command, using the /c or -c switch, respectively. See the above section  for example <exec> tasks executing sh. For batch files, use something like:

<exec dir="." executable="cmd" os="Windows NT">
  <arg line="/c test.bat"/>
</exec>


Use properties. Using ant -Dname=value lets you define values for properties on the Ant command line. These properties can then be used within your build file as any normal property: ${name} will put in value.

If you have more questions, read here:

valipotor
0
 
LVL 6

Expert Comment

by:valipotor
ID: 17779302
0
 

Author Comment

by:lfrohman
ID: 17781344
valipotor,
     This doesn't help me at all, I already know how to call a .bat file, the problem is how
to call the batch file on all the input files, but only if they have a newer timestamp.
0
 
LVL 3

Accepted Solution

by:
KnightFire earned 125 total points
ID: 17787209
You could write a custom ant task to do this, then call it from ant. Would that work for you?
See http://ant.apache.org/manual/develop.html for information on writing your own task, you simply extend org.apache.tools.ant.Task, implement an execute method and setters for any attributes you want the task to have.
Then in your ant build file, you map the name of your new task to the class that implements it (the one you created above).

You could create a task that takes a bat file and a path as an argument, and calls the bat on all files in that path, or something similar.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question