Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add permissions attribute in manifest third party jars using maven

How can we add additional parameters to manifest file using Maven to third party jars. After Java 7_25 version the Java web start requires codebase and permissions to be add in all downloading jar files. I want to insert them jar singing time.

Please let me know if you need any information. Thanks in advance.

like image 527
sats Avatar asked Sep 20 '13 22:09

sats


1 Answers

i made a little ant script (this is an extract, in fact it also excludes some crypto file).

just set directory property value to a directory that contains jars to be updated and launch the target "give-permissions".

it should be easy to use with maven-ant:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="project">
    <taskdef resource="net/sf/antcontrib/antcontrib.properties" />

    <property name="directory" value="WebContent/jnlpApplication" />

    <target name="give-permissions">
        <foreach target="_re-jar" param="currentFile" parallel="false">
            <path>
                <fileset dir="${directory}" casesensitive="yes">
                    <include name="**/*.jar" />
                </fileset>
            </path>
        </foreach>

        <move todir="${directory}" overwrite="true">
            <fileset dir="${directory}.tmp" casesensitive="yes">
                <include name="**/*.jar" />
            </fileset>
        </move>

        <delete dir="${directory}.tmp" />
    </target>

    <target name="_re-jar">
        <basename property="filename" file="${currentFile}" />

        <jar destfile="${directory}.tmp/${filename}">
            <zipfileset src="${currentFile}">
                <exclude name="META-INF/**.RSA" />
                <exclude name="META-INF/**.SF" />
            </zipfileset>
            <manifest>
                <attribute name="Permissions" value="all-permissions" />
                <attribute name="Codebase" value="*" />
                <attribute name="Application-Name" value="jnlpApplicationName" />
            </manifest>
        </jar>
    </target>
</project>
like image 62
Michele Mariotti Avatar answered Oct 10 '22 01:10

Michele Mariotti