W.r.t. Pass options to JPAAnnotationProcessor from

2019-07-18 17:58发布

问题:

I am using Gradle version 2.14, I have made changes in build.gradle to exclude packages from JPAAnnotationProcessor as mentioned in question. My build.gradle configuration for same as follows:

configurations {

    querydslapt     
}


dependencies{
    compile group: 'com.querydsl', name: 'querydsl-core', version: '4.1.4'
    compile group: 'com.querydsl', name: 'querydsl-apt', version: '4.1.4'
    compile group: 'com.querydsl', name: 'querydsl-jpa', version: '4.1.4'

}

task generateQueryDSL(type: JavaCompile, group: 'build', description: 'Generates the QueryDSL query types') {

    source =sourceSets.main.java

    classpath = configurations.compile + configurations.querydslapt
    options.compilerArgs = [
            "-proc:only",
            "-processor", "com.querydsl.apt.jpa.JPAAnnotationProcessor",
            "-Aquerydsl.excludedPackages=com.projectx.data.domain.poc.lombok"            
    ]
    destinationDir = sourceSets.generated.java.srcDirs.iterator().next()
}

compileJava {
    dependsOn generateQueryDSL
    source generateQueryDSL.destinationDir
}

compileGeneratedJava {
    dependsOn generateQueryDSL
    options.warnings = false
    classpath += sourceSets.main.runtimeClasspath
}

But when I am building application I getting warning as warning: The following options were not recognized by any processor: '[querydsl.excludedPackages]'

And specified packages are not excluded from preprocessing.

回答1:

Found a solution!

After adding querydsl.entityAccessors=true to aptOptions warning still present, but excluding packages works!

In your case, you should try add -Aquerydsl.entityAccessors=true to options.compilerArgs =[] hope it helps

UPDATED

Just noticed that you use lombook in your project. Found this one ( How to make QueryDSL and Lombok work together ) Hope it could be helpful for you!