Can Gradle handle a build directory structure that does not conform default conventions?

StackOverflow https://stackoverflow.com/questions/2551463

  •  23-09-2019
  •  | 
  •  

문제

I am working on a + based project that has the following directory structure:

projectRoot/src
projectRoot/classes
projectRoot/conf
projectRoot/webservices

this works perfectly well in but I am looking to migrate to .

Is there a way to define a non-maven directory structure in Gradle or should I be looking to mavenize?

도움이 되었습니까?

해결책

It is very easy with Gradle to adapt to any directory structure. See the Working with source sets section of the Gradle User Guide.

다른 팁

Example with non-standard project directory structure (custom layout):

sourceSets {
    main {
        java {
            srcDir 'sources/main/java'
        }
        outputDir = file("$workDir/client/program")
        // For older version (now deprecated):
        //output.classesDir = "$workDir/client/program"
    }
    test {
        java {
            srcDir 'sources/test/java'
        }
        outputDir = file("$workDir/client/tests")
        // For older versions (now deprecated):
        //output.classesDir = "$workDir/client/tests"
        //output.resourcesDir = "$workDir/client/tests"
    }
    resources {
        srcDirs 'sources/test/res'
    }
}

Try:

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

or

sourceSets {
    main.java.srcDirs += 'src/java'
    main.resources.srcDirs += 'src/resources'
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top