How to specify Maven property in Gradle build script?

I am migrating from Maven3 to Gradle, and I have a transitive Spring dependency in this form:

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${supported-spring-version}</version> </dependency> 

I cannot change my dependent pom.xml, so how can I solve this transitive dependency? There are two problems here.

  • How to declare a property so that Gradle uses it for default permission?
  • How to declare a property that is invalid Gradle syntax (e.g. spring -version is supported)?
+6
source share
2 answers

Announcement 1. Setting a Java system property (for example, System.setProperty("supported-spring-version", "3.0") ) in your Gradle construct can do the job.

Announcement 2. You do not declare this as a Groovy property.

+1
source

For more information, see: http://gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html

The syntax for declaring dependencies in gradle is as follows:

 dependencies { compile group: 'org.springframework', name: 'spring-jdbc', version: '${supported-spring-version}' testCompile group: 'junit', name: 'junit', version: '4.+' } 

You can use the config.groovy file to set the support-spring -version property as described in this lesson: http://mrhaki.blogspot.com/2009/11/gradle-goodness-using-properties-for.html

0
source

Source: https://habr.com/ru/post/925615/


All Articles