How to determine if Ivy retrieve task updated any dependency in my lib folder?

Viewed 83

I have an Ant build where I only want to rebuild an artifact if its dependencies is updated.

For the external dependencies, this is easy since I can just compare the change date for ivy.xml with the created date of the artifact (with uptodate). But this does not work for internal dependencies where I use latest.release to define the revision of the dependency. Like this:

<dependencies>
    <dependency org="se.woop" name="thelibrary" rev="latest.release" conf="default->*"/>
</dependencies>

In this scenario the project thelibrary can result in a new version without a change in the ivy.xml file. I would like something like the checkIfChanged on the resolve task on the retrieve task.

Any suggestion on how this can be solved?

Edit:

I realized that I might be able to use the uptodate function to check my library folder agains the latest produced artifactory as well, and it almost works. This is what my uptodate looks like:

<uptodate targetfile="build/artifacts/theclient.jar" property="artifact.uptodate">
   <srcfiles dir= "src" includes="*"/>
   <srcfiles dir= "lib" includes="*"/>
   <srcfiles dir= "." includes="ivy.xml"/>
</uptodate>

The problem is that the uptodate function compares against the changed date of the artifacts in the library folder. However when the files are copied to the library folder (by Ivy) the changed date is not updated, but the created date is.

So... is it possible to make the uptodate compare against the created date instead? Or is it possible to make Ivy update the changed date when moving dependencies into the library folder? Or is it another solution available?

1 Answers

"I have an Ant build where I only want to rebuild an artifact if its dependencies is updated." Stop checking the version.

"The problem is that the uptodate function compares against the changed date of the artifacts in the library folder." Stop using that completely.

"Or is it another solution available?" Yes.

Each time that your program accesses the artifact, have it then later, when it is no longer needing that artifact, copy the artifact and then save that copy as a new artifact with a counting number. Like this: artifact_0001 is accessed then used then when no longer needed a new artifact_0002 is saved in the library folder. Then artifact_0001 is deleted. Edit artifact_0002 if you need to outside or inside of your program.

Each time that your program runs, check to see if artifact_xxxn exists one n at a time until you find an artifact_000n that does exist and then attempt to access that. Have it attempt to access artifact_[xxxx] where the xxxx counts up and if it can not access an artifact_xxxn, then it attempts to access artifact_000[n+1] etc. When the count reaches some number, return to 0 or 1 in the count and start again. Remember to only go through the entire n range twice to stop a potential endless loop. If the entire artifact_000n range is checked twice and there is nothing there, then have a artifact_default that is used simply to get your program running, and when it runs put up a notice that a artifact_default is being used so you know to fix that.

This should work as a cross language solution.

Related