Alex Rivera | Logout

How to set the project name/group/version, plus {source,target} compatibility in the same file?

Asked 2013-06-23T16:31:24.210
102

I intend to generalize the use of gradle for my projects and would like to reuse the same build file everywhere. Unfortunately, I have trouble trying to define the properties mentioned in $subject in a single file, in order to ease the migration.

This is gradle 1.6.

What I have tried, failing at all attempts:

  • gradle.properties: cannot modify name (read only, have to use a settings.gradle and override the root project name!); {source,target}Compatibility not taken into account;
  • settings.gradle: {source,target}Compatibility not taken into account either!

So, what is the correct method to achieve this? What I have tried so far in gradle.properties:

group = something
name = whatever  # cannot do!
version = whatever
sourceCompatibility = whatever # not taken into account!

And in settings.gradle:

sourceCompatibility = "whatever";  # not taken into account!

EDIT Well, the "name" problem just cannot be solved; for the rest, I have used another file which I apply in the build file. The "name" handling really isn't right :/

EDIT 2 This is now 2014 and gradle 1.12, and the problem still is not solved...

Edit
Report

1 Answer

147

gradle.properties:

theGroup=some.group
theName=someName
theVersion=1.0
theSourceCompatibility=1.6

settings.gradle:

rootProject.name = theName

build.gradle:

apply plugin: "java"

group = theGroup
version = theVersion
sourceCompatibility = theSourceCompatibility
answered 2013-06-23T16:52:19.780

Your Answer