0

I use gradle for building my web application. I would like to use QueryDSL, so I use this plugin to generate QueryDSL types. Here is my build.gradle file.

plugins {
    id 'war'
    id 'com.ewerk.gradle.plugins.querydsl' version '1.0.9'
    id 'idea'
}

repositories {
    jcenter()
}

querydsl {
    jpa = true
    library = 'com.querydsl:querydsl-apt:4.2.1'
}

apply plugin: 'idea'

sourceSets {
    querydsl {
        java {
            srcDirs = [
                    'src/querydsl/java'
            ]
        }

        compileClasspath += sourceSets.main.output + sourceSets.test.output
        runtimeClasspath += sourceSets.main.output + sourceSets.test.output
    }
}

idea{
    module {
        sourceDirs += file('src/querydsl/java')
    }
}

dependencies {
    // Spring
    compile 'org.springframework:spring-core:5.0.5.RELEASE'
    compile 'org.springframework:spring-context:5.0.5.RELEASE'
    compile 'org.springframework:spring-context-support:5.0.5.RELEASE'
    compile 'org.springframework:spring-aspects:5.0.5.RELEASE'
    compile 'org.springframework:spring-aop:5.0.5.RELEASE'
    compile 'org.springframework:spring-webmvc:5.0.5.RELEASE'
    compile 'org.springframework.data:spring-data-commons:2.0.6.RELEASE'
    compile 'org.springframework.data:spring-data-jpa:2.0.6.RELEASE'
    compile 'org.springframework.security:spring-security-web:5.0.5.RELEASE'
    compile 'org.springframework.security:spring-security-config:5.0.5.RELEASE'

    // Hibernate
    compile 'org.hibernate:hibernate-entitymanager:5.2.17.Final'
    compile 'org.hibernate.common:hibernate-commons-annotations:5.0.3.Final'
    compile 'org.hibernate.validator:hibernate-validator:6.0.9.Final'
    compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final'

    // QueryDSL
    compile 'com.querydsl:querydsl-apt:4.2.1'
    compile 'com.querydsl:querydsl-core:4.2.1'
    compile 'com.querydsl:querydsl-jpa:4.2.1'
    compile 'com.querydsl:querydsl-sql:4.2.1'
    compile 'com.querydsl:querydsl-sql-spring:4.2.1'

    // PostgreSQL
    compile 'org.postgresql:postgresql:42.2.2'

    // Joda Time
    compile group: 'joda-time', name: 'joda-time', version: '2.10'

    // Apache Commons
    compile 'org.apache.commons:commons-lang3:3.7'
    compile 'org.apache.commons:commons-text:1.4'
    compile 'commons-io:commons-io:2.6'

    // Google Guava
    compile 'com.google.guava:guava:25.0-jre'

    // Jackson
    compile 'com.fasterxml.jackson.core:jackson-databind:2.9.5'

    // Java
    compile 'javax.el:javax.el-api:3.0.0'
    compile 'javax.xml:jaxb-api:2.1'
    compile 'javax.xml:jaxb-impl:2.1'
    compile 'javax.cache:cache-api:1.1.0'
    compile 'org.glassfish:javax.el:3.0.0'
    compile 'javax.annotation:jsr250-api:1.0'
    providedCompile 'javax.servlet:javax.servlet-api:4.0.1'
    providedCompile 'javax.annotation:javax.annotation-api:1.3.2'

    // Ehcache
    compile 'org.ehcache:ehcache:3.5.2'

    // Logging
    compile 'ch.qos.logback:logback-core:1.2.3'
    compile 'ch.qos.logback:logback-classic:1.2.3'

    // Test
    testCompile 'org.springframework:spring-test:5.0.5.RELEASE'
    testCompile 'org.springframework.security:spring-security-test:5.0.5.RELEASE'
    testCompile 'org.testng:testng:6.14.3'
    testCompile 'org.mockito:mockito-all:1.10.19'
    testCompile 'org.hamcrest:hamcrest-all:1.3'
}

test {
    useTestNG()
}

//================================================================================
// PROFILES
//================================================================================
if (project.hasProperty("production")) {
    sourceSets.main.resources.srcDirs = [
            'src/main/resources/commons',
            'src/main/resources/production',
    ]

    sourceSets.test.resources.srcDirs = [
            'src/test/resources/commons',
            'src/test/resources/production',
    ]
} else {
    sourceSets.main.resources.srcDirs = [
            'src/main/resources/commons',
            'src/main/resources/development',
    ]

    sourceSets.test.resources.srcDirs = [
            'src/test/resources/commons',
            'src/test/resources/development',
    ]
}

When I build my application from console then everything is ok, but Idea report many errors in generated source code. For example:

  • "Package 'javax.annotation' is declared in module 'java.xml.ws.annotation' which is not in the module graph" - this error occurs when @Generated adnotation was used.
  • Cannot resolve symbol 'BooleanPath', Cannot resolve symbol 'StringPath' etc.

I use java 9. Any idea?

user3364391
  • 965
  • 2
  • 8
  • 12

1 Answers1

0

You have libraries that require annotation processing. This feature is disabled by default for any IntelliJ projects.

You'll want to make sure you enable the appropriate plugins that you use for your project. i.e. Lombok or your annotations that generate code

Enabling Annotation Processor

Settings > Build, Execution, Deployment > Compiler > Annotation Processor

Enable Annotation Processor

See this question for further reference and enabling it by default: Enable Annotation processors by default

shinjw
  • 3,329
  • 3
  • 21
  • 42