【问题标题】:IntelliJ with gradle and querydsl带有 gradle 和 querydsl 的 IntelliJ
【发布时间】:2015-06-23 18:14:20
【问题描述】:

我正在为我的 gradle 项目使用 IntelliJ 14.1.1(但这个问题在以前的版本中存在)。我的 gradle 文件有以下内容:

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
}  

似乎每次我进行 gradle 构建时,IntelliJ 都会丢失我对生成源的设置,我必须进入 Project |模块设置,并手动将 src/main/generated/ 添加到源中。

这通常有效,但我不明白为什么我必须不断告诉 IntelliJ 我的源路径是什么。是 IntelliJ 的问题,还是我的 gradle 文件的问题?

【问题讨论】:

    标签: gradle intellij-14


    【解决方案1】:

    您可以使用以下代码:

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

    【讨论】:

      猜你喜欢
      • 2016-11-16
      • 2018-04-11
      • 2019-05-17
      • 2014-05-11
      • 2019-03-22
      • 2015-01-28
      • 2020-03-14
      • 1970-01-01
      • 2018-07-22
      相关资源
      最近更新 更多