Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle properties version lookup in grails-bom #13948

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,40 @@ class GrailsDependencyVersions implements DependencyManagement {

@CompileDynamic
void addDependencyManagement(GPathResult pom) {
versionProperties = pom.properties.'*'.collectEntries { [(it.name()): it.text()] }
pom.dependencyManagement.dependencies.dependency.each { dep ->
addDependency(dep.groupId.text(), dep.artifactId.text(), dep.version.text())
addDependency(dep.groupId.text(), dep.artifactId.text(), versionLookup(dep.version.text()))
}
versionProperties = pom.properties.'*'.collectEntries { [(it.name()): it.text()] }
}

/**
* Handles properties version lookup in grails-bom
*
* <properties>
* <ant.version>1.10.15</ant.version>
* </properties>
*
* <dependencyManagement>
* <dependencies>
* <dependency>
* <groupId>org.apache.ant</groupId>
* <artifactId>ant</artifactId>
* <version>${ant.version}</version>
* </dependency>
* </dependencies>
* </dependencyManagement>
*
* @param version
* either the version or the version to lookup
*
* @return the version with lookup from properties when required
*/
String versionLookup(String version){
if (version?.startsWith('${') && version?.endsWith('}')) {
return versionProperties.get(version.substring(2, version.length()-1))
}

return version
}

protected void addDependency(String group, String artifactId, String version) {
Expand Down
Loading