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 quarkusio#30288
  • Loading branch information
cescoffier authored and michelle-purcell committed Jan 17, 2023
1 parent 69edabb commit ddba0e3
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 ddba0e3

Please sign in to comment.