eclipse-store / store

High-Performance Java-Native-Persistence. Store and load any Java Object Graph or Subgraphs partially, Relieved of Heavy-weight JPA. Microsecond Response Time. Ultra-High Throughput. Minimum of Latencies. Create Ultra-Fast In-Memory Database Applications & Microservices.
https://eclipsestore.io/
Eclipse Public License 2.0
160 stars 14 forks source link

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

Open hrstoyanov opened 3 months ago

hrstoyanov commented 3 months ago

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 commented 3 months ago

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

https://github.com/gradle/gradle/issues/28553#issuecomment-2030045257

hg-ms commented 3 months ago

fixed the erroneous annotation processor definition in PR https://github.com/eclipse-serializer/serializer/pull/123

hrstoyanov commented 3 months ago

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.