Skip to content

Commit

Permalink
Merge pull request #3518 from rotty3000/writeOnChanges
Browse files Browse the repository at this point in the history
[cli] make writeOnChanges configurable
  • Loading branch information
rotty3000 authored Nov 3, 2019
2 parents 17f24db + 1cbc07e commit a6aed53
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions biz.aQute.bnd.gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down
13 changes: 12 additions & 1 deletion biz.aQute.bnd.gradle/src/aQute/bnd/gradle/Resolve.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public class Resolve extends Bndrun {
@Input
boolean failOnChanges = false

/**
* Whether resolve changes should be writen back.
*
* <p>
* If <code>true</code>, then a change to the current -runbundles
* value will be writen back into the bndrun file. The default is
* <code>true</code>.
*/
@Input
boolean writeOnChanges = true

/**
* Whether to report optional requirements.
*
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions maven/bnd-resolver-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<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` | 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`._|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a6aed53

Please sign in to comment.