Skip to content

Commit 07a8381

Browse files
committed
fix Build fails if quarkus-oidc-client is not in the classpath
1 parent 5eb1b18 commit 07a8381

File tree

6 files changed

+413
-2
lines changed

6 files changed

+413
-2
lines changed

client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/GeneratorProcessor.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.quarkiverse.openapi.generator.deployment;
22

3+
import static io.quarkus.bootstrap.classloading.QuarkusClassLoader.isClassPresentAtRuntime;
4+
35
import java.util.Collection;
46
import java.util.List;
57
import java.util.Map;
@@ -48,9 +50,10 @@ public class GeneratorProcessor {
4850
private static final DotName BASIC_AUTHENTICATION_MARKER = DotName.createSimple(BasicAuthenticationMarker.class);
4951
private static final DotName BEARER_AUTHENTICATION_MARKER = DotName.createSimple(BearerAuthenticationMarker.class);
5052
private static final DotName API_KEY_AUTHENTICATION_MARKER = DotName.createSimple(ApiKeyAuthenticationMarker.class);
51-
5253
private static final DotName OPERATION_MARKER = DotName.createSimple(OperationMarker.class);
5354

55+
private static final String ABSTRACT_TOKEN_PRODUCER = "io.quarkus.oidc.client.runtime.AbstractTokensProducer";
56+
5457
@BuildStep
5558
FeatureBuildItem feature() {
5659
return new FeatureBuildItem(FEATURE);
@@ -61,6 +64,10 @@ void additionalBean(
6164
Capabilities capabilities,
6265
BuildProducer<AdditionalBeanBuildItem> producer) {
6366

67+
if (!isClassPresentAtRuntime(ABSTRACT_TOKEN_PRODUCER)) {
68+
//return;
69+
}
70+
6471
if (capabilities.isPresent(Capability.REST_CLIENT_REACTIVE)) {
6572
producer.produce(
6673
AdditionalBeanBuildItem.builder().addBeanClass(ReactiveOidcClientRequestFilterDelegate.class)
@@ -103,10 +110,15 @@ void produceCompositeProviders(AuthenticationRecorder recorder,
103110

104111
@BuildStep
105112
@Record(ExecutionTime.STATIC_INIT)
106-
void produceOauthAuthentication(CombinedIndexBuildItem beanArchiveBuildItem,
113+
void produceOauthAuthentication(
114+
CombinedIndexBuildItem beanArchiveBuildItem,
107115
BuildProducer<AuthProviderBuildItem> authenticationProviders,
108116
BuildProducer<SyntheticBeanBuildItem> beanProducer,
109117
AuthenticationRecorder recorder) {
118+
119+
if (!isClassPresentAtRuntime(ABSTRACT_TOKEN_PRODUCER)) {
120+
//return;
121+
}
110122
Collection<AnnotationInstance> authenticationMarkers = beanArchiveBuildItem.getIndex()
111123
.getAnnotationsWithRepeatable(OAUTH_AUTHENTICATION_MARKER, beanArchiveBuildItem.getIndex());
112124

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<parent>
4+
<artifactId>quarkus-openapi-generator-parent</artifactId>
5+
<groupId>io.quarkiverse.openapi.generator</groupId>
6+
<version>3.0.0-SNAPSHOT</version>
7+
<relativePath>../../pom.xml</relativePath>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>quarkus-openapi-generator-it-without-oidc</artifactId>
12+
<name>Quarkus - Openapi Generator - Integration Tests - Client - Without OIDC</name>
13+
<description>Example project for general usage</description>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.quarkiverse.openapi.generator</groupId>
18+
<artifactId>quarkus-openapi-generator</artifactId>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.assertj</groupId>
22+
<artifactId>assertj-core</artifactId>
23+
<scope>test</scope>
24+
</dependency>
25+
<dependency>
26+
<groupId>io.quarkus</groupId>
27+
<artifactId>quarkus-junit5</artifactId>
28+
<scope>test</scope>
29+
</dependency>
30+
</dependencies>
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>io.quarkus</groupId>
35+
<artifactId>quarkus-maven-plugin</artifactId>
36+
<extensions>true</extensions>
37+
<executions>
38+
<execution>
39+
<goals>
40+
<goal>build</goal>
41+
<goal>generate-code</goal>
42+
<goal>generate-code-tests</goal>
43+
</goals>
44+
</execution>
45+
</executions>
46+
</plugin>
47+
</plugins>
48+
</build>
49+
<profiles>
50+
<profile>
51+
<id>native-image</id>
52+
<activation>
53+
<property>
54+
<name>native</name>
55+
</property>
56+
</activation>
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<artifactId>maven-surefire-plugin</artifactId>
61+
<configuration>
62+
<skipTests>${native.surefire.skip}</skipTests>
63+
</configuration>
64+
</plugin>
65+
<plugin>
66+
<artifactId>maven-failsafe-plugin</artifactId>
67+
<executions>
68+
<execution>
69+
<goals>
70+
<goal>integration-test</goal>
71+
<goal>verify</goal>
72+
</goals>
73+
<configuration>
74+
<systemPropertyVariables>
75+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
76+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
77+
<maven.home>${maven.home}</maven.home>
78+
</systemPropertyVariables>
79+
</configuration>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
<properties>
86+
<quarkus.package.type>native</quarkus.package.type>
87+
</properties>
88+
</profile>
89+
</profiles>
90+
91+
</project>

0 commit comments

Comments
 (0)