Define path to Gradle Wrapper
Asked Answered
R

1

7

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?

Roaring answered 19/11, 2016 at 18:57 Comment(2)
One drawback of a custom directory layout is that other people will not find their way so easily.Rossuck
I agree but as I understand it, the gradle folder contains nothing that one has to interact with directly.Roaring
M
5

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
Mollie answered 19/11, 2016 at 19:14 Comment(1)
But I don't want the file to be in gradle/wrapper, I want it in .infra/gradle/wrapper to begin with.Roaring

© 2022 - 2024 — McMap. All rights reserved.