DEV Community

Discussion on: Configuring Gradle with "gradle.properties"

Collapse
 
chhh profile image
Dmitry Avtonomov

Suppose I have a flat folder structure with two support libraries

.                          
|-- app-1                  
|   |-- build.gradle.kts    [dependency(project(':lib-2')), dependency('guava:28.0')]
|   `-- settings.gradle.kts [includeFlat('lib-2'))]
|-- lib-1                  
|   |-- build.gradle.kts    [dependency('guava:26.0')]
|   `-- settings.gradle.kts
`-- lib-2                  
    |-- build.gradle.kts    [dependency('guava:27.0'); dependency(project(':lib-1'))]
    `-- settings.gradle.kts (includeFlat('lib-1'))

So 'lib-1' is some old stuff. 'lib-2' is newer and uses 'lib-1', wants to supersede guava 26.0 with 27.0. And the 'app-1' wants to use 'lib-2', but also use some features from guava 28.0.
How would I go about converting to gradle.properties so that the right versions are used in all projects. Every time I set up a composite build I start having problems with gradle complaining that "some lib/plugin is already added and should not have its version listed in the build."

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard

That works, my own project has exactly the same structure.

You have to update Gradle because there is no good way to setup plugin versions before 5.6

$ ./gradlew wrapper --gradle-version 5.6.2

There is a boilerplate resolutionStrategy that you have to copy/paste in settings.gradle.kts

Read the docs here github.com/jmfayard/buildSrcVersio...

Collapse
 
chhh profile image
Dmitry Avtonomov

Thanks! Didn't notice first that you used issue tracker as a wiki :)