Skip to content

Commit 2e69a7b

Browse files
fix Build fails if quarkus-oidc-client is not in the classpath (#829) (#840)
Co-authored-by: Loïc Hermann <[email protected]>
1 parent 3ad135f commit 2e69a7b

File tree

6 files changed

+417
-2
lines changed

6 files changed

+417
-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

client/integration-tests/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<module>type-mapping</module>
4141
<module>config-key</module>
4242
<module>github</module>
43+
<module>without-oidc</module>
4344
</modules>
4445
<dependencyManagement>
4546
<dependencies>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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>io.quarkus</groupId>
22+
<artifactId>quarkus-rest-client-jackson</artifactId>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.assertj</groupId>
26+
<artifactId>assertj-core</artifactId>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.quarkus</groupId>
31+
<artifactId>quarkus-junit5</artifactId>
32+
<scope>test</scope>
33+
</dependency>
34+
</dependencies>
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<groupId>io.quarkus</groupId>
39+
<artifactId>quarkus-maven-plugin</artifactId>
40+
<extensions>true</extensions>
41+
<executions>
42+
<execution>
43+
<goals>
44+
<goal>build</goal>
45+
<goal>generate-code</goal>
46+
<goal>generate-code-tests</goal>
47+
</goals>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
<profiles>
54+
<profile>
55+
<id>native-image</id>
56+
<activation>
57+
<property>
58+
<name>native</name>
59+
</property>
60+
</activation>
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<artifactId>maven-surefire-plugin</artifactId>
65+
<configuration>
66+
<skipTests>${native.surefire.skip}</skipTests>
67+
</configuration>
68+
</plugin>
69+
<plugin>
70+
<artifactId>maven-failsafe-plugin</artifactId>
71+
<executions>
72+
<execution>
73+
<goals>
74+
<goal>integration-test</goal>
75+
<goal>verify</goal>
76+
</goals>
77+
<configuration>
78+
<systemPropertyVariables>
79+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
80+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
81+
<maven.home>${maven.home}</maven.home>
82+
</systemPropertyVariables>
83+
</configuration>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
<properties>
90+
<quarkus.package.type>native</quarkus.package.type>
91+
</properties>
92+
</profile>
93+
</profiles>
94+
95+
</project>

0 commit comments

Comments
 (0)