Skip to content

Latest commit

 

History

History
106 lines (79 loc) · 2.83 KB

dependencyusestringnotation.md

File metadata and controls

106 lines (79 loc) · 2.83 KB

Use String notation for Gradle dependency declarations

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.

Source

GitHub, Issue Tracker, Maven Central

  • groupId: org.openrewrite
  • artifactId: rewrite-gradle
  • version: 8.1.3

Example

{% tabs %} {% tab title="build.gradle" %}

Before

{% 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 %}

After

{% 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 %}

Usage

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 %}

Contributors

See how this recipe works across multiple open-source repositories

Moderne Link Image

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.