问题描述
自上次Java更新以来,我需要使用 Trusted-Library
属性标记我的applet jars清单,以避免在javascript与applet通信时出现警告弹出窗口。 (参见)
Since the last Java update, I need to tag my applet jars manifest with the Trusted-Library
attribute to avoid warning popup when javascript is communicating with the applet. (see http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/mixed_code.html)
Manifest-Version: 1.0
Trusted-Library: true
Created-By: 1.6.0-internal (Sun Microsystems Inc.)
我之前从未做过这样的事情,是否有插件允许以无缝方式进行,或者我应该写一个,还是使用ant插件?
I never done such things before, is there a plugin which allow to do that in a seamless way or should I write one, or use the ant plugin?
罐子是已经组装并通过依赖项可用,复制到目标文件夹中以便在打包期间进行签名。我正在使用Maven 3
The jars are already assembled and available through dependencies, copied in the target folder to be signed during the packaging. I'm using Maven 3
推荐答案
最后我刚才使用了antrun插件,如下所示,antcontrib用于循环罐子列表:
In the end I just used the antrun plugin like the following, antcontrib is used to loop over the list of jars:
build-trusted.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a wrapper for all the other build files. -->
<project basedir="." name="project_name">
<target name="addTrustedLibraryProperty">
<jar file="${jarFile}" update="true">
<manifest>
<attribute name="Trusted-Library" value="true" />
</manifest>
</jar>
</target>
<target name="addTrustedLibraries">
<ac:foreach target="addTrustedLibraryProperty" param="jarFile" xmlns:ac="antlib:net.sf.antcontrib">
<path>
<fileset dir="target/lib" includes="**/*.jar" />
</path>
</ac:foreach>
</target>
</project>
在pom中
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>add-trusted-library-attribute</id>
<phase>package</phase>
<configuration>
<target>
<ant antfile="${basedir}/build-trusted.xml">
<target name="addTrustedLibraries" />
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
这篇关于将属性添加到Maven中的jar Manifest的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!