繁体   English   中英

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

[英]How to add Class-Path to the manifest file with maven

使用maven-jar-plugin时
我想在Manifest.mf中添加条目
所以它将包含:
类路径:。
当我将此条目添加到Pom时:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM