Using ant checksum https://ant.apache.org/manual/Tasks/checksum.html for generate sha256 checksum
<target name="generate_checksum">
<checksum Algorithm="SHA-256" fileext=".sha256">
<fileset dir="/home/myusername/temp/checksum">
<include name="*.jar"/>
</fileset>
</checksum>
</target>
Output of checksum file test.jar.sha256 file contain
c90fef8607e3ee7686d893d3980b6f21c5f1f138c829acc39ea64d25c8955080
Only checksum not contain filename
In Linux command if I use
sha256sum test.jar > sha265sums.txt
Getting checksum with filename
c90fef8607e3ee7686d893d3980b6f21c5f1f138c829acc39ea64d25c8955080 test.jar
Any option there in ant to include file name as well. Note, file name is unknown, any file contain in a folder which ends with .jar
Or any alternatives in Maven also fine to use.
CodePudding user response:
By using pattern Attributes result file of checksum we can add file name like below it works. Thanks @roediGERhard
Reference : https://ant.apache.org/manual/Tasks/checksum.html
<target name="generate_checksum" pattern="{0} {1}">
<checksum Algorithm="SHA-256" fileext=".sha256">
<fileset dir="/home/myusername/temp/checksum">
<include name="*.jar"/>
</fileset>
</checksum>
</target>
Result become
c90fef8607e3ee7686d893d3980b6f21c5f1f138c829acc39ea64d25c8955080 test.jar