Maven更新清单在依赖jar中

时间:2015-08-25 16:55:58

标签: maven java-web-start

Webstart要求所有jar文件都有某些清单条目,所以现在我必须遍历所有依赖项并更新每个清单。有没有办法在任意jar文件中获取maven更新清单文件?

理想情况下我想:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.2</version>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>target</outputDirectory>

                <!-- something like this --> 
                <manifestEntries>
                    <Trusted-Library>true</Trusted-Library> <!-- does not work! -->
                </manifestEntries>

            </configuration>
        </execution>
    </executions>
</plugin>

2 个答案:

答案 0 :(得分:0)

你确定每个 jar需要包含MANIFEST吗?我认为只有在你的入门/主要课程的Jar中才需要它。您可以使用maven-jar-plugin生成它:

<UserControl.Resources> 
<ResourceDictionary> 
<ResourceDictionary.MergedDictionaries></ResourceDictionary.MergedDictionaries> </ResourceDictionary>

答案 1 :(得分:0)

您可以使用Webstart Maven插件:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>webstart-maven-plugin</artifactId>
            <version>1.0-beta-6</version>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>keytool-api-1.7</artifactId>
                    <version>1.5</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>jnlp-inline</goal>                            
                    </goals>
                </execution>
            </executions>
            <configuration>
                <filenameMapping>simple</filenameMapping>
                <versionEnabled>false</versionEnabled>
                <jnlpFiles>
                    <jnlpFile>
                        <templateFilename>default-jnlp-servlet-template.vm</templateFilename>
                        <outputFilename>yourJnlp.jnlp</outputFilename>

                        <jarResources>
                            <jarResource>
                                <groupId>your.package</groupId>
                                <artifactId>ArtifactId</artifactId>
                                <version>${project.version}</version>
                                <mainClass>your.main.Class</mainClass>
                            </jarResource>
                        </jarResources>

                    </jnlpFile>
                </jnlpFiles>
                <unsignAlreadySignedJars>true</unsignAlreadySignedJars>
                <canUnsign>true</canUnsign>
                <libPath>lib</libPath>
                <codebase>$$$codebase</codebase>

                <updateManifestEntries>
                    <Caller-Allowable-Codebase>*</Caller-Allowable-Codebase>
                    <Trusted-Library>true</Trusted-Library>
                    <Application-Library-Allowable-Codebase>*</Application-Library-Allowable-Codebase>
                    <Application-Name>ApplicationName</Application-Name>
                    <Permissions>all-permissions</Permissions>
                    <Codebase>*</Codebase>
                    <Trusted-Only>true</Trusted-Only>
                </updateManifestEntries>
                <jnlp>
                    <j2seVersion>1.7+</j2seVersion>
                    <outputFile>your_jnlp.jnlp</outputFile>
                    <mainClass>your.class.here</mainClass>
                </jnlp>
                <sign>
                    <keystore>${project.basedir}/youekeystore</keystore>
                    <storepass>...</storepass>
                    <alias>your_alias</alias>
                    <verify>false</verify>
                </sign>
                <verbose>true</verbose>
            </configuration>
        </plugin>