4
votes

In a new project - in which I am using gradle/gradlew - I want to set the location of various gradle/gradlew files and folders to something different than the default behaviour.

I am talking about:

  • folder gradle, with sub folder wrapper (holding gradle-wrapper.jar and gradle-wrapper.properties
  • folder build, with sub folders 'classes', 'dependency-cache', 'libs', 'resources' having all kinds of xml files from individual components, and 'tmp' having sub folders 'compileJava' and 'jar'.

But how and where do I configure this?

1
Why would you want to change? Remember, its convention over configuration. What exactly are you trying to achieve?MojoJojo
You are correct: it is convention over configuration. But the convention (call it the company policy drives the convention in this scenario). Thus the default provided can't be applied.Pierre Smits
I am wondering how there can be an established convention for a Wrapper yet. Most other build tools do not support a Wrapper. Maven only just recently added one. It will make it much harder to understand a build for anyone new to the project if default conventions are changed.Benjamin Muschko
The convention is really annoying when combined with shell auto-complete. Without the wrapper I can type grad[tab] and it auto-completes to gradle (including the trailing space) and I type the rest of my command. With the wrapper, I type ./gra[tab] and it autocompletes to ./gradle which isn't the wrapper, it's the folder the wrapper is in, so I have to press w after the tab before I enter any options. Being able to rename the gradle folder would be really handy.rjmunro

1 Answers

6
votes

You can change the location of the Wrapper and properties file by setting up a task of type Wrapper. For example:

task wrapper(type: Wrapper) {
    jarFile = file('mywrapper/wrapper.jar')
}

Running gradle wrapper will generate the following files:

.
├── build.gradle
├── gradlew
├── gradlew.bat
└── mywrapper
    ├── wrapper.jar
    └── wrapper.properties

The default build output directory can be changed via the method Project.setBuildDir(Object). For example:

buildDir = file('target')