Skip to content

Commit

Permalink
introduces resolve never option for bnd(run)
Browse files Browse the repository at this point in the history
Sometimes you have e.g. a basic bnd(run) that can be resolved and others
that include that file and add other instructions or bundles. In such a
case developers may hit resolve on reflex and can result in diverging
-rundbundes over time. Resolve never is an option to prevent developers
from accidentally doing this.

Signed-off-by: Juergen Albert <[email protected]>
  • Loading branch information
juergen-albert committed Aug 7, 2024
1 parent 035bab9 commit cd21a96
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ enum ResolveMode {
*/
@SyntaxAnnotation(lead = "Resolve when the runbundles are needed unless there is a cache file that is newer than the bndrun/project & workspace. The cache file has the same name as the project/bndrun file but starts with a '.'")
cache,

/**
* Never resolve
*/
@SyntaxAnnotation(lead = "A Resolve will never take place. Manually resolve will result in error.")
never
}

@SyntaxAnnotation(lead = "Resolve mode defines when resolving takes place. The default, manual, requires a manual step in bndtools. Auto will resolve on save, and beforelaunch runs the resolver before being launched, batchlaunch is like beforelaunch but only in batch mode", example = "'-resolve manual", pattern = "(manual|auto|beforelaunch|batch)")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@org.osgi.annotation.versioning.Version("1.7.0")
@org.osgi.annotation.versioning.Version("1.8.0")
package aQute.bnd.help.instructions;
1 change: 1 addition & 0 deletions biz.aQute.resolve/src/biz/aQute/resolve/Bndrun.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public Collection<Container> getRunbundles() throws Exception {
switch (resolve) {
case auto :
case manual :
case never :
default :
break;

Expand Down
8 changes: 8 additions & 0 deletions biz.aQute.resolve/src/biz/aQute/resolve/RunResolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import aQute.bnd.exceptions.Exceptions;
import aQute.bnd.help.Syntax;
import aQute.bnd.help.instructions.ResolutionInstructions;
import aQute.bnd.help.instructions.ResolutionInstructions.ResolveMode;
import aQute.bnd.help.instructions.ResolutionInstructions.RunStartLevel;
import aQute.bnd.help.instructions.ResolutionInstructions.Runorder;
import aQute.bnd.osgi.BundleId;
Expand Down Expand Up @@ -96,6 +97,13 @@ public static RunResolution resolve(Project project, Processor actualProperties,
*/
public static RunResolution resolve(Project project, Processor actualProperties,
Collection<ResolutionCallback> callbacks, ResolverLogger resolverLogger) {
if (ResolveMode.never.toString()
.equals(project.get(Constants.RESOLVE))) {
return new RunResolution(project, actualProperties, new UnsupportedOperationException(String
.format("Resolve is forbidden here, as %s is set to %s", Constants.RESOLVE,
ResolveMode.never.toString())),
null);
}
if (callbacks == null)
callbacks = Collections.emptyList();
ResolverLogger logger = resolverLogger == null ? ResolverLogger.newLogger(actualProperties, false)
Expand Down
3 changes: 2 additions & 1 deletion docs/_instructions/resolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ The values are:
* `beforelaunch` – Calculate the `-runbundles` on demand. This ignores the value of the `-runbundles` and runs the resolver. The results of the resolver are cached. This cache works by creating a checksum over all the properties of the project.
* `batch` – When running in batch mode, the run bundles will be resolved. In all other modes this will only resolve when the `-runbundles` are empty.
* `cache` – Will use a cache file in the workspace cache. If that file is stale relative to the workspace or project or it does not exist, then the bnd(run) file will be resolved and the result is stored in the cache file.
* `never` – If anybody tries to resolve , the process will throw an `UnsupportedOperationException`. This is intended for manually curated runbundles or where a base file is resolved and other files include them an add some additional instructions. The Excepetion is meant as a clear warning to any developer accidentally resolving the `-runbundles`.



## Example

-resolve beforelaunch
Expand Down

0 comments on commit cd21a96

Please sign in to comment.