Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity and Wrapper code generators in Gradle - please document #183

Open
hrstoyanov opened this issue Mar 23, 2024 · 3 comments
Open

Entity and Wrapper code generators in Gradle - please document #183

hrstoyanov opened this issue Mar 23, 2024 · 3 comments
Milestone

Comments

@hrstoyanov
Copy link

Please consider adding the below example code to the relevant ES documentation sections - it may save Gradle users headaches and frustrations.

A Gradle user migth attempt to add ES generators as per the Gradle docs like shown below (where all information is extracted from the codegen jar and manifest):

dependencies {
    annotationProcessor "org.eclipse.serializer:codegen-wrapping:1.3.1"
    annotationProcessor "org.eclipse.serializer:codegen-entity:1.3.1"
    implementation "org.eclipse.store:storage-embedded:1.3.1"
}

compileJava {
    options.compilerArgs += [
            '-Awrapper.types=org.eclipse.serializer.persistence.types.PersistenceStoring',
            '-Aentity.hashequalator=true',
            '-Aentity.appendable=true'
    ]
}

Unfortunately, this works for the codegen-wrapper, but not for codegen-entity, which is simply ignored by Gradle 8.6+. I filed a Gradle issue for that, and we need to see what the Gradle team says (but I suspect codegen-entity is ignored because it does not declare to really processes any annotations).

In the meantime, here is a workaround that works fine: adding explicit -processor option to the javac command line to point to the processor class(es). Here is an example of enabling both ES code generators (note how the processor classes are comma-separated):

dependencies {
    annotationProcessor "org.eclipse.serializer:codegen-wrapping:${eclipseSerializerVersion}"
    annotationProcessor "org.eclipse.serializer:codegen-entity:${eclipseSerializerVersion}"
    implementation "org.eclipse.store:storage-embedded:${eclipseStoreVersion}"
   // ... more dependencies

}

compileJava {
    options.compilerArgs += [
            '-Awrapper.types=org.eclipse.serializer.persistence.types.PersistenceStoring',
            '-Aentity.hashequalator=true',
            '-Aentity.appendable=true',
            '-processor', 'org.eclipse.serializer.codegen.wrapping.WrapperProcessor,org.eclipse.serializer.codegen.entity.EntityProcessor'
    ]
    options.annotationProcessorPath = configurations.annotationProcessor
}
@hrstoyanov hrstoyanov changed the title Entity and Wrapper code gemerators in Gradle - please document! Entity and Wrapper code gemerators in Gradle - please document Mar 25, 2024
@hrstoyanov
Copy link
Author

So this seems like a small bug in the EclipseStore annotation processor. Here is how to fix it:

gradle/gradle#28553 (comment)

@hg-ms
Copy link
Contributor

hg-ms commented Apr 3, 2024

fixed the erroneous annotation processor definition in PR eclipse-serializer/serializer#123

@hrstoyanov
Copy link
Author

Thanks for the quick fix! You also may want to fix the docs, since now it should not be required (in both Maven and Gradle) to explicitly specify the processor class - the build tool should be able to figure it out by examining the jar only.

@hrstoyanov hrstoyanov changed the title Entity and Wrapper code gemerators in Gradle - please document Entity and Wrapper code generators in Gradle - please document Apr 10, 2024
@fh-ms fh-ms added this to the 1.3.2 milestone Apr 17, 2024
@fh-ms fh-ms modified the milestones: 1.3.2, 1.3.3 May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants