I'm generating a git diff changeset using the maven-changelog-plugin
. This plugin runs when I run mvn site
or mvn changeset:changeset
and outputs the changeset file into target/site/changeset.html
and /target/changeset.xml
. I would like to include this generated file in the jar that is built when I run mvn clean install
.
How can I include this generated file in the JAR? I've tried using the build-helper-maven-plugin
to add an artifact or to add a source, but it seems that the changeset is created as the last step or isn't discoverable.
My most recent attempt:
<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>
The issue with the maven-changelog-plugin
was that it always ran at a step later than the build step where it needed to be. I ended up using the gitlog-maven-plugin
instead, which allowed me to change the phase at which it executed