org.openrewrite.gradle.DependencyUseStringNotation
In Gradle, dependencies can be expressed as a String
like "groupId:artifactId:version"
, or equivalently as a Map
like group: 'groupId', name: 'artifactId', version: 'version'
. This recipe replaces dependencies represented as Maps
with an equivalent dependency represented as a String
.
GitHub, Issue Tracker, Maven Central
- groupId: org.openrewrite
- artifactId: rewrite-gradle
- version: 8.1.3
{% tabs %} {% tab title="build.gradle" %}
{% code title="build.gradle" %}
plugins {
id 'java-library'
}
dependencies {
api(group: 'org.openrewrite', name: 'rewrite-core', version: 'latest.release')
implementation group: 'group', name: 'artifact', version: 'version'
}
{% endcode %}
{% code title="build.gradle" %}
plugins {
id 'java-library'
}
dependencies {
api("org.openrewrite:rewrite-core:latest.release")
implementation "group:artifact:version"
}
{% endcode %}
{% endtab %} {% tab title="Diff" %} {% code %}
--- build.gradle
+++ build.gradle
@@ -6,2 +6,2 @@
dependencies {
- api(group: 'org.openrewrite', name: 'rewrite-core', version: 'latest.release')
- implementation group: 'group', name: 'artifact', version: 'version'
+ api("org.openrewrite:rewrite-core:latest.release")
+ implementation "group:artifact:version"
}
{% endcode %} {% endtab %} {% endtabs %}
This recipe has no required configuration parameters and comes from a rewrite core library. It can be activated directly without adding any dependencies. {% tabs %} {% tab title="Gradle" %} {% code title="build.gradle" %}
plugins {
id("org.openrewrite.rewrite") version("6.1.4")
}
rewrite {
activeRecipe("org.openrewrite.gradle.DependencyUseStringNotation")
}
repositories {
mavenCentral()
}
{% endcode %} {% endtab %}
{% endtabs %}
The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.