Skip to content

Commit

Permalink
When using Gradle with extensions generating source code (gRPC, Avro.…
Browse files Browse the repository at this point in the history
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix #30288
  • Loading branch information
cescoffier committed Jan 17, 2023
1 parent 832c06f commit 5079fd0
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public Object apply(EvalContext ctx) {
String ctxName = ctx.getName();

List<Path> sourcesDir = DevConsoleManager.getHotReplacementContext().getSourcesDir();
if (ctxName.equals("sourcePackages")) {
if (ctxName.endsWith("sourcePackages")) {
if (disable) {
return Collections.emptyList(); // we need this here because the result needs to be iterable
}
Expand All @@ -938,12 +938,15 @@ public Object apply(EvalContext ctx) {
String lang = sourcePaths.getFileName().toString();
List<String> packages = sourcePackagesForRoot(sourcePaths);
if (!packages.isEmpty()) {
sourcePackagesByLang.put(lang, packages);
// The `replace` is used to avoid invalid JavaScript identifier (using `-`)
// It happens when using Gradle and extensions generating code (Avro, gRPC...)
// See https://github.com/quarkusio/quarkus/issues/30288.
sourcePackagesByLang.put(lang.replace("-", "_"), packages);
}
}
return sourcePackagesByLang;
}
if (ctxName.equals("locationPackages")) {
if (ctxName.endsWith("locationPackages")) {
if (disable) {
return Collections.emptyList(); // we need this here because the result needs to be iterable
}
Expand Down

0 comments on commit 5079fd0

Please sign in to comment.