Search code examples
gradlegradlew

Define path to Gradle Wrapper


To not clutter my project's top-level directory I would like the gradle wrapper JAR to land in a subdirectory, e.g. infra. I'm going for something like this:

root
 L .infra
    L gradle
       L wrapper
          L gradle-wrapper.jar
          L gradle-wrapper.properties

I hoped that archiveBase or distributionBase would get me there but even if brute forcing these settings, I still end up with gradle in the top level.

configure(rootProject) {

    task wrapper(type: Wrapper) {
        description = 'Generates gradlew and gradlew.bat scripts'
        gradleVersion = '3.2'
        archiveBase = Wrapper.PathBase.PROJECT
        archivePath = ".infra/"
        distributionBase = Wrapper.PathBase.PROJECT
        distributionPath = ".infra/"
    }

}

What am I doing wrong?


Solution

  • These paths will be set in the gradle/wrapper/gradle-wrapper.properties.

    distributionBase=PROJECT
    distributionPath=infra/ <---- 
    zipStoreBase=PROJECT
    zipStorePath=infra/ <----
    

    You can set the path to wrapper script and jar by using following properties.

    jarFile = "${project.projectDir}/.infra/gradle-wrapper.jar" // archive
    scriptFile = "${project.projectDir}/.infra/gradlew" // wrapper script