Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkschneider/5110deac7790652175f42d8187db9f3b to your computer and use it in GitHub Desktop.
Save jkschneider/5110deac7790652175f42d8187db9f3b to your computer and use it in GitHub Desktop.
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