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

Gradle dependencies declared in build.gradle as ‘checkstyle’ with a variable as the version are not identified #17657

Closed
Gal-Doron opened this issue Sep 6, 2022 · 10 comments · Fixed by #19111
Assignees
Labels
manager:gradle Gradle package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:bug Bug fix of existing functionality

Comments

@Gal-Doron
Copy link

How are you running Renovate?

Self-hosted

If you're self-hosting Renovate, tell us what version of Renovate you run.

32.192.2

If you're self-hosting Renovate, select which platform you are using.

github.com

If you're self-hosting Renovate, tell us what version of the platform you run.

No response

Was this something which used to work for you, and then stopped?

I never saw this working

Describe the bug

Gradle dependencies declared as checkstyle with the version as a variable under 'checkstyle' in the build.gradle, like the following, are not identified by Renovate:

checkstyle {
    configProperties 'workspace_loc': project.projectDir
    toolVersion = '8.25' 
    showViolations = true
    ignoreFailures = false
}

dependencies {
    checkstyle "com.puppycrawl.tools:checkstyle:${project.extensions.checkstyle.toolVersion}"
}

When setting the version variable under 'ext' like the following, Renovate identifies the version:

ext {
    maronVersion = "2.13.0"
}

dependencies {
    errorprone "com.google.errorprone:error_prone_core:${maronVersion}"
}

Please find a minimal reproduction repo below with both dependencies. In the log, you can see that only one dependency is identified:
https://github.com/MaronHatoum/gradle-check-style-linux

Relevant debug logs

Logs
DEBUG: Matched 1 file(s) for manager gradle: build.gradle (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: Found gradle package files (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: Found 1 package file(s) (repository=MaronHatoum/gradle-check-style-linux)
 INFO: Dependency extraction complete (repository=MaronHatoum/gradle-check-style-linux, baseBranch=main)
       "stats": {
         "managers": {"gradle": {"fileCount": 1, "depCount": 1}},
         "total": {"fileCount": 1, "depCount": 1}
       }
DEBUG: Looking up com.google.errorprone:error_prone_core in repository https://repo.maven.apache.org/maven2/ (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: No concurency limits (repository=MaronHatoum/gradle-check-style-linux)
       "host": "repo.maven.apache.org"
DEBUG: Found 77 new releases for com.google.errorprone:error_prone_core in repository https://repo.maven.apache.org/maven2/ (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: PackageFiles.add() - Package file saved for branch (repository=MaronHatoum/gradle-check-style-linux, baseBranch=main)
DEBUG: Package releases lookups complete (repository=MaronHatoum/gradle-check-style-linux, baseBranch=main)
DEBUG: branchifyUpgrades (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: Using group branchName template (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: Dependency com.google.errorprone:error_prone_core is part of group maronVersion (repository=MaronHatoum/gradle-check-style-linux)
DEBUG: 1 flattened updates found: com.google.errorprone:error_prone_core (repository=MaronHatoum/gradle-check-style-linux)```

</details>


### Have you created a minimal reproduction repository?

I have linked to a minimal reproduction repository in the bug description
@Gal-Doron Gal-Doron added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality labels Sep 6, 2022
@PhilipAbed PhilipAbed added priority-2-high Bugs impacting wide number of users or very important features status:ready status:requirements Full requirements are not yet known, so implementation should not be started and removed priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started labels Sep 6, 2022
@Churro Churro added manager:gradle Gradle package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others and removed priority-2-high Bugs impacting wide number of users or very important features labels Sep 6, 2022
@MaronHatoum
Copy link
Contributor

if checkstyle version = toolVersion instead of project.extensions.checkstyle.toolVersion Renovate works as expected.

I tried to add to:

const matcherConfigs: SyntaxMatchConfig[] = [

this matcher:

  {
    matchers: [
      {
        matchType: TokenType.Word,
        matchValue:'checkstyle'
      },
      {
        matchType: potentialStringTypes,
      },
      { matchType: TokenType.Colon },
      {
        matchType: TokenType.Word,
        matchValue: ['project'],
      },
      { matchType: TokenType.Dot },
      {
        matchType: TokenType.Word,
        matchValue: ['extensions'],
      },
      { matchType: TokenType.Dot },
      {
        matchType: TokenType.Word,
        matchValue: ['checkstyle'],
      },
      { matchType: TokenType.Dot },
      { matchType: TokenType.Word, tokenMapKey: 'keyToken' },
      { matchType: TokenType.Assignment },
      { matchType: TokenType.String, tokenMapKey: 'valToken' },
      endOfInstruction,
    ],
    handler: handleAssignment,
  },

it is not matching the checkstyle dependency template.

checkstyle {
    configProperties 'workspace_loc': project.projectDir
    toolVersion = '8.25' 
    showViolations = true
    ignoreFailures = false
}

dependencies {
    checkstyle "com.puppycrawl.tools:checkstyle:${toolVersion}"
}

any suggestions on how we should handle such cases for example runtime variables like project.extentions

@rarkins
Copy link
Collaborator

rarkins commented Sep 22, 2022

@Churro @zharinov do we just need to enhance our parsing to detect this case, or is it something else?

@zharinov
Copy link
Collaborator

It would be problematic to do this with the current implementation, I think. Could be easier with our parsing library.

@rarkins
Copy link
Collaborator

rarkins commented Sep 22, 2022

Do we have an issue open for the refactor that would be required first?

@zharinov
Copy link
Collaborator

I don't think so

@Churro
Copy link
Collaborator

Churro commented Sep 22, 2022

I started working on this (in fact it only lacks the tests 😄) as there are other issues related to pmd, checkstyle, etc. as well, which could all be covered at once. Then I stumbled upon cases like this one and switched to refactoring the whole Gradle implementation.

@zharinov may have noticed that something is going on based on my issues and PRs in https://github.com/zharinov/good-enough-parser 😀. I'm quite advanced with it already, including newly added support for mapOf(...) and other stuff which is currently not considered. A refactoring issue may make sense though.

@nabeelsaabna nabeelsaabna added status:in-progress Someone is working on implementation and removed status:requirements Full requirements are not yet known, so implementation should not be started labels Oct 3, 2022
@nabeelsaabna
Copy link
Contributor

nabeelsaabna commented Oct 19, 2022

Hi @Churro, can you please update the PR status ?
Is it only missing test ? (I might be able to help with that)

@Churro
Copy link
Collaborator

Churro commented Oct 19, 2022

PR in progress, incoming soon (targeting next weekend), no worries 😊

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 34.54.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@PhilipAbed
Copy link
Collaborator

@Churro Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
manager:gradle Gradle package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:in-progress Someone is working on implementation type:bug Bug fix of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants