Skip to content

Commit

Permalink
feat(gradle): Add more variable patterns for Kotlin files (#7250)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Sep 11, 2020
1 parent 243728f commit 1f4bda7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/manager/gradle/build-gradle.ts
Expand Up @@ -145,6 +145,24 @@ function kotlinPluginVariableVersionFormatMatch(
);
}

function kotlinImplementationVariableVersionFormatMatch(
dependency: GradleDependency
): RegExp {
// implementation("com.graphql-java", "graphql-java", graphqlVersion)
return regEx(
`(?:implementation|testImplementation)\\s*\\(\\s*['"]${dependency.group}['"]\\s*,\\s*['"]${dependency.name}['"]\\s*,\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\)\\s*(?:\\s|;|})`
);
}

function kotlinPluginVariableDotVersionFormatMatch(
dependency: GradleDependency
): RegExp {
// id("org.jetbrains.kotlin.jvm").version(kotlinVersion)
return regEx(
`id\\s*\\(\\s*"${dependency.group}"\\s*\\)\\s*\\.\\s*version\\s*\\(\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\)\\s*(?:\\s|;|})`
);
}

function dependencyStringVariableExpressionFormatMatch(
dependency: GradleDependency
): RegExp {
Expand Down Expand Up @@ -181,6 +199,8 @@ export function collectVersionVariables(
dependencyStringVariableExpressionFormatMatch(dependency),
...moduleMapVariableVersionFormatMatch(dependency),
...moduleKotlinNamedArgumentVariableVersionFormatMatch(dependency),
kotlinImplementationVariableVersionFormatMatch(dependency),
kotlinPluginVariableDotVersionFormatMatch(dependency),
];

const depName = `${dependency.group}:${dependency.name}`;
Expand Down Expand Up @@ -235,6 +255,7 @@ function updateLocalVariables(
moduleStringVariableExpressionVersionFormatMatch(dependency),
groovyPluginVariableVersionFormatMatch(dependency),
kotlinPluginVariableVersionFormatMatch(dependency),
kotlinImplementationVariableVersionFormatMatch(dependency),
...moduleKotlinNamedArgumentVariableVersionFormatMatch(dependency),
];
for (const regex of regexes) {
Expand Down

0 comments on commit 1f4bda7

Please sign in to comment.