Setting properties via ORG_GRADLE_PROJECT_ environment variables is impossible for names with '.' in them


(Baruch Sadogursky) #1

In linux shell you can’t set environment variable with ‘.’ in name.

According to DefaultGradlePropertiesLoader no substitution is made from ‘_’ to ‘.’ so it’s impossible to set any property with ‘.’ in the name via environment variable.


(Luke Daley) #2

What kind of properties are you trying to set? It’s pretty uncommon to have a project property with a period in it as these are usually used as identifiers in code.


(Baruch Sadogursky) #3

Hey Luke, Amusingly enough, the ‘ORG_GRADLE_PROJECT_’ prefix is a partial property name with periods. When setting in -D, we use ‘org.gradle.project’. Another example of propery names with periods are Java System properties.

According to this practice, my properties files are also full with properties with periods, such as

‘buildInfo.build.url’, or ‘buildInfo.agent.name’. Once I use a cloud build server (e.g. codeship.io) using environment variables are often the only way to set those properties dynamically.

P.S. It’s something strange to say, but it works in Windows :slight_smile:


(Luke Daley) #4

ORG_GRADLE_PROJECT_ is for project properties, which are not the same as system properties.

There’s no clear way forward here, as _ is a valid character in a property key as well (i.e. we can’t translate _ to .).

I think we might have to live with just using -Dorg.gradle.project.* if you need to set project properties with periods on platforms where this is not valid in an environment variable name.


(Baruch Sadogursky) #5

I gave the System properties as an example of Java properties standard, which are promoting the dot notation. I ended up with -D for now, but I really don’t like it.