Skip to content

Commit d4e46af

Browse files
authored
Merge pull request #45231 from mcruzdev/config-web-dep-locator
Convert web-dependency-locator to use @ConfigMapping
2 parents 4311b87 + cbad8d3 commit d4e46af

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

extensions/web-dependency-locator/deployment/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@
9797
<version>${project.version}</version>
9898
</path>
9999
</annotationProcessorPaths>
100-
<compilerArgs>
101-
<arg>-AlegacyConfigRoot=true</arg>
102-
</compilerArgs>
103100
</configuration>
104101
</execution>
105102
</executions>

extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorConfig.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,38 @@
33
import java.util.Map;
44

55
import io.quarkus.runtime.annotations.ConfigDocMapKey;
6-
import io.quarkus.runtime.annotations.ConfigItem;
76
import io.quarkus.runtime.annotations.ConfigRoot;
7+
import io.smallrye.config.ConfigMapping;
8+
import io.smallrye.config.WithDefault;
89

910
/**
1011
* Build time configuration for Web Dependency Locator.
1112
*/
1213
@ConfigRoot
13-
public class WebDependencyLocatorConfig {
14+
@ConfigMapping(prefix = "quarkus.web-dependency-locator")
15+
public interface WebDependencyLocatorConfig {
1416

1517
/**
1618
* If the version reroute is enabled.
1719
*/
18-
@ConfigItem(defaultValue = "true")
19-
public boolean versionReroute;
20+
@WithDefault("true")
21+
boolean versionReroute();
2022

2123
/**
2224
* User defined import mappings
2325
*/
24-
@ConfigItem
2526
@ConfigDocMapKey("module-specifier")
26-
public Map<String, String> importMappings;
27+
Map<String, String> importMappings();
2728

2829
/**
2930
* The directory in the resources which serves as root for the web assets
3031
*/
31-
@ConfigItem(defaultValue = "web")
32-
public String webRoot;
32+
@WithDefault("web")
33+
String webRoot();
3334

3435
/**
3536
* The directory in the resources which serves as root for the app assets
3637
*/
37-
@ConfigItem(defaultValue = "app")
38-
public String appRoot;
38+
@WithDefault("app")
39+
String appRoot();
3940
}

extensions/web-dependency-locator/deployment/src/main/java/io/quarkus/webdependency/locator/deployment/WebDependencyLocatorProcessor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ public void findRelevantFiles(BuildProducer<GeneratedStaticResourceBuildItem> ge
5151
BuildProducer<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedProducer,
5252
WebDependencyLocatorConfig config) throws IOException {
5353

54-
QuarkusClassLoader.visitRuntimeResources(config.webRoot, visit -> {
54+
QuarkusClassLoader.visitRuntimeResources(config.webRoot(), visit -> {
5555
final Path web = visit.getPath();
5656
if (Files.isDirectory(web)) {
5757
hotDeploymentWatchedProducer
58-
.produce(new HotDeploymentWatchedFileBuildItem(config.webRoot + SLASH + STAR + STAR));
58+
.produce(new HotDeploymentWatchedFileBuildItem(config.webRoot() + SLASH + STAR + STAR));
5959
// Find all css and js (under /app)
6060
Path app = web
61-
.resolve(config.appRoot);
61+
.resolve(config.appRoot());
6262

6363
List<Path> cssFiles = new ArrayList<>();
6464
List<Path> jsFiles = new ArrayList<>();
6565

6666
if (Files.exists(app)) {
6767
hotDeploymentWatchedProducer
6868
.produce(new HotDeploymentWatchedFileBuildItem(
69-
config.webRoot + SLASH + config.appRoot + SLASH + STAR + STAR));
69+
config.webRoot() + SLASH + config.appRoot() + SLASH + STAR + STAR));
7070
try (Stream<Path> appstream = Files.walk(app)) {
7171
appstream.forEach(path -> {
7272
if (Files.isRegularFile(path) && path.toString().endsWith(DOT_CSS)) {
@@ -167,23 +167,23 @@ public void findWebDependenciesAndCreateHandler(
167167
if (webjarsLibInfo != null || mvnpmNameLibInfo != null) {
168168

169169
if (webjarsLibInfo != null) {
170-
if (config.versionReroute) {
170+
if (config.versionReroute()) {
171171
routes.produce(createRouteBuildItem(recorder, httpConfig, WEBJARS_PATH, webjarsLibInfo.nameVersionMap));
172172
}
173173
}
174174
if (mvnpmNameLibInfo != null) {
175-
if (config.versionReroute) {
175+
if (config.versionReroute()) {
176176
routes.produce(createRouteBuildItem(recorder, httpConfig, MVNPM_PATH, mvnpmNameLibInfo.nameVersionMap));
177177
}
178178
// Also create a importmap endpoint
179179
Aggregator aggregator = new Aggregator(mvnpmNameLibInfo.jars);
180-
Map<String, String> importMappings = config.importMappings;
181-
if (!importMappings.containsKey(config.appRoot + SLASH)) {
180+
Map<String, String> importMappings = config.importMappings();
181+
if (!importMappings.containsKey(config.appRoot() + SLASH)) {
182182
// Add default for app/
183-
importMappings.put(config.appRoot + SLASH, SLASH + config.appRoot + SLASH);
183+
importMappings.put(config.appRoot() + SLASH, SLASH + config.appRoot() + SLASH);
184184
}
185-
if (!config.importMappings.isEmpty()) {
186-
aggregator.addMappings(config.importMappings);
185+
if (!config.importMappings().isEmpty()) {
186+
aggregator.addMappings(config.importMappings());
187187
}
188188

189189
String importMap = aggregator.aggregateAsJson(false);

extensions/web-dependency-locator/runtime/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
<version>${project.version}</version>
4444
</path>
4545
</annotationProcessorPaths>
46-
<compilerArgs>
47-
<arg>-AlegacyConfigRoot=true</arg>
48-
</compilerArgs>
4946
</configuration>
5047
</execution>
5148
</executions>

0 commit comments

Comments
 (0)