Skip to content

Commit

Permalink
extend bnd demo ws for .bndrun usecase
Browse files Browse the repository at this point in the history
- added a .bndrun in the demo.impl bundle which is used to build the executable jar (comparable to building the product)
- added another consumer bundle which
- installed Felix Gogo Shell, so that you can even start the application and type 'hello' in the console to get an output from the service. this is basically now a very simple OSGi application
- changed to Java17
- removed all warnings in Eclipse
  • Loading branch information
chrisrueger committed Feb 1, 2025
1 parent 9330061 commit 8c74a50
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 7 deletions.
11 changes: 11 additions & 0 deletions demo/bnd-workspace/cnf/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cnf</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
8 changes: 6 additions & 2 deletions demo/bnd-workspace/cnf/build.bnd
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Bundle-Version: 1.0.0-SNAPSHOT
-runfw: org.eclipse.osgi
-runee: JavaSE-17

java: java
javac: javac
javac.source: 17
javac.target: 17
javac.debug: on
16 changes: 15 additions & 1 deletion demo/bnd-workspace/cnf/ext/central.mvn
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# Contains all bundles to consume from maven central

org.eclipse.platform:org.eclipse.osgi:3.21.0
org.eclipse.platform:org.eclipse.osgi.util:3.7.300
org.eclipse.platform:org.eclipse.osgi.services:3.12.100

org.apache.felix:org.apache.felix.gogo.command:1.1.2
org.apache.felix:org.apache.felix.gogo.runtime:1.1.6
org.apache.felix:org.apache.felix.gogo.shell:1.1.4


org.osgi:osgi.core:8.0.0
org.osgi:osgi.annotation:8.1.0
org.osgi:org.osgi.service.component.annotations:1.5.1
org.osgi:org.osgi.service.component:1.5.1
org.osgi:org.osgi.util.function:1.1.0
org.apache.felix:org.apache.felix.scr:2.2.12
org.osgi:org.osgi.util.promise:1.3.0


org.commonmark:commonmark:0.22.0
org.commonmark:commonmark-ext-gfm-tables:0.22.0
org.commonmark:commonmark-ext-gfm-tables:0.22.0
17 changes: 17 additions & 0 deletions demo/bnd-workspace/tycho.demo.api/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions demo/bnd-workspace/tycho.demo.api/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tycho.demo.api</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions demo/bnd-workspace/tycho.demo.consumer/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
23 changes: 23 additions & 0 deletions demo/bnd-workspace/tycho.demo.consumer/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tycho.demo.consumer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions demo/bnd-workspace/tycho.demo.consumer/bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-buildpath: \
org.eclipse.osgi.services,\
tycho.demo.api,\
org.apache.felix.gogo.runtime
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2025 Christoph Rüger and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christoph Rüger - extend example for .bndrun
*******************************************************************************/
package org.eclipse.tycho.demo.consumer;

import org.apache.felix.service.command.Descriptor;
import org.eclipse.tycho.demo.api.HelloWorld;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component(property = { "osgi.command.scope=tychodemo", "osgi.command.function=hello"}, service = Object.class, immediate = true)
public class Consumer {

@Reference
private HelloWorld service;

public Consumer() {
System.out.println("Please type 'hello' into the console and press Enter, and magic will happen.");
}


@Descriptor("Says hello, via HelloWorld service")
public void hello() {
service.sayHello();
}


}
17 changes: 17 additions & 0 deletions demo/bnd-workspace/tycho.demo.impl/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions demo/bnd-workspace/tycho.demo.impl/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tycho.demo.impl</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>
10 changes: 6 additions & 4 deletions demo/bnd-workspace/tycho.demo.impl/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-buildpath: osgi.annotation, \
tycho.demo.api, \
tycho.demo.markdown.api,\
org.osgi.service.component.annotations
-buildpath: \
osgi.annotation,\
tycho.demo.api,\
tycho.demo.markdown.api,\
org.osgi.service.component.annotations,\
osgi.core
23 changes: 23 additions & 0 deletions demo/bnd-workspace/tycho.demo.impl/tycho.demo.app.bndrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-runrequires: \
bnd.identity;id='tycho.demo.impl',\
bnd.identity;id='org.apache.felix.gogo.shell',\
bnd.identity;id='org.apache.felix.gogo.command',\
bnd.identity;id='tycho.demo.consumer',\
bnd.identity;id='tycho.demo.markdown.impl'
-runee: JavaSE-17
-runfw: org.eclipse.osgi;version='[3.21.0.v20240717-2103,3.21.0.v20240717-2103]'
-runbundles: \
org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\
org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\
org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.2.12,2.2.13)',\
org.osgi.service.component;version='[1.5.1,1.5.2)',\
org.osgi.util.function;version='[1.1.0,1.1.1)',\
org.osgi.util.promise;version='[1.3.0,1.3.1)',\
tycho.demo.api;version=snapshot,\
tycho.demo.impl;version=snapshot,\
tycho.demo.markdown.api;version=snapshot,\
tycho.demo.consumer;version=snapshot,\
tycho.demo.markdown.impl;version=snapshot
-runproperties: \
osgi.console=
17 changes: 17 additions & 0 deletions demo/bnd-workspace/tycho.demo.markdown/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions demo/bnd-workspace/tycho.demo.markdown/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tycho.demo.markdown</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>

0 comments on commit 8c74a50

Please sign in to comment.