devsoap/ds-gradle-vaadin

ClassIntrospectionUtils.findJsModules doesn't find elements that are not in a @Route annotated class

Closed this issue · 4 comments

Desktop (please complete the following information):

  • OS: Linux
  • JDK version: 11
  • Gradle version: 5.6
  • Vaadin Plugin version: 1.3

Describe the bug
We use form components generated by an ioc framework. Those components are not directly used in @Route annotated views. This prevents the compoents from working.
The problem seems to be in ClassIntrospectionUtils.findJsModules.

Added a new scanning strategy 'whitelist' which allows to change the classpath search to restrict the search to the whitelist instead of traversing the class hierarchy from the root route.

When using the 'whitelist' scanning strategy all found components which conforms to the whitelist will be included in the bundle. This is why it is recommended to manually configure the vaadin.whitelistedPackages property so that it only lists packages which has the wanted components in the bundle. By default the whitelist will contain the 'com.vaadin' root package as well as all packages in the project.

For example:

vaadin.scanStrategy = 'whitelist'
vaadin.whitelistedPackages = [
        'com.vaadin.flow.component.orderedlayout',
        'my.project.root.package'
]

This would only include the ordered layouts as well as your project packages.

Looks good so far (w/o testing). Is there an easy way to test snapshots? Are they public available?

There are no snapshots available but it should be quite easy to test locally by building the project locally from master sources. The generic way of doing it is:

  1. git clone https://github.com/devsoap/gradle-vaadin-flow.git
  2. In the project directory run gradle jar -> the plugin will be created in build/libs
  3. Follow the steps in https://github.com/devsoap/gradle-vaadin-flow/blob/master/CONTRIBUTING.md#using-the-plugin-from-a-test-project to apply the locally built plugin in your project.

I'll probably release this feature in a plugin update next weekend if you rather wait for a binary build.

Sorry, I wasn't able to test before… Looks good so far.
Thanks!