kordamp / jandex-gradle-plugin Goto Github PK
View Code? Open in Web Editor NEWJandex Gradle Plugin
License: Apache License 2.0
Jandex Gradle Plugin
License: Apache License 2.0
Description:
The "jandex" task will build the "jandex.idx" file once, and then appears to never build it again as long as it exists. At initial glance in the source, the "@InputFiles" field appears to be wired up to an empty file collection, which, if I understand Gradle correctly, implies that as long as the output exists, the task will pass the up-to-date check.
The "jandex" task ought to rebuild the "jandex.idx" when the class files that Jandex is indexing have changed.
Reproducer:
https://github.com/jskillin-idt/kordamp-jandex-gradle-plugin-issues-24
Steps to reproduce:
./gradlew build
and observe the "printMethods" task gives the list of methods present in src/main/java/com/sample/Test.java
./gradlew build
again. Observe the "printMethods" task continues to give the old list of methods, despite src/main/java/com/sample/Test.java
having been rewritten with new methods.Currently main
sourceset is hardcoded, so test
classes can't be verified
Using this:
plugins {
id 'org.kordamp.gradle.jandex' version '0.9.0'
}
I'm getting:
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve org.apache.maven:maven-model-builder:3.6.3.
Required by:
project : > org.kordamp.gradle.jandex:org.kordamp.gradle.jandex.gradle.plugin:0.9.0 > org.kordamp.gradle:jandex-gradle-plugin:0.9.0 > org.kordamp.gradle:base-gradle-plugin:0.42.1
> Could not resolve org.apache.maven:maven-model-builder:3.6.3.
> Could not get resource 'https://plugins.gradle.org/m2/org/apache/maven/maven-model-builder/3.6.3/maven-model-builder-3.6.3.pom'.
> Could not GET 'https://jcenter.bintray.com/org/apache/maven/maven-model-builder/3.6.3/maven-model-builder-3.6.3.pom'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
gradle 7.0.2 complains about implicit dependency
Task :dao:compileTestJava
Execution optimizations have been disabled for task ':dao:compileTestJava' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/Users/fsousa/Projects/ipb/gdoc2/dao/build/resources/main'. Reason: Task ':dao:compileTestJava' uses this output of task ':dao:jandex' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
While a useful message when implementing, it isn't helpful during normal builds. What about moving this to logger.info
instead of being displayed to the console by default?
> Task :caffeine:jandex
Index has been written to /Users/ben/projects/caffeine/caffeine/build/resources/main/META-INF/jandex.idx
Running this with Gradle 7.5-rc-1
and Java 18.
Getting the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/gradle/internal/classpath/Instrumented at org.kordamp.gradle.plugin.jandex.tasks.JandexMain$ClassFileVisitor.indexFile(JandexMain.java:172) at org.kordamp.gradle.plugin.jandex.tasks.JandexMain$ClassFileVisitor.visitFile(JandexMain.java:160) at org.kordamp.gradle.plugin.jandex.tasks.JandexMain$ClassFileVisitor.visitFile(JandexMain.java:147) at java.base/java.nio.file.Files.walkFileTree(Files.java:2812) at java.base/java.nio.file.Files.walkFileTree(Files.java:2883) at org.kordamp.gradle.plugin.jandex.tasks.JandexMain.execute(JandexMain.java:98) at org.kordamp.gradle.plugin.jandex.tasks.JandexMain.run(JandexMain.java:124) at org.kordamp.gradle.plugin.jandex.tasks.JandexMain.main(JandexMain.java:111) Caused by: java.lang.ClassNotFoundException: org.gradle.internal.classpath.Instrumented at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 8 more
It seems that this plugin doesn't support the gradle configuration. Any plan to support it?
- Task `:platform:runtime:quarkus:base:jandex` of type `org.kordamp.gradle.plugin.jandex.tasks.JandexTask`: cannot serialize object of type 'org.gradle.api.internal.artifacts.configurations.DefaultUnlockedConfiguration', a subtype of 'org.gradle.api.artifacts.Configuration', as these are not supported with the configuration cache.
See https://docs.gradle.org/8.5/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
Hi!
I'm having problem to build using the version 0.10.0.
My gradle files:
setting.grade
pluginManagement {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
plugins {
id 'io.quarkus' version "${quarkusPluginVersion}"
id 'org.kordamp.gradle.jandex' version "${jandexVersion}"
id 'com.palantir.docker' version "${palantirVersion}"
id 'com.palantir.docker-run' version "${palantirVersion}"
id 'com.github.spotbugs' version "${spotbugsVersion}"
}
}
gralde.properties
quarkusPluginVersion=1.13.4.Final
quarkusPlatformVersion=1.13.4.Final
jandexVersion=0.10.0
palantirVersion=0.26.0
spotbugsVersion=4.7.1
build.gradle
plugins {
id 'io.quarkus' apply false
id 'org.kordamp.gradle.jandex'
id 'com.github.spotbugs'
id 'jacoco'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
subprojects {
apply plugin: 'java'
apply plugin: 'io.quarkus'
apply plugin: 'org.kordamp.gradle.jandex'
apply plugin: 'com.github.spotbugs'
apply plugin: 'jacoco'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation platform("io.quarkus:quarkus-bom:${quarkusPlatformVersion}")
implementation platform("org.testcontainers:testcontainers-bom:${testcontainersVersion}")
implementation 'io.quarkus:quarkus-resteasy'
implementation 'io.quarkus:quarkus-resteasy-jackson'
implementation 'io.quarkus:quarkus-hibernate-orm-panache'
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}
// other configs like spotbug, tests, jacoco...
}
tasks.named('wrapper') {
gradleVersion = "7.0.2"
}
When I try to build i have this results:
[mq-1]$ ./gradlew --version
------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------
Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.11 (Red Hat, Inc. 11.0.11+9)
OS: Linux 5.11.19-100.fc32.x86_64 amd64
[mq-1]$ ./gradlew clean assemble
> Configure project :
> Task :jandex FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jandex'.
> Could not resolve all files for configuration ':jandex'.
> Cannot resolve external dependency org.jboss:jandex:2.2.2.Final because no repositories are defined.
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
10 actionable tasks: 1 executed, 9 up-to-date
[mq-1]$
The 'sources' property (as suggested by the documentation) unfortunately doesn't seem to exist. The following build.gradle
file:
plugins {
id("org.kordamp.gradle.jandex") version "0.8.0"
}
jandex {
sources = project.fileTree(dir: project.buildDir, includes: ["com/vaadin/flow/**/*.class"])
}
fails with:
Caused by: groovy.lang.MissingPropertyException: Could not set unknown property 'sources' for task ':jandex' of type org.kordamp.gradle.plugin.jandex.tasks.JandexTask.
at org.gradle.internal.metaobject.AbstractDynamicObject.setMissingProperty(AbstractDynamicObject.java:118)
at org.gradle.internal.metaobject.ConfigureDelegate.setProperty(ConfigureDelegate.java:104)
at build_12tm7plxy8ai7aiiasft8wf8p$_run_closure1.doCall(/home/mavi/work/inacta/vaadin-jandex/build.gradle:34)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Quarkus version: 2.11.3
Gradle: 7.5.1
> io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.deployment.index.ApplicationArchiveBuildStep#build threw an exception: org.jboss.jandex.UnsupportedVersion: Can't read index version 11; this IndexReader only supports index versions 2-3,6-10
at org.jboss.jandex.IndexReader.initReader(IndexReader.java:87)
at org.jboss.jandex.IndexReader.readVersion(IndexReader.java:140)
at org.jboss.jandex.IndexReader.getIndexVersion(IndexReader.java:127)
at io.quarkus.deployment.index.IndexingUtil$MetaInfJandexReader.apply(IndexingUtil.java:244)
at io.quarkus.deployment.index.IndexingUtil$MetaInfJandexReader.apply(IndexingUtil.java:230)
at io.quarkus.paths.PathTreeVisit.process(PathTreeVisit.java:40)
at io.quarkus.paths.DirectoryPathTree.apply(DirectoryPathTree.java:106)
at io.quarkus.paths.ArchivePathTree$OpenArchivePathTree.apply(ArchivePathTree.java:202)
at io.quarkus.paths.PathTreeWithManifest.apply(PathTreeWithManifest.java:73)
at io.quarkus.deployment.index.IndexingUtil.indexTree(IndexingUtil.java:61)
at io.quarkus.deployment.index.ApplicationArchiveBuildStep.lambda$addMarkerFilePaths$1(ApplicationArchiveBuildStep.java:251)
at io.quarkus.bootstrap.classloading.PathTreeClassPathElement.apply(PathTreeClassPathElement.java:111)
at io.quarkus.deployment.index.ApplicationArchiveBuildStep.addMarkerFilePaths(ApplicationArchiveBuildStep.java:2[38](https://gitlab.com/bizzi-group/bizzi-pay/bizzi-payment-backend-java/-/jobs/3038231999#L38))
at io.quarkus.deployment.index.ApplicationArchiveBuildStep.scanForOtherIndexes(ApplicationArchiveBuildStep.java:144)
at io.quarkus.deployment.index.ApplicationArchiveBuildStep.build(ApplicationArchiveBuildStep.java:105)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:[43](https://gitlab.com/bizzi-group/bizzi-pay/bizzi-payment-backend-java/-/jobs/3038231999#L43))
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:977)
at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2[44](https://gitlab.com/bizzi-group/bizzi-pay/bizzi-payment-backend-java/-/jobs/3038231999#L44)9)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1[47](https://gitlab.com/bizzi-group/bizzi-pay/bizzi-payment-backend-java/-/jobs/3038231999#L47)8)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:[50](https://gitlab.com/bizzi-group/bizzi-pay/bizzi-payment-backend-java/-/jobs/3038231999#L50)1)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org/
BUILD FAILED in 7m 13s
Please add a file path to the exception message so it is clear which file can't be parsed.
Sample jandex
issues: smallrye/jandex#92 , smallrye/jandex#80
Unfortunately, jandex
consumes InputStream
, so it can't reliably produce meaningful exception messages :-(
Hi
After I've tried to update to version 0.13.0 of the jandex-gradle-plugin I've encountered an issue with compatibility to the jandex version, due to Helidon version 2.5.1 only being compatible with Jandex 2.3.x (Version 9), resulting in
Caused by: org.jboss.jandex.UnsupportedVersion: Version: 10
To fix this I've been trying to change the version of Jandex, but it seems that version 0.13.0 of the gradle plugin is only compatible with Jandex 2.4.3.Final, since java.util.Map org.jboss.jandex.ClassInfo.annotationsMap()
is only available as of that version and results in the following, whenever the version is changed to something else:
Execution failed for task ':jandex'.
> A failure occurred while executing org.kordamp.gradle.plugin.jandex.tasks.JandexWorkAction
> 'java.util.Map org.jboss.jandex.ClassInfo.annotationsMap()'
Not sure, how to fix this since java.util.Map org.jboss.jandex.ClassInfo.annotations
is deprecated.
Mirror of smallrye/jandex#137
Java version
java version 21.0.1 Amazon Corretto
Gradle version
8.5
Operating system
MacOS
Hello guys.
I would like to raport that I have the same issue as this one here bug-jandex-maven-plugin while use jandex-gradle-plugin.
From what I see, maven plugin has been fixed and now uses
<jandex.version>3.1.6</jandex.version>
while gradle plugin still uses old version of jar
jandexVersion = 3.0.5
As the issue is exactly the same, my question is: are you planning to upgrade jar version with proper fix? Because currently while using gradle-plugin we are forced to set version to 3.1.6 with this block:
jandex {
version.set("3.1.6")
}
Thank you for any response!
I can't seem to be able to include additional directory for Jandex indexing. The following build.gradle:
plugins {
id("org.kordamp.gradle.jandex") version "0.8.0"
}
jandex {
fileSets = project.fileTree(dir: project.buildDir, includes: ["com/vaadin/flow/**/*.class"])
}
fails with:
* What went wrong:
Execution failed for task ':jandex'.
> Cannot convert the provided notation to a File or URI: directory '/home/mavi/work/inacta/vaadin-jandex/build'.
The following types/formats are supported:
- A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
- A String or CharSequence URI, for example 'file:/usr/include'.
- A File instance.
- A Path instance.
- A Directory instance.
- A RegularFile instance.
- A URI or URL instance.
- A TextResource instance.
Could you please give me a hand and tell me how to include additional folder with classes to index?
The plugin adds index file unconditionally, however, that would result in issues when dependency shading is used.
For instance, if different libraries add their own indices, then dependency shading would overwrite/duplicate index files.
I guess it would be nice to avoid adding the index file to the resulting jar file.
The jandex
task would still be useful as it ensures the bytecode is jandex-parseable.
Hello,
I have a Quarkus based project using Gradle, and wanted to update from Gradle 6.8
to 7
.
I am simply registering the plugin id:
plugins {
id 'org.kordamp.gradle.jandex' version '0.9.0'
}
Now I build time, I get the following warnings:
> Task :core:jar
Execution optimizations have been disabled for task ':core:jar' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: 'C:\path\to\project\core\build\resources\main'. Reason: Task ':core:jar' uses this output of task ':core:jandex' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
I get it for tasks compileTestJava
, test
, jacocoTestReport
...
If I add an explicit dependency like this:
jar {
dependsOn 'jandex'
}
It seems to solve the issue. However, I am not sure if we should do this explicitly, or if the plugin should do it auto-magically...
It's a private project that I cannot share, but I can try things out if needed :)
When I change from 1.0.0
to 1.1.0
I get the following error:
Caused by: java.lang.ClassCastException: class org.kordamp.gradle.plugin.jandex.Banner$Inject cannot be cast to class org.kordamp.gradle.plugin.jandex.Banner (org.kordamp.gradle.plugin.jandex.Banner$Inject is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @2bab28a6; org.kordamp.gradle.plugin.jandex.Banner is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @146b18e4)
at org.kordamp.gradle.plugin.jandex.JandexPlugin.apply(JandexPlugin.groovy:45)
at org.kordamp.gradle.plugin.jandex.JandexPlugin.apply(JandexPlugin.groovy)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:187)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:52)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:282)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:167)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:166)
... 174 more
Running with --quiet
seems to get past the error.
I have a mono-repo of Quarkus modules:
The Parent (app) module A
Child module Y
Child module Z
A depends on Y
A depends on Z
No dependencies between Y and Z
Module A (and A's QuarkusTests) can import/instantiate application
scoped beans defined modules Y and Z, "if" the Y and Z build.gradle.kts
files' plugins specs include:
id("org.kordamp.gradle.jandex") version "1.1.0"
But now I cannot compile (for dev/test) modules Y or Z (alone), unless I comment out
// id("org.kordamp.gradle.jandex") version "1.1.0"
from their build files.
I get Gradle error:
Reason: Task ':y-service:pluginUnderTestMetadata' uses this output of task ':y-service:jandex' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':y-service:jandex' as an input of ':y-service:pluginUnderTestMetadata'.
2. Declare an explicit dependency on ':y-service:jandex' from ':y-service:pluginUnderTestMetadata' using Task#dependsOn.
3. Declare an explicit dependency on ':y-service:jandex' from ':y-service:pluginUnderTestMetadata' using Task#mustRunAfter.
My multi-module app&test (A) works fine if I use the jandex plugin in child modules Y and Z.
But I cannot work on child modules Y and Z in isolation if Y and Z are using the jandex plugin.
I am using quarkusPlatformVersion=3.8.3, Gradle version 8.7 (build files written in Kotlin DSL), JDK 21
I have searched around for reports of similar problem, but have found none. I can work around this by commenting/uncommenting the plugin def as needed, but would like better solution. Can anyone advise?
Hi, Jandex maintainer here. Thanks for maintaining this Gradle plugin!
I'd like to bring up the topic of Jandex 3.0. There's a bunch of changes, some of them breaking. The full list is available in the issue tracker: https://github.com/smallrye/jandex/milestone/3 and there will be detailed release announcement coming (the release should be in a few days).
Two of those changes are relevant to this project:
org.jboss
to io.smallrye
.Indexer.index()
method now returns void
.I can see two ways how this plugin could support Jandex 3.0:
Indexer
class in Jandex 3.0 will carry a synthetic index()
method returning ClassInfo
(which will always be null
). Hence, compatibility should be achievable.I believe that long term, migrating to Jandex 3.0 (1st option) is in everyone's best interest, but short term, the 2nd option seems like a good idea. When invoking Indexer.index()
, this Gradle plugin actually already checks if the result is null
, so using this Jandex Gradle plugin compiled against Jandex 2.4 with Jandex 3.0 at runtime should work. There will just be no logging, which I think is acceptable. The only change required would likely be in the JandexPlugin
class, where the jandex
configuration is created. This change should be enough:
jandexConfiguration.defaultDependencies(new Action<DependencySet>() {
@Override
void execute(DependencySet dependencies) {
String version = jandexExtension.version.get()
if (version.startsWith("2.") || version.startsWith("1.")) {
dependencies.add(project.dependencies.create('org.jboss:jandex:' + version))
} else {
dependencies.add(project.dependencies.create('io.smallrye:jandex:' + version))
}
}
})
If you want to check anything, the Jandex 3.0.0-RC3 release is already in Maven Central and should be identical to the final release (unless I uncover some last-minute issue). Importantly, it has the synthetic index()
method returning ClassInfo
, as mentioned above.
WDYT?
(I may be missing something, obviously. Please let me know if so. Thanks!)
Sample use cases:
jandex
versionsjandex
versionThis might be more of a discussion, however, the discussions are not enabled in this repository :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.