Skip to content

Commit c198312

Browse files
authored
Make sure we do not fail validation of scheduling when annotation processor is present in an MP application. (#10846)
1 parent d977cfb commit c198312

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

declarative/codegen/src/main/java/io/helidon/declarative/codegen/scheduling/SchedulingExtension.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,15 @@ private boolean checkAndHasArgument(TypedElementInfo element, TypeName annotatio
352352
private void checkTypeIsService(RegistryRoundContext roundContext, TypeInfo typeInfo) {
353353
Optional<ClassModel.Builder> descriptor = roundContext.generatedType(ctx.descriptorType(typeInfo.typeName()));
354354
if (descriptor.isEmpty()) {
355-
throw new CodegenException("Type annotated with one of the scheduling annotations is not a service itself."
356-
+ " It must be annotated with "
357-
+ SERVICE_ANNOTATION_SINGLETON.classNameWithEnclosingNames() + ".",
358-
typeInfo.originatingElementValue());
355+
// we may be in CDI (as we support the annotations on both CDI beans and Helidon Declarative Services)
356+
// let's just check there is any annotation on the type
357+
if (typeInfo.annotations().isEmpty()) {
358+
throw new CodegenException("Type annotated with one of the scheduling annotations is not a service itself."
359+
+ " It must be annotated with "
360+
+ SERVICE_ANNOTATION_SINGLETON.classNameWithEnclosingNames() + ","
361+
+ " or it must be a CDI bean (in Helidon MP).",
362+
typeInfo.originatingElementValue());
363+
}
359364
}
360365
}
361366

microprofile/scheduling/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@
9898
<artifactId>helidon-common-features-codegen</artifactId>
9999
<version>${helidon.version}</version>
100100
</path>
101+
<path>
102+
<!-- Make sure the build does not fail on scheduling validation even in MP -->
103+
<groupId>io.helidon.declarative</groupId>
104+
<artifactId>helidon-declarative-codegen</artifactId>
105+
<version>${helidon.version}</version>
106+
</path>
101107
</annotationProcessorPaths>
102108
</configuration>
103109
<dependencies>
@@ -111,6 +117,11 @@
111117
<artifactId>helidon-common-features-codegen</artifactId>
112118
<version>${helidon.version}</version>
113119
</dependency>
120+
<dependency>
121+
<groupId>io.helidon.declarative</groupId>
122+
<artifactId>helidon-declarative-codegen</artifactId>
123+
<version>${helidon.version}</version>
124+
</dependency>
114125
</dependencies>
115126
</plugin>
116127
</plugins>

0 commit comments

Comments
 (0)