I'm creating a directory (local Eclipse b3 Aggregator/P2 mirror) with Maven.
Two configuration files (A.target, B.target) are used two create this directory.
If these configuration files change a new mirror directory should be created.
I want to add the checksum of the configuration files to the name of the mirror directory (e.g. mirror_65eb5293d29682a3414e8889a84104ee).
I could use the 'maven-assembly-plugin' to create a jar containing the configuration files but how do I create the checksum of this jar?
The 'checksum-maven-plugin' only writes the checksum into a csv file which I would have to parse somehow.
Is there a way to create the checksum into a property so that I can use it to add it to the name of the directory?
UPDATE:
My solution for now is to use a shell script to create the checksum and write it to a properties file.
#!/bin/bash
os=$(uname)
if [[ "$os" == "Linux" ]];
then
checksum=$(cat {A,B}.target | md5sum | awk '{print $1}')
elif [[ "$os" == "Darwin" ]]; then
checksum=$(cat {A,B}.target | md5 -q)
else
echo "unknown OS ${os}"
exit 1
fi
printf "checksum=%s" "${checksum}" > ./checksum.properties
Then I can use the properties-maven-plugin to read the checksum from this properties file.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>./checksum.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>