Best practice for gradle when using git branches?

Hey there,

I am very new to gradle, so forgive me please if this is a dump question.

I use github at the moment for version control and gradle for handling the deployment process to our intern library repository. Since there are some guys working on different parts of our library, I only want to publish the master branch to the maven repository.

If I now include all the publishing information in my build.gradle file, this information will be uploaded and put into every branch as well. Is there any more elegant way for handling this?

What is it that you are trying to achive? Only have publishing information on master or are you ok it being on all branches but you want to prevent others from publishing because publishing credentials will be not available for them?

If you’re after the second thing then you can put your credentials in gradle.properties file in your gradle home directory (usually at ‘~/.gradle’) and then use it in your build file. If somebody tries to publish and credentials are not specified then you can fail the build with a suitable error message. You can find a similar approach implemented here: https://github.com/bmuschko/gradle-nexus-plugin/blob/master/src/main/groovy/org/gradle/api/plugins/nexus/NexusPlugin.groovy#L213 and here: https://github.com/bmuschko/gradle-nexus-plugin/blob/master/src/main/groovy/org/gradle/api/plugins/nexus/NexusPlugin.groovy#L147