如何使用Maven将Class-Path添加到清单文件 [英] How to add Class-Path to the manifest file with maven

查看:858
本文介绍了如何使用Maven将Class-Path添加到清单文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用maven-jar-plugin时
我想在Manifest.mf中添加条目
因此它将包含:
Class-Path :.
当我将此条目添加到Pom中时:

When using the maven-jar-plugin
I would like to add entry to the Manifest.mf
So it will contain:
Class-Path: .
When i add this entry to the Pom:

<Class-Path>.</Class-Path> 

它将创建具有所有依赖关系的Class-Path
例如:
Class-Path :. jar1name.jar jar2name.jar等
而不仅仅是
Class-Path :.
是否可以避免Maven将所有jar名称添加到Class-Path?
谢谢

It will create Class-Path with all dependency
Like:
Class-Path: . jar1name.jar jar2name.jar etc
Instead of just
Class-Path: .
Is there a way to avoid maven from adding all jar names to the Class-Path?
Thanks

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                    <manifestEntries>
                        <Built-By>Me</Built-By>
            <Class-Path>.</Class-Path> 
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

推荐答案

这成功了
省略addClasspath并添加manifestEntries
现在,log4j.properties可以驻留在jar之外-仍然可以找到...

This did the trick
Omitting the addClasspath and adding manifestEntries
Now, log4j.properties can reside outside the jar - and still be found...

                <manifest>
                    <addClasspath>true</addClasspath>
                </manifest>

这有效:

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Built-By>Me</Built-By>
             <Class-Path>.</Class-Path>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

输出:

 Manifest-Version: 1.0
 Archiver-Version: Plexus Archiver
 Created-By: Apache Maven
 Build-Jdk: 1.6.0_45
 Built-By: Me
 Class-Path: .

这篇关于如何使用Maven将Class-Path添加到清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