From 1cbc07e001b14ac27cdb3e096e45d8239e3e05cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raymond=20Aug=C3=A9?= Date: Sat, 2 Nov 2019 23:55:50 -0400 Subject: [PATCH] [cli] make writeOnChanges configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #3517 Signed-off-by: Raymond Augé --- biz.aQute.bnd.gradle/README.md | 5 +++++ .../src/aQute/bnd/gradle/Resolve.groovy | 13 ++++++++++++- maven/bnd-resolver-maven-plugin/README.md | 1 + .../bnd/maven/resolver/plugin/ResolverMojo.java | 5 ++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/biz.aQute.bnd.gradle/README.md b/biz.aQute.bnd.gradle/README.md index e70250c5d9..e8c9f304c0 100644 --- a/biz.aQute.bnd.gradle/README.md +++ b/biz.aQute.bnd.gradle/README.md @@ -321,6 +321,11 @@ default is `false`. If `true` the build will fail if the resolve process changes the value of the `-runbundles` property. The default is `false`. +### writeOnChanges + +If `true` the build will write changes to the value of the `-runbundles` +property back to the bndrun file. The default is `true`. + ### bndrun The bndrun to be resolved. It can be anything that `Project.file(Object)` diff --git a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Resolve.groovy b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Resolve.groovy index efbfb30ecf..fa25967f24 100644 --- a/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Resolve.groovy +++ b/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Resolve.groovy @@ -59,6 +59,17 @@ public class Resolve extends Bndrun { @Input boolean failOnChanges = false + /** + * Whether resolve changes should be writen back. + * + *

+ * If true, then a change to the current -runbundles + * value will be writen back into the bndrun file. The default is + * true. + */ + @Input + boolean writeOnChanges = true + /** * Whether to report optional requirements. * @@ -91,7 +102,7 @@ public class Resolve extends Bndrun { protected void worker(def run) { logger.info 'Resolving runbundles required for {}', run.getPropertiesFile() try { - def result = run.resolve(failOnChanges, true) + def result = run.resolve(failOnChanges, writeOnChanges) logger.info '{}: {}', Constants.RUNBUNDLES, result } catch (ResolutionException e) { logger.error ResolveProcess.format(e, reportOptional) diff --git a/maven/bnd-resolver-maven-plugin/README.md b/maven/bnd-resolver-maven-plugin/README.md index 1bb91f6243..24a50a54a6 100644 --- a/maven/bnd-resolver-maven-plugin/README.md +++ b/maven/bnd-resolver-maven-plugin/README.md @@ -63,6 +63,7 @@ The `-runee` and `-runrequires` values can be inferred from the maven project as | --- | --- | |`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 `*.bndrun`._| |`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` | This is the collection of files to use for locating bundles during the bndrun resolution. 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's compile and runtime dependencies to the collection of files to use for locating bundles during the bndrun resolution. _Defaults to `true`._| |`reportOptional` | If `true`, resolution failure reports will include optional requirements. _Defaults to `true`._| diff --git a/maven/bnd-resolver-maven-plugin/src/main/java/aQute/bnd/maven/resolver/plugin/ResolverMojo.java b/maven/bnd-resolver-maven-plugin/src/main/java/aQute/bnd/maven/resolver/plugin/ResolverMojo.java index f5158a1db3..a8903567f8 100644 --- a/maven/bnd-resolver-maven-plugin/src/main/java/aQute/bnd/maven/resolver/plugin/ResolverMojo.java +++ b/maven/bnd-resolver-maven-plugin/src/main/java/aQute/bnd/maven/resolver/plugin/ResolverMojo.java @@ -59,6 +59,9 @@ public class ResolverMojo extends AbstractMojo { @Parameter(defaultValue = "true") private boolean failOnChanges; + @Parameter(defaultValue = "true") + private boolean writeOnChanges; + @Parameter(defaultValue = "${project.build.directory}", readonly = true) private File targetDir; @@ -121,7 +124,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { private Operation getOperation() { return (file, runName, run) -> { try { - run.resolve(failOnChanges, true); + run.resolve(failOnChanges, writeOnChanges); } catch (ResolutionException re) { logger.error(ResolveProcess.format(re, reportOptional)); throw re;