当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Removing "src" folder from project

问题描述:

Default structure of Gradle project created by IntelliJ IDEA is:

module/src/main/java

module/src/main/resources

module/src/test/java

module/src/test/resources

I would like to cut src folder, so I will be left with:

module/main/java

module/main/resources

module/test/java

module/test/resources

I have been removing them from every possible corner in project structure -> modules. Removed them by clicking on them from IJ, but IJ keeps creating them. I have even replaced all strings in whole project folder "/src" to "" but it works until next Gradle refresh + rebuild.

How to get rid of that folder?

网友答案:

You can change default project layout and remove src folder from it's paths, by changing source sets properties as follows:

sourceSets {
    main {
        java {
            srcDirs = ['main/java']
        }
        resources {
            srcDirs = ['main/resources']
        }
    }
    test {
        java {
            srcDirs = ['test/java']
        }
        resources {
            srcDirs = ['test/resources']
        }
    }
}

You can read about it in the official user guide.

网友答案:

You can't get rid of of neither 'main' or 'test' source sets. Only thing you can do is mark them as excluded.

分享给朋友:
您可能感兴趣的文章:
随机阅读: