Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

gradle

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...

like image 301
fge Avatar asked Jun 23 '13 16:06

fge


People also ask

How to define project name in gradle?

By default, Gradle uses the directory name as project name. You can change this by creating a settings. gradle file in the directory which specifies the project name. You can also add a description to your project via the build.

How do I change my artifact name in gradle?

If you want to change the project name (which is kind of a separate question), you can do so in settings. gradle (e.g. rootProject.name = "something" ). Important: Setting the project name in settings. gradle (e.g. rootProject.name = "org.


1 Answers

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 
like image 53
Peter Niederwieser Avatar answered Oct 24 '22 00:10

Peter Niederwieser