IntelliJ中的刷新gradle导致源文件夹结构发生变化

Ela*_*nda 9 java intellij-idea gradle

当我gradle在IntelliJ IDEA中运行刷新时,我的主文件夹被设置为源根,但是"java",这是我的实际源根,没有标记.

我每次都要手动更改gradle refresh.

你知道相关的gradle设置是什么吗?

它可以在一个通用gradle文件中吗?

我应该将main文件夹更改为源根吗?

在此输入图像描述

在此输入图像描述

我怎么知道我可以继承的常用gradle在哪里?我如何在当地覆盖这个build.gradle

我的build.gradle:

apply plugin: 'java'
apply plugin: 'application'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
//
//    configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle')
//    configurations.all*.exclude(group: 'com.fasterxml.jackson.core', module:'jackson-databind')


    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

    compile 'com.google.inject:guice:4.0-beta5'
    compile 'com.sun.jersey:jersey-core:1.18.3'
    compile 'com.sun.jersey:jersey-client:1.18.3'
    compile 'com.sun.jersey:jersey-json:1.18.3'
    compile 'com.sun.jersey.contribs:jersey-apache-client:1.18.3'
    compile group: 'junit', name: 'junit', version: '4.11'
    compile 'com.vividsolutions:jts:1.13'
    compile 'net.sf.opencsv:opencsv:2.3'
    compile 'com.googlecode.json-simple:json-simple:1.1'
    compile 'com.google.guava:guava:18.0'

    //testCompile group: 'junit', name: 'junit', version: '4.11'
}


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

    test {
        java {
            srcDirs = ['src/main']
        }
    }
}


test {
    testLogging {
// Show that tests are run in the command-line output
        events 'started', 'passed'
    }
}


task run_BaselineGenerator(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath
    main = "com.waze.routing.automation.runners.BaselineGenerator"
}
Run Code Online (Sandbox Code Playgroud)

vik*_*eve 17

您的sourceSet对我来说不正确.我会尝试:

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

    test {
        java {
            srcDirs = ['src/test/java']
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 附加评论:甚至完全省略它们.这些是默认值. (3认同)