File tree Expand file tree Collapse file tree 6 files changed +52
-2
lines changed
src/test/java/io/opentelemetry/semconv Expand file tree Collapse file tree 6 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,5 @@ dependencies {
14
14
implementation(" me.champeau.gradle:japicmp-gradle-plugin:0.4.2" )
15
15
// Needed for japicmp but not automatically brought in for some reason.
16
16
implementation(" com.google.guava:guava:32.1.3-jre" )
17
+ implementation(" biz.aQute.bnd:biz.aQute.bnd.gradle:7.0.0" )
17
18
}
Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ import org.gradle.api.provider.Property
9
9
10
10
abstract class OtelJavaExtension {
11
11
abstract val moduleName: Property <String >
12
+ abstract val bundleName: Property <String >
12
13
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ plugins {
8
8
eclipse
9
9
idea
10
10
11
+ id(" biz.aQute.bnd.builder" )
11
12
id(" otel.spotless-conventions" )
12
13
}
13
14
@@ -88,11 +89,17 @@ tasks {
88
89
89
90
manifest {
90
91
attributes(
91
- " Automatic-Module-Name" to otelJava.moduleName,
92
+ " Automatic-Module-Name" to otelJava.moduleName,
92
93
" Built-By" to System .getProperty(" user.name" ),
93
94
" Built-JDK" to System .getProperty(" java.version" ),
94
95
" 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
+ )
96
103
}
97
104
}
98
105
Original file line number Diff line number Diff line change 10
10
archivesName.set(" opentelemetry-semconv-incubating" )
11
11
}
12
12
otelJava.moduleName.set(" io.opentelemetry.semconv.incubating" )
13
+ otelJava.bundleName.set(" OpenTelemetry - Semantic Conventions Incubating" )
13
14
14
15
dependencies {
15
16
api(project(" :semconv" ))
Original file line number Diff line number Diff line change @@ -12,9 +12,13 @@ base {
12
12
archivesName.set(" opentelemetry-semconv" )
13
13
}
14
14
otelJava.moduleName.set(" io.opentelemetry.semconv" )
15
+ otelJava.bundleName.set(" OpenTelemetry - Semantic Conventions" )
15
16
16
17
dependencies {
17
18
compileOnly(" io.opentelemetry:opentelemetry-api" )
18
19
19
20
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" )
20
24
}
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