Skip to content

Commit 5e5b061

Browse files
chrisruegermerkslaeubi
committed
add bndtools workspace template fragment
Update BndBuild.md Apply suggestions from code review Co-Authored-By: Ed Merks <[email protected]> Co-Authored-By: Christoph Läubrich <[email protected]> (cherry picked from commit ff5dbb6)
1 parent a416275 commit 5e5b061

File tree

6 files changed

+121
-4
lines changed

6 files changed

+121
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
[![Build Tycho](https://github.com/eclipse-tycho/tycho/actions/workflows/maven.yml/badge.svg)](https://github.com/eclipse-tycho/tycho/actions/workflows/maven.yml) [![Unit Test Results](https://github.com/eclipse-tycho/tycho/actions/workflows/check.yml/badge.svg)](https://github.com/eclipse-tycho/tycho/actions/workflows/check.yml) [![License check](https://github.com/eclipse-tycho/tycho/actions/workflows/licensecheck.yml/badge.svg)](https://github.com/eclipse-tycho/tycho/actions/workflows/licensecheck.yml)
55

6-
Tycho is a manifest-first way to build
6+
Tycho is an IDE-first way to build:
77

8-
* Eclipse plug-ins/OSGi bundles
8+
* Eclipse plug-ins / OSGi bundles
99
* Features
1010
* Update sites/p2 repositories
1111
* RCP applications
12-
13-
with Maven.
12+
* bnd workspaces
1413

14+
with Maven.
1515

1616
* 👔 Eclipse project entry: https://projects.eclipse.org/projects/technology.tycho
1717
* 🗒️ Documentation:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Tycho Workspace template fragment for bndtools for pomless Maven build
2+
3+
This is a [bndtools template fragment](https://bnd.bndtools.org/chapters/620-template-fragments.html) which you can use in a new or existing bndtools workspace,
4+
to add a Maven build based on Eclipse Tycho for your bnd workspace.
5+
6+
It creates a `.mvn` folder in your bnd workspace root, contain an `extensions.xml` and a `maven.config`.
7+
8+
See documentation for the [Tycho BND Plugin](https://tycho.eclipseprojects.io/doc/main/BndBuild.html) for more information.
9+
10+
## Building your workspace
11+
12+
```
13+
cd mybndworkspace
14+
mvn clean install
15+
```
16+
17+
This is all you need to build your bnd workspace with Maven / Tycho.
18+
19+
It will automatically consider all `bnd.bnd` files.
20+
21+
22+
## Optional configurator pom.xml
23+
24+
While the default build is pomless, you can create a parent `pom.xml` in your `cnf` folder.
25+
It can be as simple as the following:
26+
27+
```xml
28+
<?xml version="1.0" encoding="UTF-8"?>
29+
<project xmlns="http://maven.apache.org/POM/4.0.0"
30+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
31+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
32+
<modelVersion>4.0.0</modelVersion>
33+
<groupId>com.example.mygroup</groupId>
34+
<artifactId>parent</artifactId>
35+
<version>1.0.0-SNAPSHOT</version>
36+
<packaging>pom</packaging>
37+
</project>
38+
```
39+
40+
This is useful if you want to add other maven plugins to your build, e.g., for code analysis or reporting.
41+
42+
## Create executable jar based on .bndrun files
43+
44+
Tycho can also create an executable `.jar` file of your application based on the `.bndrun` file containing `-runbundles`, which you can then deploy and start.
45+
46+
Just add the following line to your `.mvn/maven.config` file or pass it on the maven commandline:
47+
48+
```
49+
-Dbndrun.exports=mydemo.app
50+
```
51+
52+
See [Create executable jar](https://tycho.eclipseprojects.io/doc/main/BndBuild.html#Create_executable_jar) for details.
53+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<extensions>
3+
<extension>
4+
<groupId>org.eclipse.tycho</groupId>
5+
<artifactId>tycho-build</artifactId>
6+
<version>${tycho-version}</version>
7+
</extension>
8+
</extensions>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Dtycho-version=4.0.11

src/site/markdown/BndBuild.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ A BND Workspace layout build layout usually has the following structure:
1313
- `bnd.bnd` - project configuration file
1414
- `bundle2` - Another bundle project
1515
- `bnd.bnd` - project configuration file
16+
- `myapp.bndrun` - a .bndrun file which can be used to export an executable .jar as part of the build
1617
- `...`
1718

1819
Any folder that does not match the layout is ignored.
@@ -51,6 +52,55 @@ If you want to further configure the build can be done in these ways:
5152
2. You can define properties per project properties in the `bnd.bnd` file `pom.model.property.<some property>: true`, see [the wiki](https://github.com/eclipse-tycho/tycho/wiki/Tycho-Pomless#overwrite-group-and-artifact-ids) for more details.
5253
3. You can place a `pom.xml` in your `cnf` folder this will then be used as a parent for the aggregator, here you can add additional mojos, profiles and so on. If you want to enable certain things only for some of the projects you can use properties as described in (2) to skip the execution of mojos not relevant for other projects.
5354

55+
#### Create executable jar
56+
57+
Tycho can also create an executable `.jar` file of your application based on a `.bndrun` file containing `-runbundles`, which you can then deploy and start.
58+
59+
Just add the following line to your `.mvn/maven.config` file or pass it on the maven commandline:
60+
61+
```
62+
-Dbndrun.exports=mydemo.app
63+
```
64+
65+
This automatically searches all your bundles for a file named `mydemo.app.bndrun`.
66+
67+
If you have a bundle `myappbundle` which contains `mydemo.app.bndrun`, then the build would create an executable jar at the following location:
68+
69+
`/myappbundle/target/executable/mydemo.app.bndrun.jar`
70+
71+
Your build output will look like this:
72+
73+
```
74+
[INFO] --- tycho-bnd:4.0.11:run (build) @ myappbundle ---
75+
[INFO] Exporting mydemo.app.bndrun ...
76+
[INFO] Exported to .../myappbundle/target/executable/tycho.demo.app.jar
77+
```
78+
79+
5480
## Mixed Builds
5581

5682
You can even combine a BND Workspace and PDE bundles in a build, see [demo](https://github.com/eclipse-tycho/tycho/tree/master/demo/bnd-pde-workspace).
83+
84+
85+
## Troubleshooting
86+
87+
Note: All properties in `.mvn/maven.config` can also be supplied via command line, for example to use a different tycho version use the following command line argument:
88+
89+
`mvn clean install -Dtycho-version=5.0.0-SNAPSHOT`
90+
91+
This uses the snapshot build which is useful if you build tycho yourself on your local machine and want to test that build.
92+
93+
94+
### polyglot.dump.pom
95+
96+
E.g., `-Dpolyglot.dump.pom=pom-gen.xml` specifies that the generated pom.xml files which tycho polyglot creates is called `pom-gen.xml`.
97+
This might be needed if you have name clashes with existing files in your build.
98+
99+
100+
### tycho.pomless.aggregator.names
101+
102+
The command line argument `-Dtycho.pomless.aggregator.names=_dummydisabled_` is for handling a rare edge case:
103+
In case you have your bnd workspace in a subfolder named `bundles`, `plugins`, `tests`,`features`, `sites`,`products`, or `releng` then tycho can have problems.
104+
The reason is that those names are kind of 'magic' names reserved for special usecases.
105+
`-Dtycho.pomless.aggregator.names=_dummydisabled_` is a workaround to instruct Tycho to ignore those names. You can choose any word like `_dummydisabled_`, but just make sure you do not have a folder with that name.
106+

src/site/site.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
<custom>
5555
<fluidoSkin>
5656
<sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
57+
<gitHub>
58+
<projectId>eclipse-tycho/tycho</projectId>
59+
<ribbonOrientation>right</ribbonOrientation>
60+
<ribbonColor>gray</ribbonColor>
61+
</gitHub>
5762
</fluidoSkin>
5863
</custom>
5964
</site>

0 commit comments

Comments
 (0)