Gradle set highlight

The keyword introduced by gradle custom dependency, how to make it highlighted, just like the “optional” keyword customized by spring

The following screenshots are from spring framework

How can I do it so that I can produce highlights like this
If there is a solution, please let me know, thanks

Can you elaborate on what you mean?
Gradle does not highlight anything, it is a build tool.
Which IDE is that even?
What do you want to highlight where?

My IDE is IntelliJ IDEA,The “optional” created by “spring” can be highlighted and recognized by IDEA, but the one created by yourself cannot

How do you create it and use it?

This is my plugin defined

abstract class DependencyBomPlugin implements Plugin<Project> {

    public static final String DEPENDENCY_BOM = "dependencyBom"

    void apply(Project project) {
        def dependencyBom = project.configurations.create(DEPENDENCY_BOM)
        dependencyBom.visible = false
        dependencyBom.canBeResolved = false
        dependencyBom.canBeConsumed = false
        project.plugins.withType(JavaPlugin.class) {

Use in “build.gradle”

configure(gradleModuleProjects) {
    apply plugin: "java"
    apply plugin: "com.livk.dependency"

    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17

    dependencies {
        dependencyBom platform(project(":livk-boot-dependencies"))

But “dependencyBom” cannot be highlighted like “optional” defined by “spring”

Ah, so you are using Groovy DSL, no idea then.
Maybe IntelliJ has explicit support for Spring “optional”, I don’t know.
You proabably better ask them.
Or you use the Kotlin DSL, there everything is type-safe so you have extremely better IDE support including highlighting and completion.

Thanks for your answer, I think I should ask the IDE’s development team

1 Like