Skip to content

[CLI] new Command: bnd dev & bnd build -watch for continuous build run workflow - #6768

Merged
chrisrueger merged 1 commit into
masterfrom
bnd-dev-command
Sep 30, 2025
Merged

[CLI] new Command: bnd dev & bnd build -watch for continuous build run workflow#6768
chrisrueger merged 1 commit into
masterfrom
bnd-dev-command

Conversation

@chrisrueger

@chrisrueger chrisrueger commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

The goal is to have an IDE-independent live coding workflow known from the javascript / npm world e.g. "vue-cli serve" (see) which starts a dev-webserver and allows for hot code reloading when changes are detected. It should basically do the same what Eclipse "Build automatically" is doing, but without Eclipse. So I can use any text editor VSCode, vim etc.

A workflow could look like:

cd mybndworkspace
bnd dev mywebapp/launch.bndrun

or multiple .bndrun files

cd mybndworkspace
bnd dev mywebapp/launch.bndrun mywebapp/launch2.bndrun

The dev command initially checks if any project needs rebuilding, and if yes it does a full build of the workspace before launching the bndrun files. Otherwise the bndrun files are launched immediately and the workspace is watched for changes and then rebuilt automatically.

This allows e.g. to use another editor for changing java files.

or just continous build and doing the run in a separate shell process

cd mybndworkspace
bnd build --watch & cd mywebapp; bnd run launch.bndrun

This is basically. a combination of the three existing commands:

bnd compile
bnd build
bnd run

The current code is borrowed from the existing class ProjectLauncher.LiveCoding and adapted it for compile-build. ProjectLauncher.LiveCoding is only for .bndrun and detects changes in .bnd / .bndrun or built .jar files and re-installs them. This is fine. What is missing is the same for a compile-build loop which creates the jars which are then detected by ProjectLauncher.LiveCoding

build and parallel build

The build and the new dev command got a (still experimental) -p, --parallel option which can build a workspace in parallel.

Web Apps and tutorials in mind

I am coming from a Web-application background and my goal is the make building web-applications with bnd much easier. I think most of the parts are there already.

So the goal of this new dev command is actually a bnd tutorial which starts with the following commands to:

  1. create a workspace based on a template fragment for a simple web-app
  2. run the dev command to run the app and start developing
bnd add workspace -f demo-webapp -f osgi myworkspace
cd myworkspace
bnd dev launch.bndrun

Current Status

added a new command:

bnd dev [.bndrun...]

This mimics the same as bnd build --watch & bnd run myappbundle/launch.bndrun on the command line. It spawns n threads - one for continous build on changes and n for running one or multiple .bndrun files which reloads the rebuilt bundles.

bns help dev

NAME
  dev                         - Live coding. Run 1..n .bndrun files in the OSGi
                                launcher, and continously rebuild all projects
                                in the workspace when changes are detected. If
                                no bndrun is specified, the current project is
                                used for the run specification. An initial full
                                build is done when one project not built is
                                detected.

SYNOPSIS
   dev [options] <[bndrun...]>

OPTIONS

   [ -e, --exclude <string;> ] - Exclude files by pattern
   [ -f, --force ]            - Force non-incremental
   [ -p, --parallel ]         - Do the initial full build in parallel
                                (Experimental)
   [ -P, --project <string> ] - Path to another project than the current
                                project. Only valid if no bndrun is specified
   [ -s, --synctime <long> ]  -
   [ -t, --test ]             - Build for test
   [ -v, --verbose ]          - prints more processing information
   [ -V, --verify ]           - Verify all the dependencies before launching
                                (runpath, runbundles)
   [ -w, --workspace <string> ] - Use the following workspace

As a quick reference here is how to do this using a full java command using the bnd.jar

java -jar '/path/to/biz.aQute.bnd.jar' -b /path/to/bndworkspace dev mywebapp/launch.bndrun

Adding ways to do a continuous build.
The goal is to have an IDE-independent live coding workflow known from the javascript / npm world e.g. "vue-cli serve" which starts a dev-webserver and allows for hot code reloading when changes are detected.

A workflow could look like:

```
cd mybndworkspace
bnd dev mywebapp/launch.bndrun
```

or multiple .bndrun files

```
cd mybndworkspace
bnd dev mywebapp/launch.bndrun mywebapp/launch2.bndrun
```

or

```
cd mybndworkspace
bnd build --watch & cd mywebapp; bnd run launch.bndrun
```

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger chrisrueger changed the title [CLI] bnd dev / bnd build -watch for continuous build run workflow [CLI] new Command: bnd dev & bnd build -watch for continuous build run workflow Sep 30, 2025
@chrisrueger
chrisrueger merged commit 043dee0 into master Sep 30, 2025
24 checks passed
@chrisrueger
chrisrueger deleted the bnd-dev-command branch September 30, 2025 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant