Hannes
Hannes

Reputation: 5262

Where to keep maven publish related sections of Gradle build file?

I do publish an open source library to Maven Central. In order to do that the gradle.build file contains variable references to a gradle.properties file which contains secret information like usernames and passwords.

Of course the build.gradle needs to be published to the public git repository, the gradle.properties should not be published, due to containing all the personal information but without the properties file the build.gradle is not valid.

How are open source projects handling those sensitive data?

Upvotes: 2

Views: 514

Answers (1)

M.Ricciuti
M.Ricciuti

Reputation: 12096

Here is a solution based on this answer, with the use of findProperty method to allow users to build your project without providing the publishing credentials (issue you mentioned in your comment above)

  • move credentials outside the project's gradle.properties and put them to your local user /.gradle/gradle.properties configuration file
  • in your publish task definition, use:

    authentication(userName: findProperty('mavenUser'), password: findProperty('mavenPassword'))

Upvotes: 1

Related Questions