打包的Maven项目中包含META-INF/manifest.mf文件,字段"Built-by"中是当前用户的登录名。 在哪里或如何设置作者姓名,以便Maven使用此名称而不是登录名?
你可以通过在pom.xml中添加一个manifestEntries
部分来覆盖此内容,例如:
<project ...>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Built-By>${user.name}</Built-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
当从命令行调用时,以下内容适用:
mvn -Duser.name=<username> clean install
-Duser.name=<username>
另外一种做法是在特定项目的构建操作设置中设置相应属性(项目属性 -> 操作 -> 例如构建项目)。