Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
ant Restore gradlew script executable permission Apr 25, 2019
build-cache Restore gradlew script executable permission Apr 25, 2019
build-scan Restore gradlew script executable permission Apr 25, 2019
buildSrc-plugin Restore gradlew script executable permission Apr 25, 2019
code-quality Restore gradlew script executable permission Apr 25, 2019
composite-builds Restore gradlew script executable permission Apr 25, 2019
copy Restore gradlew script executable permission Apr 25, 2019
domain-objects Restore gradlew script executable permission Apr 25, 2019
extra-properties Restore gradlew script executable permission Apr 25, 2019
gradle-plugin Restore gradlew script executable permission Apr 25, 2019
groovy-interop Restore gradlew script executable permission Apr 25, 2019
hello-android Restore gradlew script executable permission Apr 25, 2019
hello-coroutines Restore gradlew script executable permission Apr 25, 2019
hello-js Restore gradlew script executable permission Apr 25, 2019
hello-kapt Restore gradlew script executable permission Apr 25, 2019
hello-kotlin Restore gradlew script executable permission Apr 25, 2019
hello-world Restore gradlew script executable permission Apr 25, 2019
kotlin-friendly-groovy-plugin Restore gradlew script executable permission Apr 25, 2019
maven-plugin Restore gradlew script executable permission Apr 25, 2019
maven-publish Restore gradlew script executable permission Apr 25, 2019
model-rules Restore gradlew script executable permission Apr 25, 2019
modularity Restore gradlew script executable permission Apr 25, 2019
multi-kotlin-project-config-injection Restore gradlew script executable permission Apr 25, 2019
multi-kotlin-project-with-buildSrc Restore gradlew script executable permission Apr 25, 2019
multi-kotlin-project Restore gradlew script executable permission Apr 25, 2019
multi-project-with-buildSrc Restore gradlew script executable permission Apr 25, 2019
precompiled-script-plugin Restore gradlew script executable permission Apr 25, 2019
project-properties Restore gradlew script executable permission Apr 25, 2019
project-with-buildSrc Restore gradlew script executable permission Apr 25, 2019
provider-properties Restore gradlew script executable permission Apr 25, 2019
source-control Fix source-control sample for Java 12 Apr 25, 2019
task-dependencies Restore gradlew script executable permission Apr 25, 2019
testkit Restore gradlew script executable permission Apr 25, 2019
.gitignore Don't gitignore every directory named `build` but only build dirs May 18, 2017
README.md improve the project-with-buildSrc exampe to show how to define extens… Aug 28, 2018

README.md

Sample Kotlin-based Gradle build scripts

See instructions below in order to set up your dev environment to benefit from the available IDE support.

The Gradle projects in this directory demonstrate typical use cases with and features available in the Gradle Kotlin DSL. They include:

Set up dev environment

Note: Currently, these instructions only address working with IntelliJ IDEA. In the future, they'll be expanded to include working with Eclipse.

Install IntelliJ IDEA

Version 2017.3.3 or better is required, and can be downloaded from https://www.jetbrains.com/idea.

Install IDEA Kotlin Plugin

Note: the specific version of the Kotlin plugin matters.

All the samples should work against the latest Kotlin plugin, 1.2.20 at the time of this writing, from the Stable channel accessible via the Tools > Kotlin > Configure Kotlin Plugin Updates action.

Set up a sample project

Clone the Gradle Kotlin DSL repository

If you have not already done so, clone the kotlin-dsl repository:

git clone git@github.com:gradle/kotlin-dsl.git # ($REPO_ROOT)

Note: The remainder of these instructions focus on the hello-world sample project, but will work equally well for any of the other samples.

Import the sample project into IDEA

In IDEA, go to File->Open... and navigate to $REPO_ROOT/samples/hello-world.

When prompted, choose "Use default Gradle wrapper".

The project should import without errors.

Explore available IDE support

You're now ready to explore what's possible with the Gradle Kotlin DSL in IDEA. Generally speaking, things should "just work", as they would in the context of any other Java or Kotlin code you would write in IDEA.

Start by opening build.gradle.kts.

Note: The very first time you do, IDEA might fail to recognise the classpath of the script, if that happens, simply restart IDEA. This is a known issue that will be fixed soon.

Continue with any or all of the following:

Syntax highlighting

You should notice that normal Kotlin syntax highlighting works throughout the file.

Quick documentation

Try clicking on any type or function in the script, and hit F1 (or possibly CTRL-J, dependending on which IDEA key mapping you use). Notice how you're presented with a quick documentation pop-up complete with that element's Javadoc / KDoc.

Navigation to source

Again, try clicking on any type or function in the script and hit CMD-B. Notice that you're taken directly to the source for that element.

Auto-completion / content assist

Try using CTRL-SPACE at various sites in the script, and notice that you're provided with complete content assist regarding what's available at that site.

Refactoring

Most any refactoring action that is possible in a Kotlin file should also work in a Kotlin-based Gradle build script. Explore!

See also

See the latest release notes for further details on current features and limitations.

You can’t perform that action at this time.