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

Multi-module Gradle doesn't resolve properties set in parent build file #1086

Open
kdubb opened this issue Oct 20, 2022 · 4 comments
Open

Multi-module Gradle doesn't resolve properties set in parent build file #1086

kdubb opened this issue Oct 20, 2022 · 4 comments

Comments

@kdubb
Copy link
Contributor

kdubb commented Oct 20, 2022

In a multi-module Gradle project with properties (e.g. version) set for all projects in the root build.gradle.kts, dekorate doesn't resolve those properties and emits a warning.

Example /build.gradle.kts:

allprojects {
  version = "1.0"
}

This will emit the warning Could not detect project version. Using 'latest'..

@iocanel
Copy link
Member

iocanel commented Oct 21, 2022

I am not really sure how much we can do about it, given that purposefully we avoid bring in build tool dependencies and we are parsing files ourselves. The only possible solution I could think of is navigating the directory hierarchy from module root to project root and try to detect global settings.

@kdubb
Copy link
Contributor Author

kdubb commented Nov 17, 2022

Is this not what is done for maven?

@iocanel
Copy link
Member

iocanel commented Nov 25, 2022

No, AFAIR for maven the version is read from the parent element.

@kdubb
Copy link
Contributor Author

kdubb commented Mar 18, 2023

@iocanel There's any easy fix for this. Require that users define the version in gradle.properties; which is an accepted practice. Then, search up the tree until you hit a gradle.properties.

Currently the code is only looking in the current project directory, but for multi-module project it needs to search up until the root project directory.

The best solution would gather all the gradle.properties up until the root and then apply them in reverse order to mimic the overriding that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants