Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

What is the quickest way to determine if files have changed during build?

Currently we're using an scm 'status' command, which we've found isn't great, performance-wise.  Is there a recommended approach for determining if a file has changed during the build?

How would this be done using the plain Java API?

0 votes

Comments

Do you mean actually changed during the build or changed from one build to the next?

Hi Jeff, thanks for the quick reply.  I actually meant 'changed during the build'....some of our builds change source files during build and I'd like to know what the experts think is the best approach to getting this data.


Accepted answer

Permanent link
One approach would be to compute checksums for each file in your extracted build tree prior to building anything, storing the information into a file. You can then to the same process after the build is over and compare the checksums.

Of course I don't know your requirements, but generally speaking it's a bad idea to be modifying source files during a build.
Todd Strangio selected this answer as the correct answer

0 votes

Comments

Thanks Jeff.  How would this be done using the Java API?

You wouldn't need the plain Java API to perform any of this. Your build will load the content and you just need something to compute the checksums for before and after.

You shouldn't need to use the RTC API: all the classes you would need for this exist as part of the JDK. You could also probably implement this solution using a shell script, though the comparison part might be tricky that way.

Can you elaborate on why you modify source files during your build? Maybe there's a different way to approach your problem that wouldn't involve such a terrible anti-pattern.

Some of our builds update a file during build with version info, which is then used during the deployment process.  Looks like the SCM command is our best option for now, thanks for the answers.

I see.

Again, I don't know the specifics, but in (superficially) similar cases in the past I have treated the source file as a template, generating the actual shipped file during the build process using the template, using token replacement, sed, or whatever other automated editing facility was available in the given context.


One other answer

Permanent link
The command line is your best option. You might be able to get something more lightweight with the plain Java API but it would be quite a bit reimplementing of the command-line and I don't know how much time you're willing to spend on that.

1 vote

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jun 07 '13, 1:37 p.m.

Question was seen: 4,759 times

Last updated: Jun 11 '13, 6:54 p.m.

Confirmation Cancel Confirm