services = all(lookup);
+ if (services.size() == 1) {
+ return services.getFirst();
+ }
+ if (services.isEmpty()) {
+ throw new CodegenException("Expected that service registry contains service: " + lookup + ", yet none was found");
+ }
+
+ throw new CodegenException("Expected that service registry contains service: " + lookup
+ + ", yet more than one was found: " + services);
+ }
+}
diff --git a/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/package-info.java b/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/package-info.java
new file mode 100644
index 00000000000..1f616eb568e
--- /dev/null
+++ b/service/inject/maven-plugin/src/main/java/io/helidon/service/inject/maven/plugin/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2023, 2024 Oracle and/or its affiliates.
+ *
+ * Licensed 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * Maven plugin for Helidon Service Inject.
+ *
+ * This plugin should be used by the application - i.e. the actual microservice that is going to be deployed and started.
+ * This plugin will not help when used on a library.
+ *
+ * The plugin generates application binding (mapping of services to injection points they satisfy), and application main class
+ * to avoid lookups (binding), and reflection and resources discovery from classpath (main class).
+ */
+package io.helidon.service.inject.maven.plugin;
diff --git a/service/inject/maven-plugin/src/main/java/module-info.java b/service/inject/maven-plugin/src/main/java/module-info.java
new file mode 100644
index 00000000000..f75f6c19013
--- /dev/null
+++ b/service/inject/maven-plugin/src/main/java/module-info.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2023, 2024 Oracle and/or its affiliates.
+ *
+ * Licensed 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+/**
+ * Injection maven-plugin module.
+ */
+module io.helidon.service.inject.maven.plugin {
+
+ requires io.helidon.builder.api;
+ requires io.helidon.common;
+ requires io.helidon.common.config;
+ requires io.helidon.codegen;
+ requires io.helidon.codegen.scan;
+ requires io.helidon.codegen.compiler;
+ requires io.helidon.service.codegen;
+ requires io.helidon.service.inject.codegen;
+ requires io.helidon.service.inject.api;
+
+ requires maven.artifact;
+ requires maven.model;
+ requires maven.plugin.annotations;
+ requires maven.plugin.api;
+ requires maven.project;
+ requires io.github.classgraph;
+ requires io.helidon.service.metadata;
+
+ exports io.helidon.service.inject.maven.plugin;
+}
diff --git a/service/inject/pom.xml b/service/inject/pom.xml
index a246ccb2276..1d863c4a322 100644
--- a/service/inject/pom.xml
+++ b/service/inject/pom.xml
@@ -40,5 +40,6 @@
codegen
api
inject
+ maven-plugin
diff --git a/service/pom.xml b/service/pom.xml
index 72de3cd13e2..dc67f7c9624 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -25,6 +25,7 @@
io.helidon
helidon-project
4.2.0-SNAPSHOT
+ ../pom.xml
io.helidon.service
diff --git a/service/tests/inject/codegen/src/test/java/io/helidon/service/tests/inject/codegen/InjectCodegenTypesTest.java b/service/tests/inject/codegen/src/test/java/io/helidon/service/tests/inject/codegen/InjectCodegenTypesTest.java
index ed93979fbcb..5856b589df5 100644
--- a/service/tests/inject/codegen/src/test/java/io/helidon/service/tests/inject/codegen/InjectCodegenTypesTest.java
+++ b/service/tests/inject/codegen/src/test/java/io/helidon/service/tests/inject/codegen/InjectCodegenTypesTest.java
@@ -24,8 +24,11 @@
import java.util.Set;
import io.helidon.common.types.TypeName;
+import io.helidon.service.inject.Binding;
import io.helidon.service.inject.InjectConfig;
+import io.helidon.service.inject.InjectRegistryManager;
import io.helidon.service.inject.InjectionMain;
+import io.helidon.service.inject.InjectionPlanBinder;
import io.helidon.service.inject.api.Event;
import io.helidon.service.inject.api.EventManager;
import io.helidon.service.inject.api.FactoryType;
@@ -104,7 +107,10 @@ void testTypes() {
checkField(toCheck, checked, fields, "INJECT_CONFIG", InjectConfig.class);
checkField(toCheck, checked, fields, "INJECT_CONFIG_BUILDER", InjectConfig.Builder.class);
checkField(toCheck, checked, fields, "INJECT_MAIN", InjectionMain.class);
+ checkField(toCheck, checked, fields, "INJECT_BINDING", Binding.class);
checkField(toCheck, checked, fields, "INJECT_REGISTRY", InjectRegistry.class);
+ checkField(toCheck, checked, fields, "INJECT_REGISTRY_MANAGER", InjectRegistryManager.class);
+ checkField(toCheck, checked, fields, "INJECT_PLAN_BINDER", InjectionPlanBinder.class);
// api.* interception types
checkField(toCheck, checked, fields, "INTERCEPT_EXCEPTION", InterceptionException.class);
diff --git a/service/tests/inject/inject/pom.xml b/service/tests/inject/inject/pom.xml
index 3d483dca7b4..7768e2efaf7 100644
--- a/service/tests/inject/inject/pom.xml
+++ b/service/tests/inject/inject/pom.xml
@@ -137,6 +137,22 @@
+
+ io.helidon.service.inject
+ helidon-service-inject-maven-plugin
+ ${helidon.version}
+
+
+ create-application
+
+ create-application
+
+
+
+
+ true
+
+
diff --git a/service/tests/inject/lookup/pom.xml b/service/tests/inject/lookup/pom.xml
index 4ee6d85a335..1d1be68d387 100644
--- a/service/tests/inject/lookup/pom.xml
+++ b/service/tests/inject/lookup/pom.xml
@@ -137,6 +137,22 @@
+
+ io.helidon.service.inject
+ helidon-service-inject-maven-plugin
+ ${helidon.version}
+
+
+ create-application
+
+ create-application
+
+
+
+
+ true
+
+
diff --git a/service/tests/inject/qualified-providers/pom.xml b/service/tests/inject/qualified-providers/pom.xml
index 0772cf44a96..e00b45ef4c1 100644
--- a/service/tests/inject/qualified-providers/pom.xml
+++ b/service/tests/inject/qualified-providers/pom.xml
@@ -127,6 +127,22 @@
+
+ io.helidon.service.inject
+ helidon-service-inject-maven-plugin
+ ${helidon.version}
+
+
+ create-application
+
+ create-application
+
+
+
+
+ true
+
+
diff --git a/service/tests/inject/toolbox/pom.xml b/service/tests/inject/toolbox/pom.xml
index 5cc2a7b0322..84c7f654273 100644
--- a/service/tests/inject/toolbox/pom.xml
+++ b/service/tests/inject/toolbox/pom.xml
@@ -141,6 +141,22 @@
+
+ io.helidon.service.inject
+ helidon-service-inject-maven-plugin
+ ${helidon.version}
+
+
+ create-application
+
+ create-application
+
+
+
+
+ true
+
+
diff --git a/service/tests/inject/toolbox/src/test/java/io/helidon/service/tests/inject/toolbox/ToolBoxTest.java b/service/tests/inject/toolbox/src/test/java/io/helidon/service/tests/inject/toolbox/ToolBoxTest.java
index 5e9b9a6a023..974c976e4c0 100644
--- a/service/tests/inject/toolbox/src/test/java/io/helidon/service/tests/inject/toolbox/ToolBoxTest.java
+++ b/service/tests/inject/toolbox/src/test/java/io/helidon/service/tests/inject/toolbox/ToolBoxTest.java
@@ -150,7 +150,6 @@ void hierarchyOfInjections() {
* This assumes the presence of module(s) + application(s) to handle all bindings, with effectively no lookups!
*/
@Test
- @Disabled("Disabled, as this required maven plugin, to be added in a later PR")
void noServiceActivationRequiresLookupWhenApplicationIsPresent() {
Counter counter = lookupCounter();
long initialCount = counter.count();