Skip to content

Commit

Permalink
maven: Support resolving bndrun files to an output folder
Browse files Browse the repository at this point in the history
Writing bndrun files in place after resolving is awkward since this
results in modifying files under source control.

So we add the outputBndrunDir configuration parameter to
bnd-resolver-maven-plugin so you can specify the output directory
to write the output bndrun files.

We add the bndrunDir configuration parameter to
bnd-export-maven-plugin and bnd-testing-maven-plugin so they can use
the output bndrun files from a bnd-resolver-maven-plugin execution.
For completeness, we also add the bndrunDir configuration parameter to
bnd-resolver-maven-plugin.

Signed-off-by: BJ Hargrave <bj@hargrave.dev>
  • Loading branch information
bjhargrave committed Nov 16, 2022
1 parent b9da98e commit 67fbf14
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 46 deletions.
29 changes: 15 additions & 14 deletions maven/bnd-export-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ An *implicit repository* containing the project artifact and project dependencie

## Configuration Properties

|Configuration Property | Description |
| --- | --- |
|`bndruns` | Can contain `bndrun` child elements naming a bndrun file to export. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bndrun files. These are relative to the `${project.basedir}` directory. _Defaults to `<include>*.bndrun</include>`._|
|`targetDir` | The director into which to export the result. _Defaults to `${project.build.directory}`._|
|`resolve` | Whether to resolve the `-runbundles` required for a valid runtime. _Defaults to `false`._|
|`failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._|
|`exporter` | The name of the exporter plugin to use. Bnd has two built-in exporter plugins. `bnd.executablejar` exports an executable jar and `bnd.runbundles` exports the `-runbundles` files. _Default to `bnd.executablejar`._|
|`bundles` | A collection of files to include in the *implicit repository*. Can contain `bundle` child elements specifying the path to a bundle. These can be absolute paths. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bundles. These are relative to the `${project.basedir}` directory. _Defaults to dependencies in the scopes specified by the `scopes` property, plus the current artifact (if any and `useMavenDependencies` is `true`)._ |
|`useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._|
|`attach` | If `true` then if the exported generates a jar file, the jar file will be attached as an output of the current artifact. _Defaults to `true`._|
|`reportOptional` | If `true`, resolution failure reports (see `resolve`) will include optional requirements. _Defaults to `true`._|
|`scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.export.scopes`.|
|`includeDependencyManagement`| Include `<dependencyManagement>` subject to `scopes` when collecting files to include in the *implicit repository*. _Defaults to `false`._ Override with property `bnd.export.include.dependency.management`.|
|`skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.export.skip`.|
| Configuration Property | Description |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `bndruns` | Can contain `bndrun` child elements specifying a bndrun file to export. These are relative to the `${project.basedir}` directory. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bndrun files in the `bndrunDir` directory. _Defaults to `<include>*.bndrun</include>`._ |
| `bndrunDir` | This directory will be used when locating bndrun files using `include` and `exclude`. _Defaults to `${project.basedir}`_. |
| `targetDir` | The director into which to export the result. _Defaults to `${project.build.directory}`._ |
| `resolve` | Whether to resolve the `-runbundles` required for a valid runtime. _Defaults to `false`._ |
| `failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._ |
| `exporter` | The name of the exporter plugin to use. Bnd has two built-in exporter plugins. `bnd.executablejar` exports an executable jar and `bnd.runbundles` exports the `-runbundles` files. _Default to `bnd.executablejar`._ |
| `bundles` | A collection of files to include in the *implicit repository*. Can contain `bundle` child elements specifying the path to a bundle. These can be absolute paths. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bundles. These are relative to the `${project.basedir}` directory. _Defaults to dependencies in the scopes specified by the `scopes` property, plus the current artifact (if any and `useMavenDependencies` is `true`)._ |
| `useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._ |
| `attach` | If `true` then if the exported generates a jar file, the jar file will be attached as an output of the current artifact. _Defaults to `true`._ |
| `reportOptional` | If `true`, resolution failure reports (see `resolve`) will include optional requirements. _Defaults to `true`._ |
| `scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.export.scopes`. |
| `includeDependencyManagement` | Include `<dependencyManagement>` subject to `scopes` when collecting files to include in the *implicit repository*. _Defaults to `false`._ Override with property `bnd.export.include.dependency.management`. |
| `skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.export.skip`. |
3 changes: 2 additions & 1 deletion maven/bnd-export-maven-plugin/src/it/export/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
<artifactId>bnd-export-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<bndrunDir>${project.basedir}</bndrunDir>
<bndruns>
<bndrun>test.bndrun</bndrun>
<include>test.bndrun</include>
</bndruns>
<failOnChanges>false</failOnChanges>
<resolve>true</resolve>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public class ExportMojo extends AbstractMojo {
@Parameter(property = "bnd.export.include.dependency.management", defaultValue = "false")
private boolean includeDependencyManagement;

/**
* The bndrun files will be read from this directory.
*/
@Parameter(defaultValue = "${project.basedir}")
private File bndrunDir;

@Component
private RepositorySystem system;

Expand All @@ -116,7 +122,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
int errors = 0;

try {
List<File> bndrunFiles = bndruns.getFiles(project.getBasedir(), "*.bndrun");
List<File> bndrunFiles = bndruns.getFiles(bndrunDir, "*.bndrun");

if (bndrunFiles.isEmpty()) {
logger.warn(
Expand Down
24 changes: 13 additions & 11 deletions maven/bnd-resolver-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ An *implicit repository* containing the project artifact and project dependencie

## Configuration Properties

|Configuration Property | Description |
| --- | --- |
|`bndruns` | Can contain `bndrun` child elements naming a bndrun file to resolv. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bndrun files. These are relative to the `${project.basedir}` directory. _Defaults to `<include>*.bndrun</include>`._|
|`failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._|
|`writeOnChanges` | Whether to write the resolved run bundles back to the `-runbundles` property of the `bndrun` file. _Defaults to `true`._|
|`bundles` | A collection of files to include in the *implicit repository*. Can contain `bundle` child elements specifying the path to a bundle. These can be absolute paths. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bundles. These are relative to the `${project.basedir}` directory. _Defaults to dependencies in the scopes specified by the `scopes` property, plus the current artifact (if any and `useMavenDependencies` is `true`)._|
|`useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._|
|`reportOptional` | If `true`, resolution failure reports will include optional requirements. _Defaults to `true`._|
|`scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.resolve.scopes`.|
|`includeDependencyManagement`| Include `<dependencyManagement>` subject to `scopes` when collecting files to include in the *implicit repository*. _Defaults to `false`._ Override with property `bnd.resolve.include.dependency.management`.|
|`skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.resolve.skip`.|
| Configuration Property | Description |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `bndruns` | Can contain `bndrun` child elements specifying a bndrun file to resolve. These are relative to the `${project.basedir}` directory. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bndrun files in the `bndrunDir` directory. _Defaults to `<include>*.bndrun</include>`._ |
| `bndrunDir` | This directory will be used when locating bndrun files using `include` and `exclude`. _Defaults to `${project.basedir}`_. |
| `outputBndrunDir` | The bndrun files will be written to the specified directory. If the specified directory is the same as `bndrunDir`, then any changes to a bndrun files will cause the bndrun file to be overwritten. _Defaults to `${project.basedir}`_. |
| `failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._ |
| `writeOnChanges` | Whether to write the resolved run bundles back to the `-runbundles` property of the `bndrun` file. _Defaults to `true`._ |
| `bundles` | A collection of files to include in the *implicit repository*. Can contain `bundle` child elements specifying the path to a bundle. These can be absolute paths. You can also specify `include` and `exclude` child elements using Ant-style globs to specify bundles. These are relative to the `${project.basedir}` directory. _Defaults to dependencies in the scopes specified by the `scopes` property, plus the current artifact (if any and `useMavenDependencies` is `true`)._ |
| `useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._ |
| `reportOptional` | If `true`, resolution failure reports will include optional requirements. _Defaults to `true`._ |
| `scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.resolve.scopes`. |
| `includeDependencyManagement` | Include `<dependencyManagement>` subject to `scopes` when collecting files to include in the *implicit repository*. _Defaults to `false`._ Override with property `bnd.resolve.include.dependency.management`. |
| `skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.resolve.skip`. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-standalone: ${projectsDirectory}/index/index.xml.gz
-runfw: org.apache.felix.framework;version='[5.4.0,5.4.0]'
-runee: JavaSE-1.8
-runrequires: ${runrequires}
Loading

0 comments on commit 67fbf14

Please sign in to comment.