无法在maven2的MANIFEST.MF中添加类路径
我正在尝试使用以下代码在 maven2 的 MANIFEST.MF 中添加类路径,但无法添加它。
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>iHubServiceImpl</finalName>
</build>
你能帮我一下吗?
更新:更新后的pom.xml下方:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.adp.ihub</groupId>
<artifactId>PreFinal</artifactId>
<version>1</version>
</parent>
<groupId>com.adp.ihub</groupId>
<artifactId>iHubCommon</artifactId>
<version>1</version>
<packaging>jar</packaging>
<name>iHubCommon</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathLayoutType>simple</classpathLayoutType>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${pom.url}</url>
<key>value</key>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- Use the jar plugin for plugin management configuration to take effect -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/pom*</exclude>
</excludes>
</resource>
</resources>
<finalName>iHubCommon</finalName>
</build>
<dependencies>
<dependency>
<groupId>com.adp.ihub</groupId>
<artifactId>BizLogic3</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${PWD}/iHUBCM/Environment/lib/BizLogic3.jar</systemPath>
</dependency>
<dependency>
<groupId>com.adp.ihub</groupId>
<artifactId>EncryptionAPI-jdk15-0.4</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${PWD}/iHUBCM/Environment/lib/EncryptionAPI-jdk15-0.4.jar</systemPath>
</dependency>
<dependency>
<groupId>com.adp.ihub</groupId>
<artifactId>adpbod-1.0</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${PWD}/iHUBCM/Environment/lib/adpbod-1.0.jar</systemPath>
</dependency>
</dependencies>
</project>
但我仍然没有在manifest.mf中获取条目。怎么了?
I am trying to add class path in MANIFEST.MF in maven2 with following code but it is unable to add it.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>iHubServiceImpl</finalName>
</build>
Can you please help me.
Update: Below the updated pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.adp.ihub</groupId>
<artifactId>PreFinal</artifactId>
<version>1</version>
</parent>
<groupId>com.adp.ihub</groupId>
<artifactId>iHubCommon</artifactId>
<version>1</version>
<packaging>jar</packaging>
<name>iHubCommon</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathLayoutType>simple</classpathLayoutType>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${pom.url}</url>
<key>value</key>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- Use the jar plugin for plugin management configuration to take effect -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/pom*</exclude>
</excludes>
</resource>
</resources>
<finalName>iHubCommon</finalName>
</build>
<dependencies>
<dependency>
<groupId>com.adp.ihub</groupId>
<artifactId>BizLogic3</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${PWD}/iHUBCM/Environment/lib/BizLogic3.jar</systemPath>
</dependency>
<dependency>
<groupId>com.adp.ihub</groupId>
<artifactId>EncryptionAPI-jdk15-0.4</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${PWD}/iHUBCM/Environment/lib/EncryptionAPI-jdk15-0.4.jar</systemPath>
</dependency>
<dependency>
<groupId>com.adp.ihub</groupId>
<artifactId>adpbod-1.0</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${PWD}/iHUBCM/Environment/lib/adpbod-1.0.jar</systemPath>
</dependency>
</dependencies>
</project>
But I still don't get the entries in my manifest.mf. what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
向清单添加类路径条目 ,您需要通过添加具有适当配置的
元素来告诉 Maven Jar 插件执行此操作。来自清单定制(略有调整):但您的情况的问题是您正在使用邪恶
system
范围,根据定义,它适用于应该始终可用且不会在存储库中查找的依赖项。因此,不要期望 Maven 将它们放入 Manifest.mf 的 Class-Path 条目中。我想我永远不会重复足够的人们不应该使用它
系统
范围的依赖项,但它们的用途是强烈劝阻:将 jar 安装在本地存储库中,或者使用公司存储库,或者使用 基于文件的存储库。但不要使用
system
范围。To Add a Class-Path Entry to the Manifest, you need to tell the Maven Jar Plugin to do so by adding an
<archive>
element with the appropriate configuration. From Manifest customization (slightly adapted):But the problem in your case is that you are (ab)using the evil
system
scope which by definition is for dependencies that are supposed to be always available and [are] not looked up in a repository. So don't expect Maven to put them in the Class-Path entry of the Manifest.mf.I guess I'll never repeat enough that people should not use it
system
scoped dependencies, but their use is strongly discouraged:Either install your jars in your local repository, or use a corporate repository, or use a file based repository. But don't use the
system
scope.maven 编译器插件 不谈论配置名为“manifest”的属性,您可能需要使用maven-jar-plugin。请参阅此链接了解如何执行此操作。
编辑:
当你使用插件管理来配置插件时,你需要在元素中实际使用该插件。
请参阅 文档
在控制台类型上:
编辑使用此 pom.xml
The maven compiler plugin does not talk about a configuration attribute called "manifest", You may want to use the maven-jar-plugin. See this link on how to do it.
Edit:
When you are using the pluginManagement to configure plugins,you need to actually use the plugin in the elements.
See the documenttation
On console type:
Edit use this pom.xml