renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.61k stars 2.32k forks source link

Gradle dependency Version using variable and set() #8307

Closed vgropp closed 3 years ago

vgropp commented 3 years ago

What Renovate type, platform and version are you using?

we are using https://gitlab.com/renovate-bot/renovate-runner/-/blob/master/templates/renovate.gitlab-ci.yml as an include in gitlab-ci

Describe the bug

When generating a sample project at start.pring.io for gradle im getting this (I already changed BOM as found in #4614 to platform()):

plugins {
    id 'org.springframework.boot' version '2.4.1'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

ext {
    set('springCloudVersion', "Hoxton.SR8")
}

dependencies {
    implementation platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}")
    implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
    useJUnitPlatform()
}

Renovate fails to upgrade set('springCloudVersion', "Hoxton.SR8"), using springCloudVersion = "Hoxton.SR8" it does work. regex to match this : set\(\s*['"](.+)['"]\s*,\s*['"](.+)['"]\s*\) and replacement: $1 = "$2"

Is there any chance to get this gradle syntax supported?

Relevant debug logs

DEBUG: gradle.updateDependency(): packageFile:settings.gradle depName:org.springframework.cloud:spring-cloud-dependencies, version:Hoxton.SR8 ==> 2020.0.0 (repository=23671976, branch=renovate/major-spring-cloud)
DEBUG: gradle.updateDependency(): packageFile:build.gradle depName:org.springframework.cloud:spring-cloud-dependencies, version:Hoxton.SR8 ==> 2020.0.0 (repository=23671976, branch=renovate/major-spring-cloud)
DEBUG: No package files need updating (repository=23671976, branch=renovate/major-spring-cloud)
DEBUG: No updated lock files in branch (repository=23671976, branch=renovate/major-spring-cloud)
DEBUG: No files to commit (repository=23671976, branch=renovate/major-spring-cloud)

Have you created a minimal reproduction repository?

https://gitlab.com/vgropp/renovate-spring-gradle-sample

vgropp commented 3 years ago

We use this set() notation to ovveride Spring IO dependencies, using springCloud.version = "" is not possible in build.gradle: https://docs.spring.io/platform/docs/current/reference/html/getting-started-overriding-versions.html

rarkins commented 3 years ago

@zharinov can you scope or fix this for both gradle and gradle-lite?

zharinov commented 3 years ago

Sure, let's see...

zharinov commented 3 years ago

Well, I wonder why gradle execution fails to extract report and extract any dep from the sample fork. But merging #8315 is merged and enabling "gradle-lite": { "enabled": true } in config should be enough to resolve the issue.

vgropp commented 3 years ago

Thanks alot for the fast fix for gradle-lite, i'll try to test it soon. But using gradle-lite will probably be blocked for us cause of #8188, is adding this to gradle still in skope or should it already work and we are missing some other config?

zharinov commented 3 years ago

Okay, also I'll unblock #8188 for you soon ;)

zharinov commented 3 years ago

@vgropp can you please check if all your use-cases is covered by gradle-lite or not?

vgropp commented 3 years ago

Hi, thanks again for the fast help. Our current use-cases seemes to be covered after enabling gradle-lite