Whats the equivalent of the following code snippet from a build.gradle
in a build.gradle.kts
version?
repositories { mavenCentral() maven { url '<MAVEN REPO URL>' } }
Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.
Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.
Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.
You have to add repositories to your build file. For maven repositories you have to prefix repository name with maven {} Add the maven repository outside the buildscript configuration block of your main build.gradle file as follows: Thanks for contributing an answer to Stack Overflow!
Maven Central is a popular repository hosting open source libraries for consumption by Java projects. To declare the Maven Central repository for your build add this to your script: Example 1. Adding central Maven repository The Google repository hosts Android-specific artifacts including the Android SDK.
Popular public repositories include Maven Central and the Google Android repository. Gradle provides built-in shorthand notations for these widely-used repositories. Figure 1. Declaring a repository with the help of shorthand notations
As an addition to the other answers, in #kotlin-dsl/256 shortcut methods were added to the various repository methods to do something like the following:
repositories { mavenCentral() maven(url = "<MAVEN REPO URL>") }
According to the issue, this was added in the Kotlin DSL version 0.11.1
. The 0.11.x
versions were included in the Gradle 4.2 release.
To see the Gradle version you are running with your build when using the Gradle wrapper run ./gradlew --version
.
At 2018-01-13 the correct syntax is the following (instead of url
, the function setUrl
):
repositories { mavenCentral() maven { setUrl("<MAVEN REPO URL>") } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With