Groovy Classpath issue

In project GroovyFX doing gradle build I get this error:

C:\Temp\groovyfx\src\main\groovy\groovyx\javafx\canvas\FillArcOperation.groovy: Could not find class for Transformation Processor groovyx.javafx.beans.FXBindableASTTransformation declared by groovyx.javafx.beans.FXBindable

Both classes FxBindableASTTransformation and FXBindable are in the same package, in the source code.
How do I fix the classpath in Gradle, so this classes are on the classpath?

Sounds like you try to solve a chicken-and-egg problem.
If the transform is in src/main/groovy and the class you want to transform is in the same source set, how should that work?
To compile the source set you need the transform, but to have the transform you need to compile the source set.

I tried now to create one more source set ‘ast’, and move one of the classes into it. But now I receive this error:

Entry META-INF/services/org.codehaus.groovy.runtime.ExtensionModule is a duplicate but no duplicate handling strategy has been set. Please refer to Copy - Gradle DSL Version 7.6 for details.

How can I fix it?

sourceSets {
    ast {
        compileClasspath += configurations.runtimeClasspath
        groovy {
            srcDirs 'src/ast/groovy'
        }
    }
    main {
        compileClasspath += sourceSets.ast.output + configurations.runtimeClasspath
        runtimeClasspath += sourceSets.ast.output
        groovy {
            srcDirs 'src/main/groovy'
        }
    }
    demo {
        compileClasspath += sourceSets.main.output + configurations.runtimeClasspath
        runtimeClasspath += sourceSets.main.output
        groovy {
            srcDirs 'src/demo/groovy'
        }
        resources {
            srcDir 'src/demo/resources'
        }
    }
}

The main question is, you are just updating an existing build, aren’t you?
How did it work before?
This is nothing that should have changed with your version updates.

Besides that, a separate source set or separate project in the same build might indeed be the proper solution if you need some classes already compiled for compiling the other classes. A separate project is usually easier.

Where your “duplicate file” problem comes from I don’t know without analyzing deeper what you do and what comes from where and what actually complains, as you did not really include much information. Setting the duplicates strategy would only be duct-type symptom treatment. The question is where you configured a file to be included multiple times.

The GroovyFX project was written under Java8, and I want to fix it for OpenJDK 21. I found a solution for the duplicate file issue by commenting out the resources in the snippet bellow. Now everything works fine.

sourceSets {
    ast {
        compileClasspath += configurations.runtimeClasspath
        groovy {
            srcDirs 'src/ast/groovy'
        }
        /*resources {
            srcDir 'src/ast/resources'
        }*/
    }
    main {
        compileClasspath += sourceSets.ast.output + configurations.runtimeClasspath
        runtimeClasspath += sourceSets.ast.output + configurations.runtimeClasspath
        groovy {
            srcDirs 'src/main/groovy'
        }
    }
    demo {
        compileClasspath += sourceSets.main.output + sourceSets.ast.output + configurations.runtimeClasspath
        runtimeClasspath += sourceSets.main.output + sourceSets.ast.output + configurations.runtimeClasspath
        groovy {
            srcDirs 'src/demo/groovy'
        }
        /*resources {
            srcDir 'src/demo/resources'
        }*/
    }
}

Yes, you are adding the directory that already is the conventional default a second time, so A + A = 2 * A.
All your srcDirs statements are actually useless as they just try to declare what is already the default.
If you cant to redeclare it for some reason - don’t do it - use setSrcDirs.
srcDir and srcDirs methods just add further parts and while the compilation might be able to cope with those duplicate files, resource processing cannot.

In your previous snippet you did not have those resources srcdir statements or it would have been clear where it comes from, so sharing code and an error that stems from other code is not too useful. :wink:
You should remove all those src dir lines.

Thank you for your reply. I commented the srcDirs out. Now on the package task I am getting:
Execution failed for task ‘:minpom’.

Cannot get property ‘allDependencies’ on null object
What can cause this?
The build file is here

Well, what causes this is right there in the message.
Something is trying to get the property allDependencies on null.
Where it is coming from, check in the --stacktrace or build --scan.

And better open a new thread if you have a new problem, this is a forum, not a chat. :wink: