diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abd0d40e..574cc821 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,4 +46,4 @@ jobs: java-version: ${{matrix.java}} - name: build with maven - run: mvn verify + run: mvn -ntp verify diff --git a/api/bnd.bnd b/api/bnd.bnd index 83941087..24b6cd26 100644 --- a/api/bnd.bnd +++ b/api/bnd.bnd @@ -1,12 +1,30 @@ -exportcontents: \ org.eclipse.microprofile.* -Import-Package: \ - javax.enterprise.util;version="[1.1,3)", \ - * - Bundle-SymbolicName: org.eclipse.microprofile.config # For reproducible builds -noextraheaders: true -snapshot: SNAPSHOT + +# Apply OSGi Portable Java Contracts [1] with "active" effectiveness so that +# they are not strict runtime requirements. This removes the need to import +# packages with versions. +-contract: *;effective:=active + +# Simulate the JavaCDI contract since the compile dependencies used do not +# provide them. +-define-contract: \ + osgi.contract;\ + osgi.contract=JavaCDI;\ + version:List='2.0,1.1';\ + uses:='\ + javax.decorator,\ + javax.enterprise.context,\ + javax.enterprise.context.spi,\ + javax.enterprise.event,\ + javax.enterprise.inject,\ + javax.enterprise.inject.spi,\ + javax.enterprise.util' + +# [1] https://www.osgi.org/portable-java-contract-definitions/ \ No newline at end of file diff --git a/api/pom.xml b/api/pom.xml index b952c564..84d04152 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -23,15 +23,16 @@ 2.0-SNAPSHOT - - 5.0.0 - org.eclipse.microprofile.config microprofile-config-api MicroProfile Config API MicroProfile Config :: API https://microprofile.io/project/eclipse/microprofile-config + + biz.aQute.bnd + biz.aQute.bnd.annotation + jakarta.enterprise jakarta.enterprise.cdi-api @@ -39,9 +40,11 @@ org.osgi - org.osgi.annotation.versioning - 1.1.0 - provided + org.osgi.service.cdi + + + org.osgi + osgi.annotation diff --git a/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java b/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java index f146d760..e8bde216 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java +++ b/api/src/main/java/org/eclipse/microprofile/config/inject/ConfigProperty.java @@ -24,6 +24,8 @@ import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.osgi.annotation.bundle.Requirement.Resolution.OPTIONAL; +import static org.osgi.service.cdi.CDIConstants.CDI_EXTENSION_PROPERTY; import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -31,6 +33,8 @@ import javax.enterprise.util.Nonbinding; import javax.inject.Qualifier; +import org.osgi.annotation.bundle.Requirement; + /** *

* Binds the injection point with a configured value. @@ -100,6 +104,15 @@ @Qualifier @Retention(RUNTIME) @Target({METHOD, FIELD, PARAMETER, TYPE}) +/* + * Two @Requirement annotations are defined so that the result is a _weak requirement_. + * One requirement is resolution:=optional which means that at runtime, if satisfied, + * it will be wired, otherwise it is simply ignored. Another requirement is + * effective:=active which means it is not visible at runtime, but applicable during + * assembly where an effectviness of _active_ is specified. + */ +@Requirement(namespace = CDI_EXTENSION_PROPERTY, name = "org.eclipse.microprofile.config", effective = "active") +@Requirement(namespace = CDI_EXTENSION_PROPERTY, name = "org.eclipse.microprofile.config", resolution = OPTIONAL) public @interface ConfigProperty { String UNCONFIGURED_VALUE="org.eclipse.microprofile.config.configproperty.unconfigureddvalue"; /** diff --git a/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java b/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java index 28661dc9..20752ffc 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java +++ b/api/src/main/java/org/eclipse/microprofile/config/inject/package-info.java @@ -42,8 +42,8 @@ * * @author Mark Struberg * @author Emily Jiang - * + * */ -@org.osgi.annotation.versioning.Version("1.0") +@org.osgi.annotation.versioning.Version("1.0.1") package org.eclipse.microprofile.config.inject; diff --git a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java index 9ee6dc9e..8ca71808 100644 --- a/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java +++ b/api/src/main/java/org/eclipse/microprofile/config/spi/ConfigProviderResolver.java @@ -25,6 +25,8 @@ import org.eclipse.microprofile.config.Config; +import aQute.bnd.annotation.spi.ServiceConsumer; + /** * The service provider for implementations of the MicroProfile Configuration specification. *

@@ -36,6 +38,16 @@ * @author Romain Manni-Bucau * @author Emily Jiang */ + +/* + * The @ServiceConsumer annotation adds support for Service Loader Mediator in + * order to support wiring of Service Loader providers to consumers in OSGi. + * However, the requirements generated are specified as effective:=active to + * prevent this from being a strict requirement. As such the API is usable in + * runtimes without a Service Loader Mediator implementation while allowing for + * such to be enabled when using the resolver during assembly. + */ +@ServiceConsumer(value = ConfigProviderResolver.class, effective = "active") public abstract class ConfigProviderResolver { /** * Construct a new instance. diff --git a/pom.xml b/pom.xml index 2d785efb..9aded505 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ https://osgi.org/javadoc/osgi.annotation/7.0.0/ + 5.0.1 2.17 ^_?[a-z][a-zA-Z0-9]*$ @@ -102,9 +103,14 @@ tck spec - + + biz.aQute.bnd + biz.aQute.bnd.annotation + ${bnd.version} + provided + jakarta.enterprise jakarta.enterprise.cdi-api @@ -123,6 +129,18 @@ import pom + + org.osgi + org.osgi.service.cdi + 1.0.0 + provided + + + org.osgi + osgi.annotation + 7.0.0 + provided + diff --git a/tck/pom.xml b/tck/pom.xml index 5afe64d5..ebd623cd 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -54,6 +54,19 @@ provided + + biz.aQute.bnd + biz.aQute.bnd.annotation + + + org.osgi + org.osgi.service.cdi + + + org.osgi + osgi.annotation + + jakarta.enterprise jakarta.enterprise.cdi-api @@ -69,7 +82,6 @@ true - org.apache.geronimo.specs geronimo-atinject_1.0_spec @@ -89,7 +101,7 @@ - + junit @@ -122,7 +134,7 @@ compile - + @@ -151,7 +163,7 @@ - + eclipse-jarsigner