vaadin / vaadin-gradle-plugin

Gradle plugin for Vaadin 14 applications. Takes care of front-end build, helps to configure repositories and to create various project and file templates.
Apache License 2.0
31 stars 9 forks source link

Just scan class files. not MANIFEST.MF, LICENSE or any .java #99

Closed stbischof closed 3 years ago

stbischof commented 3 years ago

Desktop (please complete the following information):

Describe the bug ReflectionsClassFinder should only scan class files. at the moment there is to much useless log output

To Reproduce .gradle clean build --debug

Expected behavior just scan class files

org.reflections.ReflectionsException: could not create class object from file META-INF/MANIFEST.MF
        at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:32)
        at org.reflections.Reflections.scan(Reflections.java:253)
        at org.reflections.Reflections.scan(Reflections.java:202)
        at org.reflections.Reflections.<init>(Reflections.java:123)
        at com.vaadin.gradle.ReflectionsClassFinder.<init>(ReflectionsClassFinder.kt:43)
        at com.vaadin.gradle.VaadinUtilsKt.getClassFinder(VaadinUtils.kt:63)
        at com.vaadin.gradle.VaadinUtilsKt.createNodeTasksBuilder(VaadinUtils.kt:157)
        at com.vaadin.gradle.VaadinPrepareFrontendTask.vaadinPrepareFrontend(VaadinPrepareFrontendTask.kt:89)
        at jdk.internal.reflect.GeneratedMethodAccessor624.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
...
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.reflections.ReflectionsException: could not create class file from MANIFEST.MF
        at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:102)
        at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:24)
        at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:30)
        ... 108 more
mvysny commented 3 years ago

Thank you, reproduced on github.com/vaadin/base-starter-gradle v14; simply run ./gradlew --debug.

mvysny commented 3 years ago

The bug is present in the ReflectionsClassFinder: it doesn't configure the Reflections library properly to only process .class files. That class comes from Vaadin 14 and so the bug is present upstream. However, the same bug can not be reproduced with Maven plugin even if running with -X (probably slf4j is missing on classpath and thus the Reflections library logs nothing). That leads me to believe that upstream will not fix this issue.

The ReflectionsClassFinder has been copied out of Vaadin for Gradle plugin 0.17+ anyways; proposed solution is to copy out the class for Gradle plugin 0.14 and patch it locally.

mvysny commented 3 years ago

Thank you, the fix will now be present in a future release of both 14.x (0.14.4.4 or higher) and master (0.18.0.2 or higher).

mvysny commented 3 years ago

The fix is to configure ConfigurationBuilder to only consider *.class files as follows:

setInputsFilter { it!!.endsWith(".class") && !it.endsWith("module-info.class") } // only scan .class files: https://github.com/vaadin/vaadin-gradle-plugin/issues/99

Reopening since the new Vaadin 20 plugin will have the same issue.

mvysny commented 3 years ago

Reported upstream as https://github.com/vaadin/flow/issues/10304

mvysny commented 3 years ago

Upstream bug has been fixed in Vaadin 20; however it has not been fixed in Vaadin 14. Therefore I'm leaving this ticket open.

vaadin-bot commented 3 years ago

This ticket/PR has been released with platform 21.0.0.alpha8. For prerelease versions, it will be included in its final version.

vaadin-bot commented 3 years ago

This ticket/PR has been released with platform 20.0.4. For prerelease versions, it will be included in its final version.