This tutorial assumes that you have
/src/main
as your sources folder/src/test
as your test folder/src/resources
as your resources folder
(Even you if don't, it's alright, read on. You'll just have to modify the gradle file a bit)
You need to install the latest version locally.
Note: If you use the one that comes bundled with Intellij or
gradlew
you might face problems while compiling with JDK 9 since they don't provide the latest version of gradle.
brew install gradle
Now just download this file (or the contents of this file) here.
Call it build.gradle
and place it into the root folder of your project.
IMPORTANT:
- Now close the project (I'm not kidding, lol).
- And then open it up again.
- You should be able to see a small notification on the bottom right. Click Import Gradle (or something on those lines).
- That should open up a import module window.
This is what the import module should look like: Mimic the fields that are in the picture. And press OK.
If all goes well, you should have gradle working in your project.
Don't forget to add .gradle
to your .gitignore
!
It's nothing difficult really. Just modify this snippet in your build.gradle
:
sourceSets {
main {
java {
srcDirs = ['src/main']
}
resources {
srcDirs = ['src/resources']
}
}
test {
java {
srcDirs = ['src/test']
}
}
}