This is an automated email from the ASF dual-hosted git repository.

alien11689 pushed a commit to branch 
ARIES-2172-support-jakarta-enterprise-cdi-api-in-blueprint-maven-plugin
in repository https://gitbox.apache.org/repos/asf/aries.git

commit 1592f5211057363415d7692d19faedcabde4f249
Author: Dominik Przybysz <[email protected]>
AuthorDate: Mon Mar 10 20:10:47 2025 +0100

    ARIES-2172: Support jakarta.enterprise.cdi-api in blueprint-maven-plugin
---
 .github/dependabot.yaml                            |  3 ++
 .../blueprint-maven-plugin/pom.xml                 |  6 ++++
 .../plugin/handlers/jakarta/ProducesHandler.java   | 29 +++++++++++++++
 ....aries.blueprint.plugin.spi.FactoryMethodFinder |  1 +
 .../blueprint/plugin/BlueprintFileWriterTest.java  | 21 +++++++++++
 .../plugin/jakarta/JakartaFactoryBean.java         | 42 ++++++++++++++++++++++
 .../blueprint/plugin/jakarta/ProducedBean.java     | 22 ++++++++++++
 7 files changed, 124 insertions(+)

diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml
index 7f21fd35f..96cc1c328 100644
--- a/.github/dependabot.yaml
+++ b/.github/dependabot.yaml
@@ -34,6 +34,9 @@ updates:
       - dependency-name: "jakarta.annotation:jakarta.annotation-api"
         versions:
           - ">=3.0.0" # does not support java 8
+      - dependency-name: "jakarta.enterprise:jakarta.enterprise.cdi-api"
+        versions:
+          - ">=4.0.0" # does not support java 8
       - dependency-name: "javax.enterprise:cdi-api"
         versions:
           - ">2.0.SP1" # 2.0-PFD2 is considered as newer, but is older
diff --git a/blueprint-maven-plugin/blueprint-maven-plugin/pom.xml 
b/blueprint-maven-plugin/blueprint-maven-plugin/pom.xml
index e55a7a8e9..d97bec6da 100644
--- a/blueprint-maven-plugin/blueprint-maven-plugin/pom.xml
+++ b/blueprint-maven-plugin/blueprint-maven-plugin/pom.xml
@@ -43,6 +43,7 @@
         
<blueprint-maven-plugin-spi.version>1.1.0</blueprint-maven-plugin-spi.version>
         
<blueprint-maven-plugin-spring-handlers.version>1.0.0</blueprint-maven-plugin-spring-handlers.version>
         <jakarta.annotation-api.version>2.1.1</jakarta.annotation-api.version>
+        
<jakarta.enterprise.cdi-api.version>3.0.1</jakarta.enterprise.cdi-api.version>
         <jakarta.inject.version>2.0.1</jakarta.inject.version>
         <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
         
<javax.enterprise.cdi-api.version>2.0.SP1</javax.enterprise.cdi-api.version>
@@ -156,6 +157,11 @@
             <artifactId>cdi-api</artifactId>
             <version>${javax.enterprise.cdi-api.version}</version>
         </dependency>
+        <dependency>
+            <groupId>jakarta.enterprise</groupId>
+            <artifactId>jakarta.enterprise.cdi-api</artifactId>
+            <version>${jakarta.enterprise.cdi-api.version}</version>
+        </dependency>
         <dependency>
             <groupId>javax.persistence</groupId>
             <artifactId>persistence-api</artifactId>
diff --git 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/jakarta/ProducesHandler.java
 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/jakarta/ProducesHandler.java
new file mode 100644
index 000000000..78579e8fd
--- /dev/null
+++ 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/handlers/jakarta/ProducesHandler.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.plugin.handlers.jakarta;
+
+import jakarta.enterprise.inject.Produces;
+import org.apache.aries.blueprint.plugin.spi.FactoryMethodFinder;
+
+public class ProducesHandler implements FactoryMethodFinder<Produces> {
+    @Override
+    public Class<Produces> getAnnotation() {
+        return Produces.class;
+    }
+}
diff --git 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.FactoryMethodFinder
 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.FactoryMethodFinder
index f7a308931..4b468b716 100644
--- 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.FactoryMethodFinder
+++ 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/main/resources/META-INF/services/org.apache.aries.blueprint.plugin.spi.FactoryMethodFinder
@@ -15,5 +15,6 @@
 # limitations under the License.
 #
 
+org.apache.aries.blueprint.plugin.handlers.jakarta.ProducesHandler
 org.apache.aries.blueprint.plugin.handlers.javax.ProducesHandler
 org.apache.aries.blueprint.plugin.handlers.blueprint.bean.BeanHandler
\ No newline at end of file
diff --git 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
index f4dae170c..6ab1fb4bd 100644
--- 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
+++ 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/BlueprintFileWriterTest.java
@@ -48,7 +48,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import com.google.common.collect.Sets;
+import org.apache.aries.blueprint.plugin.jakarta.JakartaFactoryBean;
 import org.apache.aries.blueprint.plugin.jakarta.NamedJakartaBean;
+import org.apache.aries.blueprint.plugin.jakarta.ProducedBean;
 import org.apache.aries.blueprint.plugin.jakarta.SimpleJakartaBean;
 import org.apache.aries.blueprint.plugin.jakarta.SimpleJakartaBeanUsage;
 import 
org.apache.aries.blueprint.plugin.jakarta.SimpleJakartaBeanUsageViaField;
@@ -1430,6 +1432,25 @@ public class BlueprintFileWriterTest {
         assertXpathEquals(injectingBeanViaFields, "property[@name='c']/@ref", 
"test-named-jakarta-bean");
     }
 
+    @Test
+    public void testJakartaProducesNamedBeans() throws Exception {
+        Node producer = getBeanById("jakartaFactoryBean");
+        assertXpathEquals(producer, "@class", 
JakartaFactoryBean.class.getName());
+
+        Node bean1 = getBeanById("producedBean");
+        assertXpathEquals(bean1, "@class", ProducedBean.class.getName());
+        assertXpathEquals(bean1, "@factory-ref", "jakartaFactoryBean");
+        assertXpathEquals(bean1, "@factory-method", "create");
+
+        Node bean2 = getBeanById("namedProducedBean");
+        assertXpathEquals(bean2, "@class", ProducedBean.class.getName());
+        assertXpathEquals(bean2, "@factory-ref", "jakartaFactoryBean");
+        assertXpathEquals(bean2, "@factory-method", 
"createBeanWithParameters");
+        assertXpathEquals(bean2, "argument[1]/@ref", "myBean1");
+        assertXpathEquals(bean2, "argument[2]/@value", "100");
+        assertXpathEquals(bean2, "argument[3]/@ref", "refServiceC");
+    }
+
     private void assertXpathDoesNotExist(Node node, String xpathExpression) 
throws XPathExpressionException {
         assertXpathEquals(node, "count(" + xpathExpression + ")", "0");
     }
diff --git 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/jakarta/JakartaFactoryBean.java
 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/jakarta/JakartaFactoryBean.java
new file mode 100644
index 000000000..157d87467
--- /dev/null
+++ 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/jakarta/JakartaFactoryBean.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.plugin.jakarta;
+
+import jakarta.enterprise.inject.Produces;
+import jakarta.inject.Named;
+import jakarta.inject.Singleton;
+import org.apache.aries.blueprint.annotation.config.ConfigProperty;
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.plugin.test.MyBean1;
+import org.apache.aries.blueprint.plugin.test.interfaces.ServiceC;
+
+@Singleton
+public class JakartaFactoryBean {
+
+    @Produces
+    public ProducedBean create() {
+        return new ProducedBean();
+    }
+
+    @Produces
+    @Named("namedProducedBean")
+    public ProducedBean createBeanWithParameters(MyBean1 myBean1, 
@ConfigProperty("100") int bla, @Reference @Named("refServiceC") ServiceC 
myReference) {
+        return new ProducedBean();
+    }
+}
diff --git 
a/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/jakarta/ProducedBean.java
 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/jakarta/ProducedBean.java
new file mode 100644
index 000000000..f30901297
--- /dev/null
+++ 
b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/jakarta/ProducedBean.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.plugin.jakarta;
+
+public class ProducedBean {
+}

Reply via email to