Repository navigation
Description
The Gradle plugin needs to gather all jars in order to perform a classpath scan and analyze the npm-related java annotations.
Currently, this is done in the vaadinPrepareFrontend task: a set of dependencies is figured out, from that a set of projects, from that a set of assemble tasks producing those jars. However, this does not work reliably:
- Doesn't work for transitive
implementationdependencies - Doesn't work if the jar file was not produced by
assembletask.
Solution is to simplify the code and take advantage of the fact that Gradle can depend on a FileCollection. The line in the VaadinPrepareFrontendTask class will then simplify to
dependsOn(project.configurations.runtimeClasspath.jars)
/**
* Returns the "runtimeClasspath" file collection.
*/
internal val ConfigurationContainer.runtimeClasspath: Configuration
get() = getByName("runtimeClasspath")
/**
* Returns only jar files from given file collection.
*/
internal val Configuration.jars: FileCollection
get() = filter { it.name.endsWith(".jar", true) }See this commit for more details: vaadin/vaadin-gradle-plugin@62211df
(Possible) steps to reproduce:
Have a Gradle multiproject which contains WAR project which implementation-depends on another project which implementation-depends on another project. At the moment the plugin will not not depend on the third project but will still try to read the outcome jar of that project, leading to the following exception:
Caused by: java.lang.IllegalStateException: xyz.jar doesn't exist
at com.vaadin.gradle.GradlePluginAdapter.getClassFinder(GradlePluginAdapter.kt:68)
at com.vaadin.flow.plugin.base.BuildFrontendUtil.prepareFrontend(BuildFrontendUtil.java:137)
at com.vaadin.gradle.VaadinPrepareFrontendTask.vaadinPrepareFrontend(VaadinPrepareFrontendTask.kt:71)
Activity
denis-anisimov commentedon Sep 28, 2021
VaadinPrepareFrontendTaskis in the vaadin/vaadin-gradle-plugin repo along with the gradle plugin code.So should this ticket be created in this repo instead ?
Should I move it there?
mvysny commentedon Sep 29, 2021
Please keep the ticket here. The reason is that there are two codebases:
I have performed the fix on the unofficial plugin; however the same fix needs to be performed on the official plugin as well.
denis-anisimov commentedon Sep 29, 2021
Ah, OK.
Thanks for explanation.
fix: Fix gradle dependency resolution
fix: Fix gradle dependency resolution
fix: Fix gradle dependency resolution (#11984)
fix: Fix gradle dependency resolution (#11984)
fix: Fix gradle dependency resolution (#11984) (#12012)
vaadin-bot commentedon Oct 15, 2021
This ticket/PR has been released with platform 22.0.0.alpha8 and is also targeting the upcoming stable 22.0.0 version.