Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Support custom init.gradle and/or gradle.properties #6894

Closed
bnorm opened this issue Jul 31, 2020 · 9 comments
Closed

Support custom init.gradle and/or gradle.properties #6894

bnorm opened this issue Jul 31, 2020 · 9 comments
Labels
manager:gradle Gradle package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality)

Comments

@bnorm
Copy link

bnorm commented Jul 31, 2020

What would you like Renovate to be able to do?

Renovate needs a way to supply encrypted credentials to Gradle scripts.

Some of my projects store credentials in the global ~/.gradle/gradle.properties file to avoid leaking them into version control. These properties are then read in the the Gradle scripts to access artifact repositories and resolve artifacts. Without them, the build scripts fail and Renovate is not able to resolve the artifact versions and determine if updates are required.

Did you already have any implementation ideas?

It is currently possible to add an npmrc file so I thought it a natural enhancement for Gradle support to allow specifying either an init.gradle and/or a gradle.properties file. These could then be encrypted if they needed to include credentails.

Are there any workarounds or alternative ideas you've tried to avoid needing this feature?

Not that I am aware of but if suggestions are made, I would be happy to test them.

Is this a feature you'd be interested in implementing yourself?

I've dabbled very little with TypeScript, but if pointed at the npmrc config implementation and where it would need to be copied, I might be able to come up with an implementation.

@rarkins rarkins added manager:gradle Gradle package manager type:feature Feature (new functionality) priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others labels Aug 5, 2020
@rarkins
Copy link
Collaborator

rarkins commented Aug 5, 2020

Is there any way to supply these properties using environment variables or CLI commands instead? Writing files is our least favorite way of doing things.

@bnorm
Copy link
Author

bnorm commented Aug 5, 2020

Yes, Gradle also has -Pname=value as the command line alternative to a gradle.properties file. Environment variables are handled differently by Gradle so some changes would need to be made to my build scripts but is doable. Command line properties would be preferred.

@rarkins
Copy link
Collaborator

rarkins commented Aug 5, 2020

BTW are you using the hosted app, or self-hosted? I'm assuming hosted but want to check.

Our Gradle manager implementation is unique within Renovate because it (unfortunately) runs Gradle and fully resolves dependencies during the extract phase, rather than doing a light parse of the package manager files. We'd probably need to supply credentials during both the Gradle extract phase as well as the Maven version lookup phase.

What type of host is the credentials for? e.g. is it a private maven registry/repository?

@bnorm
Copy link
Author

bnorm commented Aug 5, 2020

Your assumption is correct, using the hosted app.

The credentials are for a private maven repository. I already have them in a hostRules entry so Renovate can access the repository but they need to be provided anytime Gradle is run since it is the only repository we use for resolving artifacts.

@rarkins rarkins added the status:requirements Full requirements are not yet known, so implementation should not be started label Jan 12, 2021
@monperrus
Copy link
Contributor

Reading in the doc that "Renovate (b) automatically detect during the manager extract phase which custom registries are in use." and here @rarkins writes "Our Gradle manager implementation is unique within Renovate because it (unfortunately) runs Gradle and fully resolves dependencies during the extract phase, rather than doing a light parse of the package manager files".

However, for our project Spoon, the additional registry is not detected.

repositories {
    mavenCentral()
    maven { url 'https://raw.github.com/SpoonLabs/spoon-dependencies/master' }
}

Ref: https://github.com/INRIA/spoon/blob/1d8f45b239cfa9c8420384db8137cfb6bb071ff3/spoon-dataflow/build.gradle#LL19C18-L19C76

Consequently, we get a dependency lookup warning "Renovate failed to look up the following dependencies: Failed to look up maven package com.microsoft:z3."

Why is the additional registry not detected? Is that a bug?

@rarkins
Copy link
Collaborator

rarkins commented May 6, 2023

The Gradle manager is now a parser. @Churro can you tell at a glance what's going wrong here?

@Churro
Copy link
Collaborator

Churro commented May 6, 2023

Repo extraction works correctly here but when renovate looks for com.microsoft:z3:4.8.4, it tries to retrieve maven-metadata.xml, which doesn't exist. The z3 repo only contains maven-metadata-local.xml, which according to maven docs is supposed to be used with local repos, while this one is obviously remote. So, I'd suggest adding a maven-metadata.xml to the repo and try again.

The "real" gradle doesn't have this issue, as it doesn't try to list releases and just fetches z3-4.8.4.pom directly.

@monperrus, not sure if you're aware but the trailing comma in your renovate.json renders the config invalid.

monperrus added a commit to SpoonLabs/spoon-dependencies that referenced this issue May 6, 2023
monperrus added a commit to INRIA/spoon that referenced this issue May 6, 2023
@monperrus
Copy link
Contributor

Thanks a lot @Churro

So, I'd suggest adding a maven-metadata.xml to the repo and try again

Done, see SpoonLabs/spoon-dependencies@4b8a7af

if you're aware but the trailing comma in your renovate.json renders the config invalid.

Oh, thanks, see INRIA/spoon#5203

It would be great to have a big warning in the dependency dashboard issue when renovate.json is invalid.

@viceice
Copy link
Member

viceice commented May 6, 2023

if you're aware but the trailing comma in your renovate.json renders the config invalid.

Oh, thanks, see INRIA/spoon#5203

It would be great to have a big warning in the dependency dashboard issue when renovate.json is invalid.

it's probably valid because renovate is parsing all JSON config files as JSON5. 🤗

@renovatebot renovatebot locked and limited conversation to collaborators Oct 1, 2023
@rarkins rarkins converted this issue into discussion #24904 Oct 1, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
manager:gradle Gradle package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality)
Projects
None yet
Development

No branches or pull requests

5 participants