Groovy usage on services

Hi,

I am setting up a new project with version 7.2.19
Now as I wanted to create a few services in groovy, I have realised I haven’t enabled groovy on the source folders. I’ve tried to enable it in the build.gradle as @mario did earlier:

    apply(plugin: 'groovy')

    sourceSets {
        main { groovy { srcDirs = ["src"] } }
        test { groovy { srcDirs = ["test"] } }
    }
}

But now I am getting the following exception for all of my Entity classes upon startup:

Entity class xxx is missing some of enhancing interfaces: CubaEnhanced; PersistenceObject; PersistenceWeaved; PersistenceWeavedFetchGroups;

In the global module, the enhancing is enabled the new way:

    entitiesEnhancing {
        main {
            enabled = true
        }
    }

I have tried to exclude the “entity” folder - without any luck (although there is no groovy file in there)

Could you please help, what could I do?

Thanks
Gabor

Hi @krivopustov,
do you have any thoughts on this, please?

Kind regards
Gabor

Now we have debugged the Cuba Gradle plugin @krivopustov wrote, especially the enhancer part.
We have seen, that it is going through the classes, gets the ones which are persistent entity classes and modifies a few methods and then writes the compiled binary into

modules/global/build/classes/java/main/uk/co/companyname/app 

path. So this was not the issue. But then we realised that after enabling groovy, another folder structure was created just next to this, with ALL the java files compiled by groovy:

modules/global/build/classes/groovy/main/uk/co/companyname/app 

And as the enhancer plugin is not considering these, they are not enhanced and most probably they came first in the classpath and got into the final build -> they were not enhanced, and that’s why the error message happened.

After tweaking the plugin config, excluding anything from the “entity” folder for groovy, seemingly sorts the issue:

configure([globalModule, coreModule, webModule, portalModule]) {
    apply(plugin: 'groovy')

    sourceSets {
        main {
            groovy {
                srcDirs = ["src"]
                exclude "**/entity/**"
            }
        }
        test { groovy { srcDirs = ["test"] } }
    }
}

Cheers
Gabor

1 Like