We have a spring-boot java project which has both maven and Gradle. The problem is with dependencies, each has its own version of dependencies. For example, in maven MySQL dependency is
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>
Whereas in Gradle, having below:
dependencies {
implementation(project(':demo'))
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.31'
}
Is there a way to maintain versions for both maven and Gradle in some commonplace? Like from an external property file inside the project? Manually syncing versions for both Maven and Gradle is getting cumbersome.
This is possible using the
gradle.propertiesfile for both Gradle and Maven.For instance, you can have these properties:
Gradle looks for
gradle.propertiesfiles in these places (source):GRADLE_USER_HOMEenvironment variable, which if not set defaults toUSER_HOME/.gradleThen, in
build.gradle, you can read these properties like so:As for Maven, you can access this file using the Properties Maven Plugin:
And use them just like you would with the usual Maven properties.
UPDATE
It looks like the documentation for the Properties Maven Plugin is misleading, or not accurate enough. For the time being, it's not possible to read version properties from an external properties file, even though it's stated:
For more information regarding this issue, follow this GitHub discussion: https://github.com/mojohaus/properties-maven-plugin/issues/26