Skip to content

Commit 67fbf14

Browse files
committed
maven: Support resolving bndrun files to an output folder
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 <[email protected]>
1 parent b9da98e commit 67fbf14

File tree

20 files changed

+348
-46
lines changed

20 files changed

+348
-46
lines changed

maven/bnd-export-maven-plugin/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@ An *implicit repository* containing the project artifact and project dependencie
5454

5555
## Configuration Properties
5656

57-
|Configuration Property | Description |
58-
| --- | --- |
59-
|`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>`._|
60-
|`targetDir` | The director into which to export the result. _Defaults to `${project.build.directory}`._|
61-
|`resolve` | Whether to resolve the `-runbundles` required for a valid runtime. _Defaults to `false`._|
62-
|`failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._|
63-
|`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`._|
64-
|`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`)._ |
65-
|`useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._|
66-
|`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`._|
67-
|`reportOptional` | If `true`, resolution failure reports (see `resolve`) will include optional requirements. _Defaults to `true`._|
68-
|`scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.export.scopes`.|
69-
|`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`.|
70-
|`skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.export.skip`.|
57+
| Configuration Property | Description |
58+
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
59+
| `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>`._ |
60+
| `bndrunDir` | This directory will be used when locating bndrun files using `include` and `exclude`. _Defaults to `${project.basedir}`_. |
61+
| `targetDir` | The director into which to export the result. _Defaults to `${project.build.directory}`._ |
62+
| `resolve` | Whether to resolve the `-runbundles` required for a valid runtime. _Defaults to `false`._ |
63+
| `failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._ |
64+
| `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`._ |
65+
| `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`)._ |
66+
| `useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._ |
67+
| `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`._ |
68+
| `reportOptional` | If `true`, resolution failure reports (see `resolve`) will include optional requirements. _Defaults to `true`._ |
69+
| `scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.export.scopes`. |
70+
| `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`. |
71+
| `skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.export.skip`. |

maven/bnd-export-maven-plugin/src/it/export/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
<artifactId>bnd-export-maven-plugin</artifactId>
1717
<version>${bnd.version}</version>
1818
<configuration>
19+
<bndrunDir>${project.basedir}</bndrunDir>
1920
<bndruns>
20-
<bndrun>test.bndrun</bndrun>
21+
<include>test.bndrun</include>
2122
</bndruns>
2223
<failOnChanges>false</failOnChanges>
2324
<resolve>true</resolve>

maven/bnd-export-maven-plugin/src/main/java/aQute/bnd/maven/export/plugin/ExportMojo.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ public class ExportMojo extends AbstractMojo {
9696
@Parameter(property = "bnd.export.include.dependency.management", defaultValue = "false")
9797
private boolean includeDependencyManagement;
9898

99+
/**
100+
* The bndrun files will be read from this directory.
101+
*/
102+
@Parameter(defaultValue = "${project.basedir}")
103+
private File bndrunDir;
104+
99105
@Component
100106
private RepositorySystem system;
101107

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

118124
try {
119-
List<File> bndrunFiles = bndruns.getFiles(project.getBasedir(), "*.bndrun");
125+
List<File> bndrunFiles = bndruns.getFiles(bndrunDir, "*.bndrun");
120126

121127
if (bndrunFiles.isEmpty()) {
122128
logger.warn(

maven/bnd-resolver-maven-plugin/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ An *implicit repository* containing the project artifact and project dependencie
6363

6464
## Configuration Properties
6565

66-
|Configuration Property | Description |
67-
| --- | --- |
68-
|`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>`._|
69-
|`failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._|
70-
|`writeOnChanges` | Whether to write the resolved run bundles back to the `-runbundles` property of the `bndrun` file. _Defaults to `true`._|
71-
|`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`)._|
72-
|`useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._|
73-
|`reportOptional` | If `true`, resolution failure reports will include optional requirements. _Defaults to `true`._|
74-
|`scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.resolve.scopes`.|
75-
|`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`.|
76-
|`skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.resolve.skip`.|
66+
| Configuration Property | Description |
67+
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
68+
| `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>`._ |
69+
| `bndrunDir` | This directory will be used when locating bndrun files using `include` and `exclude`. _Defaults to `${project.basedir}`_. |
70+
| `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}`_. |
71+
| `failOnChanges` | Whether to fail the build if any change in the resolved `-runbundles` is discovered. _Defaults to `true`._ |
72+
| `writeOnChanges` | Whether to write the resolved run bundles back to the `-runbundles` property of the `bndrun` file. _Defaults to `true`._ |
73+
| `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`)._ |
74+
| `useMavenDependencies` | If `true`, adds the project dependencies subject to `scopes` to the collection of files to include in the *implicit repository*. _Defaults to `true`._ |
75+
| `reportOptional` | If `true`, resolution failure reports will include optional requirements. _Defaults to `true`._ |
76+
| `scopes` | Specify from which scopes to collect dependencies. _Defaults to `compile, runtime`._ Override with property `bnd.resolve.scopes`. |
77+
| `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`. |
78+
| `skip` | Skip the project. _Defaults to `false`._ Override with property `bnd.resolve.skip`. |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-standalone: ${projectsDirectory}/index/index.xml.gz
2+
-runfw: org.apache.felix.framework;version='[5.4.0,5.4.0]'
3+
-runee: JavaSE-1.8
4+
-runrequires: ${runrequires}

0 commit comments

Comments
 (0)