NatAntBuild Cache properties file - Hash value

Hi all, interesting scenario here (and probably relevant as more sites transition to straight NaturalOne usage)

For the Hash Value in the
Natural Ant build file

How is the hash value for the modules generated?

I say this, as there may be developers who are working in an ‘old’ style (Natural Studio / MF Editor), and rather then clobber their change with a redeploy (stow/cat) - I would rather ignore the rogue modules and leave it be - update the value in the cache properties file (to match the server version / updated from base library version) so it does not deploy.

I have been overcoming this problem in the past by running a Natural Ant Deploy without Stow or Upload on (to update the hash values).

For all those interested, It is easy to identify the modules intended for deployment (without performing the deploy) with the ‘checkts’ argument in the Natural Ant Deploy.

Unfortunately, unless everybody in a team is using modern ways of working (Git, NaturalOne, Jenkins) - there would be many sites with similar issues.

The following sample code should do the job:

	public String getHash(String str) {
		String hash = null;
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			byte[] array = md.digest(str.getBytes());
			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < array.length; ++i) {
				sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100)
						.substring(1, 3));
			hash = sb.toString();
		} catch (NoSuchAlgorithmException e) {
			System.out.println("Could not calculate MD5 hash");
		return hash;
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.