Created
May 16, 2022 21:12
-
-
Save jkschneider/5110deac7790652175f42d8187db9f3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.openrewrite.gradle; | |
import org.openrewrite.Option; | |
import org.openrewrite.Recipe; | |
import org.openrewrite.internal.lang.Nullable; | |
import org.openrewrite.semver.DependencyMatcher; | |
public class ChangeDependencyVersionFromEnv extends Recipe { | |
@Option(displayName = "Dependency pattern", | |
description = "A dependency pattern specifying which dependencies should have their groupId updated. " + | |
DependencyMatcher.STANDARD_OPTION_DESCRIPTION, | |
example = "com.fasterxml.jackson*:*" | |
) | |
final String dependencyPattern; | |
@Option(displayName = "Dependency configuration", | |
description = "The dependency configuration to search for dependencies in.", | |
example = "api", | |
required = false) | |
@Nullable | |
final String configuration; | |
public ChangeDependencyVersionFromEnv(String dependencyPattern, @Nullable String configuration) { | |
this.dependencyPattern = dependencyPattern; | |
this.configuration = configuration; | |
doNext(new ChangeDependencyVersion(dependencyPattern, configuration, | |
System.getenv("ENV_NEW_VERSION"))); | |
} | |
@Override | |
public String getDisplayName() { | |
return "Change a Gradle dependency version"; | |
} | |
@Override | |
public String getDescription() { | |
return "Fetch the version from an environment variable"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment