File tree Expand file tree Collapse file tree
src/test/java/io/opentelemetry/semconv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,4 +14,5 @@ dependencies {
1414 implementation(" me.champeau.gradle:japicmp-gradle-plugin:0.4.2" )
1515 // Needed for japicmp but not automatically brought in for some reason.
1616 implementation(" com.google.guava:guava:32.1.3-jre" )
17+ implementation(" biz.aQute.bnd:biz.aQute.bnd.gradle:7.0.0" )
1718}
Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ import org.gradle.api.provider.Property
99
1010abstract class OtelJavaExtension {
1111 abstract val moduleName: Property <String >
12+ abstract val bundleName: Property <String >
1213}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ plugins {
88 eclipse
99 idea
1010
11+ id(" biz.aQute.bnd.builder" )
1112 id(" otel.spotless-conventions" )
1213}
1314
@@ -88,11 +89,17 @@ tasks {
8889
8990 manifest {
9091 attributes(
91- " Automatic-Module-Name" to otelJava.moduleName,
92+ " Automatic-Module-Name" to otelJava.moduleName,
9293 " Built-By" to System .getProperty(" user.name" ),
9394 " Built-JDK" to System .getProperty(" java.version" ),
9495 " Implementation-Title" to project.base.archivesName,
95- " Implementation-Version" to project.version)
96+ " Implementation-Version" to project.version,
97+ // Add OSGi manifest headers with bnd
98+ " -exportcontents" to " ${otelJava.moduleName.get()} .*" ,
99+ " Bundle-Name" to otelJava.bundleName,
100+ " Bundle-SymbolicName" to " ${otelJava.moduleName.get()} .${project.base.archivesName.get()} " ,
101+ " Import-Package" to " io.opentelemetry.api.*;resolution:=optional" // FIXME: should not be optional, dependency should be provided
102+ )
96103 }
97104 }
98105
Original file line number Diff line number Diff line change 1010 archivesName.set(" opentelemetry-semconv-incubating" )
1111}
1212otelJava.moduleName.set(" io.opentelemetry.semconv.incubating" )
13+ otelJava.bundleName.set(" OpenTelemetry - Semantic Conventions Incubating" )
1314
1415dependencies {
1516 api(project(" :semconv" ))
Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ base {
1212 archivesName.set(" opentelemetry-semconv" )
1313}
1414otelJava.moduleName.set(" io.opentelemetry.semconv" )
15+ otelJava.bundleName.set(" OpenTelemetry - Semantic Conventions" )
1516
1617dependencies {
1718 compileOnly(" io.opentelemetry:opentelemetry-api" )
1819
1920 testImplementation(" io.opentelemetry:opentelemetry-api" )
21+ // FIXME: dependency and version should not be managed here
22+ testImplementation(" org.apache.felix:org.apache.felix.framework:7.0.5" )
23+ testImplementation(" org.osgi:osgi.core:6.0.0" )
2024}
Original file line number Diff line number Diff line change 1+ package io .opentelemetry .semconv ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+
5+ import java .io .File ;
6+ import java .util .HashMap ;
7+ import java .util .Map ;
8+ import org .apache .felix .framework .Felix ;
9+ import org .junit .jupiter .api .Test ;
10+ import org .osgi .framework .Bundle ;
11+ import org .osgi .framework .BundleContext ;
12+ import org .osgi .framework .BundleException ;
13+ import org .osgi .framework .Constants ;
14+ import org .osgi .framework .launch .Framework ;
15+
16+ class OSGiBundleTest {
17+ @ Test
18+ void bundleIsActive () throws BundleException {
19+ Map <String ,String > params = new HashMap <String , String >();
20+ // FIXME: do not use hardcoded build path
21+ params .put (Constants .FRAMEWORK_STORAGE , "build" );
22+
23+ Framework framework = new Felix (params );
24+ framework .init ();
25+ framework .start ();
26+
27+ BundleContext context = framework .getBundleContext ();
28+ // FIXME: do not use hardcoded bundle path
29+ File bundleFile = new File ("build/libs/opentelemetry-semconv-1.27.0-alpha-SNAPSHOT.jar" );
30+
31+ Bundle bundle = context .installBundle (bundleFile .toURI ().toString ());
32+ bundle .start ();
33+
34+ assertEquals (Bundle .ACTIVE , bundle .getState ());
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments