IntelliJ with gradle and querydsl

I am using IntelliJ 14.1.1 (but this question existed in previous versions) for my gradle project. For my gradle file, I have the following:

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'jacoco'
apply plugin: 'maven'

project.ext {
    springBootVersion = '1.1.7.RELEASE'
}

configurations {
    querydslapt
}

jacoco {
    toolVersion = "0.7.0.201403182114"
}

buildscript {
    repositories {
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url "http://repo.spring.io/libs-milestone" }
        maven { url "http://repo.spring.io/libs-snapshot" }
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.3.RELEASE")
    }
}

jar {
   ...
}

repositories {
    mavenCentral()
    maven { url "http://repo.spring.io/libs-milestone" }
    ...
}

jacocoTestReport {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}

//Querydsl
def generatedSrcDir = 'src/main/generated'
task createGeneratedSrcDir << {
    file(generatedSrcDir).mkdirs()
}
compileJava.dependsOn createGeneratedSrcDir
compileJava {
    options.compilerArgs << '-processor' << 'com.mysema.query.apt.jpa.JPAAnnotationProcessor' << '-s' << file(generatedSrcDir).absolutePath
}
clean {
    delete generatedSrcDir
}  

      

IntelliJ seems to lose my settings for generated sources every time I build gradle and I need to go to Project | Module settings and manually add sources src / main / generated / to sources.

This usually works, but I don't understand why I should keep telling IntelliJ what is my original path. Is the problem with IntelliJ or my gradle file?

+3


source to share


1 answer


you can use the following code:



apply plugin: 'idea'
idea {
module {
    sourceDirs += file('src/main/generated')
    generatedSourceDirs += file('src/main/generated')
 }
}

      

+3


source







All Articles