Ant Uptodate for individual files

G

Greg

Hello,

I am using the newest version of ant and I have a bit of a difficult
problem I am trying to solve. I have xml files that I generate java
from. Therefore, each java depends on the xml. What I need to do is
check to see if whatever.xml is newer than whatever.java or
whatever.java does not exist. If whatever.xml is newer or
whatever.java does not exist I need to run a java app on only that xml
file. Therefore, dependset does not work because I dont want to dump
all my java files if only one xml file changes. Does anyone know how
to do this and is this possible?

Thanks!

Greg
 
M

Martin Gregorie

Hello,

I am using the newest version of ant and I have a bit of a difficult
problem I am trying to solve. I have xml files that I generate java
from. Therefore, each java depends on the xml. What I need to do is
check to see if whatever.xml is newer than whatever.java or
whatever.java does not exist. If whatever.xml is newer or whatever.java
does not exist I need to run a java app on only that xml file.
Therefore, dependset does not work because I dont want to dump all my
java files if only one xml file changes. Does anyone know how to do
this and is this possible?
Have you tried using 'make' to handle the XML->Java step?
 
M

Mike Schilling

Greg said:
Hello,

I am using the newest version of ant and I have a bit of a difficult
problem I am trying to solve. I have xml files that I generate java
from. Therefore, each java depends on the xml. What I need to do is
check to see if whatever.xml is newer than whatever.java or
whatever.java does not exist. If whatever.xml is newer or
whatever.java does not exist I need to run a java app on only that xml
file. Therefore, dependset does not work because I dont want to dump
all my java files if only one xml file changes. Does anyone know how
to do this and is this possible?

When I've needed to do this, I've put the "is it stale?" logic in the
program that does the generation rather than in Ant. You can use dependset
to run the program only if *something* is stale; that's a small
optimization.
 
J

John B. Matthews

Martin Gregorie said:
]
I am using the newest version of ant and I have a bit of a difficult
problem I am trying to solve. I have xml files that I generate java
from. Therefore, each java depends on the xml. What I need to do is
check to see if whatever.xml is newer than whatever.java or
whatever.java does not exist. If whatever.xml is newer or whatever.java
does not exist I need to run a java app on only that xml file.
Therefore, dependset does not work because I dont want to dump all my
java files if only one xml file changes. Does anyone know how to do
this and is this possible?
Have you tried using 'make' to handle the XML->Java step?

This is an excellent suggestion, as ant targets make excellent 'make'
commands.

Alternatively, the OP might look at <touch> with a nested <mapper> as a
means to change .java files to the date of their corresponding .xml
sources:

<touch file="file.xml">
<mapper type="glob" from="file.xml" to="file.java" />
</touch>

<http://ant.apache.org/manual/CoreTasks/touch.html>
 
M

Mike Schilling

By the way, the fact that it's difficult to express "'A' depends on 'B'"
shows clearly what a miserable excuse for a build tool ANT is. It's like a
parser generator that can't express "an A is a B followed by a C".
 
A

Arne Vajhøj

Mike said:
By the way, the fact that it's difficult to express "'A' depends on 'B'"
shows clearly what a miserable excuse for a build tool ANT is.

Today the normal way is to just compile everything.

Arne
 
M

Mike Schilling

Arne said:
Today the normal way is to just compile everything.

Which assumes that's less expensive than checking. That's more or
less true for Java 1[], but it't universal.

1. Actually, Java makes it very difficult to be sure what needs
recompilation. Ant applies an algorithm that's correct much of the
time. Unfortunately, it errs on the side of risk, not of safety.
 
A

Arne Vajhøj

Mike said:
Arne said:
Today the normal way is to just compile everything.

Which assumes that's less expensive than checking. That's more or
less true for Java 1[], but it't universal.

It is practically almost acceptable.
1. Actually, Java makes it very difficult to be sure what needs
recompilation. Ant applies an algorithm that's correct much of the
time. Unfortunately, it errs on the side of risk, not of safety.

Which is why starting by cleaning destination is so common.

Arne
 
M

Martin Gregorie

Arne said:
Today the normal way is to just compile everything.

Which assumes that's less expensive than checking. That's more or less
true for Java 1[], but it't universal.

1. Actually, Java makes it very difficult to be sure what needs
recompilation. Ant applies an algorithm that's correct much of the
time. Unfortunately, it errs on the side of risk, not of safety.
I'm surprised at its speed. On my rather slow box (866 MHz P3) compiling
one 300 line source ("touch aprog.java; ant") takes 5 secs, which is
acceptable.

