diff --git a/config/config/pom.xml b/config/config/pom.xml
index e057076288d..4034cb5a790 100644
--- a/config/config/pom.xml
+++ b/config/config/pom.xml
@@ -115,6 +115,9 @@
org.apache.maven.plugins
maven-compiler-plugin
+
+ -Ainject.acceptPreview=true
+
io.helidon.common.features
diff --git a/config/tests/service-registry/pom.xml b/config/tests/service-registry/pom.xml
index 4c535573635..23208c7b0ae 100644
--- a/config/tests/service-registry/pom.xml
+++ b/config/tests/service-registry/pom.xml
@@ -70,6 +70,9 @@
org.apache.maven.plugins
maven-compiler-plugin
+
+ -Ainject.acceptPreview=true
+
io.helidon.inject
diff --git a/examples/inject/basics/pom.xml b/examples/inject/basics/pom.xml
index 2f29aa24431..15e5e3a0c0e 100644
--- a/examples/inject/basics/pom.xml
+++ b/examples/inject/basics/pom.xml
@@ -63,6 +63,7 @@
-Ainject.autoAddNonContractInterfaces=false
-Ainject.debug=false
+ -Ainject.acceptPreview=true
true
diff --git a/examples/inject/interceptors/pom.xml b/examples/inject/interceptors/pom.xml
index bc7515345de..905e1be9de0 100644
--- a/examples/inject/interceptors/pom.xml
+++ b/examples/inject/interceptors/pom.xml
@@ -68,6 +68,9 @@
maven-compiler-plugin
true
+
+ -Ainject.acceptPreview=true
+
io.helidon.inject
diff --git a/examples/inject/providers/pom.xml b/examples/inject/providers/pom.xml
index 3445464e1fb..36d8b744119 100644
--- a/examples/inject/providers/pom.xml
+++ b/examples/inject/providers/pom.xml
@@ -71,6 +71,7 @@
-Ainject.autoAddNonContractInterfaces=true
-Ainject.debug=false
+ -Ainject.acceptPreview=true
diff --git a/inject/processor/src/main/java/io/helidon/inject/processor/BaseAnnotationProcessor.java b/inject/processor/src/main/java/io/helidon/inject/processor/BaseAnnotationProcessor.java
index dced242b201..36d8b1a9e78 100644
--- a/inject/processor/src/main/java/io/helidon/inject/processor/BaseAnnotationProcessor.java
+++ b/inject/processor/src/main/java/io/helidon/inject/processor/BaseAnnotationProcessor.java
@@ -19,18 +19,22 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
import io.helidon.common.types.TypeName;
+import io.helidon.inject.tools.Options;
/**
* Abstract base for all Helidon annotation processing.
*/
abstract class BaseAnnotationProcessor extends AbstractProcessor {
+ private static final AtomicBoolean LOGGED_WARNING = new AtomicBoolean();
private final System.Logger logger = System.getLogger(getClass().getName());
private ActiveProcessorUtils utils;
@@ -53,6 +57,15 @@ public SourceVersion getSupportedSourceVersion() {
public void init(ProcessingEnvironment processingEnv) {
this.utils = new ActiveProcessorUtils(this, processingEnv);
super.init(processingEnv);
+
+ if (!Options.isOptionEnabled(Options.TAG_ACCEPT_PREVIEW)
+ && LOGGED_WARNING.compareAndSet(false, true)) {
+ processingEnv.getMessager()
+ .printMessage(Diagnostic.Kind.WARNING,
+ "Helidon Inject is preview feature, and the API and SPI may be modified in a future"
+ + " revision. It is considered a production feature."
+ + " This warning can be disabled by compiler argument -Ainject.acceptPreview=true");
+ }
}
@Override
diff --git a/inject/tests/interception/pom.xml b/inject/tests/interception/pom.xml
index 53677b8d216..8b9e369e524 100644
--- a/inject/tests/interception/pom.xml
+++ b/inject/tests/interception/pom.xml
@@ -72,6 +72,9 @@
maven-compiler-plugin
true
+
+ -Ainject.acceptPreview=true
+
io.helidon.inject
diff --git a/inject/tests/resources-inject/pom.xml b/inject/tests/resources-inject/pom.xml
index f8dbcace55b..4427bed22f0 100644
--- a/inject/tests/resources-inject/pom.xml
+++ b/inject/tests/resources-inject/pom.xml
@@ -46,12 +46,6 @@
helidon-config-metadata
provided
-
- io.helidon.inject
- helidon-inject-processor
- provided
- true
-
io.helidon.inject
helidon-inject-maven-plugin
@@ -104,6 +98,7 @@
+ -Ainject.acceptPreview=true
true
@@ -130,7 +125,12 @@
-
+
+ io.helidon.inject
+ helidon-inject-processor
+ ${helidon.version}
+
+
io.helidon.common.processor
helidon-common-processor-helidon-copyright
${helidon.version}
diff --git a/inject/tools/src/main/java/io/helidon/inject/tools/Options.java b/inject/tools/src/main/java/io/helidon/inject/tools/Options.java
index be5bcfdc7bc..6ff5f419db9 100644
--- a/inject/tools/src/main/java/io/helidon/inject/tools/Options.java
+++ b/inject/tools/src/main/java/io/helidon/inject/tools/Options.java
@@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import javax.annotation.processing.ProcessingEnvironment;
@@ -36,6 +37,10 @@ public class Options {
* Tag for putting Injection's annotation processing into debug mode.
*/
public static final String TAG_DEBUG = InjectionServices.TAG_DEBUG;
+ /**
+ * Tag to accept this is a preview feature (so no warning is printed).
+ */
+ public static final String TAG_ACCEPT_PREVIEW = "inject.acceptPreview";
/**
* Treat all super types as a contract for a given service type being added.
*/
@@ -84,6 +89,7 @@ private Options() {
* @param processingEnv the processing env
*/
public static void init(ProcessingEnvironment processingEnv) {
+ Objects.requireNonNull(processingEnv);
if (OPTS.isEmpty()) {
OPTS.put(TAG_DEBUG,
String.valueOf(isOptionEnabled(TAG_DEBUG, processingEnv)));
@@ -105,6 +111,7 @@ public static void init(ProcessingEnvironment processingEnv) {
getOption(TAG_IGNORE_UNSUPPORTED_ANNOTATIONS, null, processingEnv));
OPTS.put(TAG_IGNORE_MODULE_USAGE,
getOption(TAG_IGNORE_MODULE_USAGE, null, processingEnv));
+ OPTS.put(TAG_ACCEPT_PREVIEW, getOption(TAG_ACCEPT_PREVIEW, null, processingEnv));
}
}
@@ -146,7 +153,7 @@ static List getOptionStringList(String option) {
/**
* This only supports the subset of options that Injection cares about, and should not be generally used for options.
*
- * @param option the key (assumed to be meaningful to this class)
+ * @param option the key (assumed to be meaningful to this class)
* @param defaultVal the default value used if the associated value is null.
* @return the option value
*/
@@ -158,11 +165,10 @@ private static String getOption(String option,
private static boolean isOptionEnabled(String option,
ProcessingEnvironment processingEnv) {
- if (processingEnv != null) {
- String val = processingEnv.getOptions().get(option);
- if (val != null) {
- return Boolean.parseBoolean(val);
- }
+
+ String val = processingEnv.getOptions().get(option);
+ if (val != null) {
+ return Boolean.parseBoolean(val);
}
return getOption(option, "", processingEnv).equals("true");
@@ -171,11 +177,9 @@ private static boolean isOptionEnabled(String option,
private static String getOption(String option,
String defaultVal,
ProcessingEnvironment processingEnv) {
- if (processingEnv != null) {
- String val = processingEnv.getOptions().get(option);
- if (val != null) {
- return val;
- }
+ String val = processingEnv.getOptions().get(option);
+ if (val != null) {
+ return val;
}
return defaultVal;