Introduction

Gradle is a build tool that replaces XML based build scripts (ant, maven etc), with a Groovy-based domain-specific-logic language. A full gradle installation is described on the official gradle webpage.

It is very likely that some projects might have a gradle wrapper available (executable file gradlew in the source directory). In this case, the installation of a gradle client is not strictly necessary (but it is always recommended for developers).


Local configuration

The gradle build is parametrized by properties which are defined in the gradle.properties file. The local user properties are by default loaded from the $HOME/.gradle/gradle.properties file, which is the recommended location for user-specific information (e.g. credentials).

More details on the gradle properties, how to set them and the location of properties files, are
described in Gradle User Manual.

Artifactory authentication

To resolve and download dependencies from the Artifactory, gradle needs to know the username and the “API Key” to authorize itself on behalf of the user. By convention, these are provided by the following two properties:

  • artifactory_user: the username of the artifactory user = username in censhare LDAP;
  • artifactory_api_key: the user’s authorization key, generated in his/her settings.
Example
artifactory_user=kpo
artifactory_api_key=jdskcjnksjancdncndsajcnjksdcnk

The value of the artifactory_api_key is sensitive information, therefore you must make sure that it remains confidential. To do this, make sure that the gradle.properties file is not readable by other users, by changing its file permissions to Read only:

chmod 600 ~/.gradle /gradle .properties


  • Do not use other ways to pass this value (e.g. commandline option)

  • If the value happens to leak, revoke it in the Artifactory web user interface and generate new one
  • Never use your real password instead of the API Key



Artifactory API Key How to

Follow the steps below to create an Artifactory API key:

  1. Go to Artifactory UI and login with your censhare LDAP credentials;
  2. Click on the username in upper right corner (next to Log Out);
  3. Enter your password again, to unlock the settings;
  4. The API Key management is now available:
    • eye”: This icon shows the encrypted password;
    • file”: This icon copies the value to the clipboard;
    • gear”: This icon generates a new, random value.

Artifactory API Key Screenshot