However, running "ant clean; ant", i.e. deleting all class files, a
jarfile and a zip file, then compiling 95 sources and rebuilding the jar
file and packaging scripts into the ZIP file takes 10 seconds - amazingly
fast.

My reaction to these times is that: 5 secs feels subjectively quick while
10 secs feels very much longer.

People's reactions to response times are interesting, especially when it
comes to the psychology of using computers. I remember that in James
Martin's book on User Interface design, "Design of Man-Machine Dialogues"
he quoted three response time bands:

- 1 second or less. Feels instantaneous. Fast enough to upset some users.

- 1-4 seconds. Most users can't tell the difference between response times
in this range. Fast enough for users not to notice the time taken.

- over 5 seconds. Feels slow. Users start to complain about the speed
at much over 5 seconds.

The book was published in 1973, way back in the days of mainframes with
page-mode green screens. I've never had much time for his other stuff,
but that was a good book with some ideas that I've never seen being
written about since for designing the UI to suit the category of user.
 
A

Arne Vajhøj

Martin said:
I'm surprised at its speed. On my rather slow box (866 MHz P3) compiling
one 300 line source ("touch aprog.java; ant") takes 5 secs, which is
acceptable.

However, running "ant clean; ant", i.e. deleting all class files, a
jarfile and a zip file, then compiling 95 sources and rebuilding the jar
file and packaging scripts into the ZIP file takes 10 seconds - amazingly
fast.

Which seems to indicate that most of the 5 secs is spent
initializing.

Arne
 
R

Roedy Green

I am using the newest version of ant and I have a bit of a difficult
problem I am trying to solve. I have xml files that I generate java
from. Therefore, each java depends on the xml. What I need to do is
check to see if whatever.xml is newer than whatever.java or
whatever.java does not exist. If whatever.xml is newer or
whatever.java does not exist I need to run a java app on only that xml
file. Therefore, dependset does not work because I dont want to dump
all my java files if only one xml file changes. Does anyone know how
to do this and is this possible?

If you use TakeCommand as your Windows command processor, you can
compare file dates. See http://mindprod.com/jgloss/takecommand.html

If you use ANT:

<fileset dir="${ant.1.5}/src/main" includes="**/*.java">
<different targetdir="${ant.1.4.1}/src/main"
ignoreFileTimes="true"/>
</fileset>
Compares all the Java source files between the 1.4.1 and the 1.5
release and selects those who are different, disregarding file times.

<fileset dir="${ant.1.5}/src/main" includes="**/*.java">
<depend targetdir="${ant.1.4.1}/src/main"/>
</fileset>

Selects all the Java source files which were modified in the 1.5
release.

Read up on Selectors.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"By 2040, the Sahara will be moving into Europe, and Berlin
will be as hot as Baghdad. Atlanta will end up a kudzu
jungle. Phoenix will become uninhabitable, as will parts of
Beijing (desert), Miami (rising seas) and London (floods).
Food shortages will drive millions of people north, raising
political tensions."
~ James Lovelock
Lovelock is more pessimistic than the consensus, because he thinks man will
refuse to take significant action to ameliorate global warming.
 
G

Greg

If you use TakeCommand as your Windows command processor, you can
compare file dates.  Seehttp://mindprod.com/jgloss/takecommand.html

If you use ANT:

<fileset dir="${ant.1.5}/src/main" includes="**/*.java">
    <different targetdir="${ant.1.4.1}/src/main"
        ignoreFileTimes="true"/>
</fileset>
Compares all the Java source files between the 1.4.1 and the 1.5
release and selects those who are different, disregarding file times.

<fileset dir="${ant.1.5}/src/main" includes="**/*.java">
    <depend targetdir="${ant.1.4.1}/src/main"/>
</fileset>

Selects all the Java source files which were modified in the 1.5
release.

Read up on Selectors.
--
Roedy Green Canadian Mind Productshttp://mindprod.com

"By 2040, the Sahara will be moving into Europe, and Berlin
will be as hot as Baghdad. Atlanta will end up a kudzu
jungle. Phoenix will become uninhabitable, as will parts of
Beijing (desert), Miami (rising seas) and London (floods).
Food shortages will drive millions of people north, raising
political tensions."
~ James Lovelock
Lovelock is more pessimistic than the consensus, because he thinks man will
refuse to take significant action to ameliorate global warming.

Ok thanks for all the replies. How might I take the resulting file
that the depend selector is using and feed that particular file into
my java program as an argument?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top