Skip to content

Commit

Permalink
feat: allow specifying additional filesets for feature's packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
lppedd authored and laeubi committed Dec 17, 2022
1 parent 282b99c commit 4808765
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,29 @@ public abstract class AbstractTychoPackagingMojo extends AbstractMojo {
@Parameter(defaultValue = "true")
protected boolean strictBinIncludes;

/**
* Additional files to be included in the final <code>.jar</code>.
* <p>
* A typical usage might be when <code>bin.includes</code> in <code>build.properties</code>
* is not flexible enough, e.g., for generated files, as when conflicting additional files
* win over <code>bin.includes</code>.
* <p>
* Example:
* <pre>
* &lt;additionalFileSets&gt;
* &lt;fileSet&gt;
* &lt;directory&gt;${project.build.directory}/mytool-gen/&lt;/directory&gt;
* &lt;includes&gt;
* &lt;include&gt;&#42;&#42;/*&lt;/include&gt;
* &lt;/includes&gt;
* &lt;/fileSet&gt;
* &lt;/additionalFileSets&gt;
* </pre>
* Note: currently, additional file sets are not used for the <code>package-iu</code> goal.
*/
@Parameter
protected DefaultFileSet[] additionalFileSets;

@Component
protected PlexusContainer plexus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ public void execute() throws MojoExecutionException, MojoFailureException {
jarArchiver.setDestFile(outputJar);

try {
// Additional file sets win over bin.includes ones, so we add them first
if (additionalFileSets != null) {
for (final var fileSet : additionalFileSets) {
final var directory = fileSet.getDirectory();

// noinspection ConstantConditions
if (directory != null && directory.isDirectory()) {
archiver.getArchiver().addFileSet(fileSet);
}
}
}

archiver.getArchiver().addFileSet(getManuallyIncludedFiles(buildProperties));
if (licenseFeature != null) {
archiver.getArchiver()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,6 @@ public class PackagePluginMojo extends AbstractTychoPackagingMojo {
@Component(role = Archiver.class, hint = "jar")
private JarArchiver jarArchiver;

/**
* Additional files to be included in the bundle jar. This can be used when
* <tt>bin.includes</tt> in build.properties is not flexible enough , e.g. for
* generated files. If conflicting, additional files win over
* <tt>bin.includes</tt><br/>
* Example:<br/>
*
* <pre>
* &lt;additionalFileSets&gt;
* &lt;fileSet&gt;
* &lt;directory&gt;${project.build.directory}/mytool-gen/&lt;/directory&gt;
* &lt;includes&gt;
* &lt;include&gt;&#42;&#42;/*&lt;/include&gt;
* &lt;/includes&gt;
* &lt;/fileSet&gt;
* &lt;/additionalFileSets&gt;
* </pre>
*
*/
@Parameter
private DefaultFileSet[] additionalFileSets;

/**
* Name of the generated JAR.
*/
Expand Down

0 comments on commit 4808765

Please sign in to comment.