0

I am unsuccessfully trying to use the JPA metamodel generator in my project. The following is my gradle.build file:

plugins {
    id 'org.springframework.boot' version '2.7.5'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
    id 'java'
}

sourceCompatibility = '17'
def generatedSourcesDir = "${buildDir}/generated/sources/java"

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'

    implementation 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.0'

    annotationProcessor 'org.hibernate:hibernate-jpamodelgen:6.1.5.Final'
    compileOnly 'org.projectlombok:lombok:1.18.24'
    runtimeOnly 'com.sun.xml.bind:jaxb-impl:3.0.1'
}

sourceSets.main.java.srcDirs += (generatedSourcesDir)

compileJava {
    doFirst {
        file(generatedSourcesDir).mkdirs()
    }
    options.compilerArgs += ['-AaddGenerationDate=true']
    options.compilerArgs += ['-s', generatedSourcesDir]
//  options.compilerArgs += '-proc:none'
    println "Args for $name are $options.allCompilerArgs"
}

compileTestJava {
    doFirst {
        file(generatedSourcesDir).mkdirs()
    }
    options.compilerArgs += ['-AaddGenerationDate=true']
    options.compilerArgs += ['-s', generatedSourcesDir]
    options.compilerArgs += '-proc:none'
}
.....  Other config excluded for brevity.

Running gradle compileJava results in the following error message:

> Task :compileJava FAILED
Note: Hibernate JPA 2 Static-Metamodel Generator 6.1.5.Final

FAILURE: Build failed with an exception.
knittl
  • 246,190
  • 53
  • 318
  • 364
Dark Star1
  • 6,986
  • 16
  • 73
  • 121
  • Does this answer your question? [How to use JPA metamodel with gradle, intellij IDEA?](https://stackoverflow.com/questions/49830187/how-to-use-jpa-metamodel-with-gradle-intellij-idea) – knittl Nov 01 '22 at 14:38

1 Answers1

0

After carrying on trying to make this work, I stumbled upon the first comment of an answer to a similar issue, which removed the explicit version declaration of the plugin. Doing so fixed my issue.

Dark Star1
  • 6,986
  • 16
  • 73
  • 121