Last active
August 8, 2016 12:12
-
-
Save bdulac/269bfd3f1be2ce3bb87c263a8bc89991 to your computer and use it in GitHub Desktop.
An ANT macrodef to unsign a Jar file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project name="unsign" basedir="."> | |
<description>Jar unsigner project.</description> | |
<macrodef name="unsignjar" description="To unsign a Jar file"> | |
<attribute name="jarfile" | |
description="The jar file to unsign" /> | |
<sequential> | |
<!-- Copying the manifest file in a temporary file --> | |
<copy toFile="@{jarFile}_MANIFEST.tmp"> | |
<resources> | |
<zipentry zipfile="@{jarFile}" name="META-INF/MANIFEST.MF"/> | |
</resources> | |
</copy> | |
<!-- Removing the Name and SHA entries from the temporary file --> | |
<replaceregexp file="@{jarFile}_MANIFEST.tmp" match="\nName:(.+?)\nSH" replace="SH" flags="gis" byline="false"/> | |
<replaceregexp file="@{jarFile}_MANIFEST.tmp" match="SHA(.*)" replace="" flags="gis" byline="false"/> | |
<!-- Creating a temporary Jar file with the temporary manifest --> | |
<jar jarfile="@{jarFile}.tmp" | |
manifest="@{jarFile}_MANIFEST.tmp"> | |
<zipfileset src="@{jarFile}"> | |
<include name="**"/> | |
<exclude name="META-INF/*.SF"/> | |
<exclude name="META-INF/*.DSA"/> | |
<exclude name="META-INF/*.RSA"/> | |
</zipfileset> | |
</jar> | |
<!-- Removing the temporary manifest --> | |
<delete file="@{jarFile}_MANIFEST.tmp" /> | |
<!-- Swapping the original Jar file with the temporary one --> | |
<move file="@{jarFile}.tmp" | |
tofile="@{jarFile}" | |
overwrite="true" /> | |
</sequential> | |
</macrodef> | |
<!-- The definition can then be called this way in an ANT task --> | |
<target name="unsignJar"> | |
<unsignjar jarFile="${webapp.libs}/org.apache.commons.logging_1.1.1.v201101211721.jar" /> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment