Skip to content

Forge: assetCompile fails in apps generated with the openapi feature #16707

Closed

Description

@matrei

Expected Behavior

A web application generated by Grails Forge with the openapi feature builds out of the box, including assetCompile, bootWar and bootJar.

Actual Behaviour

assetCompile fails, and bootWar and bootJar fail with it because they depend on it.

The openapi feature adds org.springdoc:springdoc-openapi-starter-webmvc-ui, which brings in the org.webjars:swagger-ui webjar. The asset-pipeline Gradle plugin picks up every webjar on the runtime classpath. The generated assets { excludes = [...] } block covers jquery, bootstrap and bootstrap-icons, but not swagger-ui. So the asset pipeline tries to minify swagger-ui-bundle.js and swagger-ui-es-bundle.js, and Closure Compiler can't parse them:

SEVERE: swagger-ui-es-bundle.unminified.js:3:847210: ERROR - [JSC_UNSUPPORTED_LANGUAGE_FEATURE] This language feature is not currently supported by the compiler: Private elements.
... (30 errors, each printing a line of the minified bundle, so the log runs to tens of MB)
ERROR asset.pipeline.AssetCompiler -- Error compiling assets
java.util.concurrent.ExecutionException: java.lang.RuntimeException: Exception parsing "swagger-ui-es-bundle.unminified.js"
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at asset.pipeline.AssetCompiler.compile(AssetCompiler.groovy:462)
	at asset.pipeline.AssetCompiler.main(AssetCompiler.groovy:265)
Caused by: java.lang.RuntimeException: Exception parsing "swagger-ui-es-bundle.unminified.js"
	at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:148)
	...
Caused by: java.lang.StringIndexOutOfBoundsException: Range [38, 42) out of bounds for length 40
	at java.base/java.lang.String.substring(String.java:2823)
	at com.google.javascript.jscomp.parsing.IRFactory.normalizeString(IRFactory.java:4012)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processTemplateLiteralToken(IRFactory.java:2452)
	...

* What went wrong:
Execution failed for task ':assetCompile' (registered by plugin 'cloud.wondrify.asset-pipeline').
> Process 'command '.../bin/java'' finished with non-zero exit value 1

The asset pipeline doesn't need these files: springdoc serves Swagger UI straight from the webjar. Adding 'webjars/swagger-ui/**' to excludes in the generated build.gradle makes assetCompile pass.

Steps To Reproduce

  1. Generate a web application with the openapi feature, for example grails create-app demo --features=openapi.
  2. Run ./gradlew assetCompile, or ./gradlew bootWar.
  3. The build fails with the error above.

Environment Information

  • Operating System: Linux
  • JDK Version: 21.0.10
  • Gradle: 9.8.0 (generated wrapper)
  • org.webjars:swagger-ui: 5.32.11

Example Application

A freshly generated application, with no changes, reproduces it.

Version

8.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions