如何使用Maven将Class-Path添加到清单文件


问题内容

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

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

它将创建具有所有依赖项的Class-Path,例如

Class-Path:。jar1name.jar jar2name.jar等
不仅仅是
类路径:。
有没有一种方法可以避免maven将所有jar名称添加到Class-Path?
谢谢

    <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之外-仍然可以找到…

                <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: .