【发布时间】:2023-02-01 10:54:29
【问题描述】:
我正在使用 maven-changelog-plugin 生成一个 git diff 变更集。这个插件在我运行mvn site或mvn changeset:changeset时运行,并将变更集文件输出到target/site/changeset.html和/target/changeset.xml。我想将这个生成的文件包含在我运行mvn clean install 时构建的 jar 中。
如何将这个生成的文件包含在 JAR 中?我试过使用 build-helper-maven-plugin 添加工件或添加源,但似乎变更集是作为最后一步创建的或不可发现的。
我最近的尝试:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
<version>2.3</version>
<reportSets>
<reportSet>
<id>changelog-report</id>
<configuration>
<type>range</type>
<range>30</range>
</configuration>
<reports>
<report>changelog</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>add-changelog-to-artifact</id>
<activation>
<file><exists>target/site/changelog.html</exists></file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/site/changelog.html</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
【问题讨论】:
-
查看插件文档,我看不到
changelog:changelog默认绑定到哪个阶段,但您可以添加插件配置,就像build-helper-maven-plugin一样,它将在早期阶段运行更新日志。 -
@tgdavies 我确实尝试向
build-helper插件添加一个阶段,但是在<reporting> block it always runs last. I tried moving the plugin to the <build> block with an earlier phase, and it still did not work. Even usingmvn 站点 install, which builds the reports first, does not work because theadd-changelog` 插件中使用时找不到该文件
标签: java maven jar dependencies