Preparing to use Gradle - tooltwist/documentation GitHub Wiki
Note: This is obsolete. See Gradle-for-v8.4
Installing Gradle
Gradle is the build system used to build ToolTwist's java applications.
Normally Gradle does not need to be installed. Each extension project that uses Gradle includes several scripts known as the Gradle Wrapper, that are used to run Gradle, and these should be checked into the source code repository for the project. If Gradle is not already installed on the machine then these scripts will install it. They also look after ensuring the correct version of Gradle is being run.
The scripts are named gradlew
for Unix systems, and gradlew.bat
for Windows.
If the scripts are missing, ask the owner of the extension project to run gradle wrapper
in the root directory of the project, and to check the new script files into Github.
Shortcuts
If you haven't already done so, create a file named ~/.yourname_rc:
function g { gradle "$@" ; }
function gw { ./gradlew "$@" ; }
These functions will allow you to run simple commands like gw aP
, which is equivalent to gradlew artifactoryPublish
. Note that gradle allows task names with camel-case to be abbreviated. For example, if you had tasks named eatChocolate and iLikeIcecream, they could be abbreviated to eC and iLI.
Artifactory
We normally use Github to store the source code for our projects. However we don't always want to build from source, and we don't always want to make source available, so we store JAR files and other resources in an Artifactory repository (usually repo.tooltwist.com). This enabled faster builds and simplified release management.
To access Artifactory you will need a user account, and this account will allow you to log in to http://repo.tooltwist.com/artifactory. Accounts can only be added by an administrator.
Administrators can also create new repositories. There are two types of repositories you need to know about:
-
A local repository is a repository local to the Artifactory installation (not your own machine). When we want to make an extension project available to other users, we publish it to a local repository in Artifactory.
Local repositories have names like 'projectname-release-local' and 'projectname-snapshot-local'.
Note that we publish to local repositories, but we never normally otherwise use them during Gradle builds (see below).
-
A virtual repository is a single repository that maps onto multiple other repositories, some of which will be local repositories, and others stored remotely. A virtual repository allows people building using gradle (or Maven) to reference a single repository, and the virtual repository will search it's mapped repositories to find the required resources.
In most cases, you can simply refer to the virtual repository _tooltwist-all-in-one and it will find jar files and other resources in your 'local' repositories, along with most common java locations (e.g. Maven Central, Apache, etc).
Configuration
You user credentials must never be checked into Github. To prevent this Gradle expects them to be defined them in a separate location, at ~/.gradle/gradle.properties. Here is an example file:
######################################################################
#
# My personal details ( KEEP THIS SECRET !!! )
#
RESOLVE_ARTIFACTORY_CONTEXTURL=http\://repo.tooltwist.com/artifactory/
RESOLVE_ARTIFACTORY_REPO=tooltwist-all-in-one
RESOLVE_ARTIFACTORY_USER=fred.smith
RESOLVE_ARTIFACTORY_PASSWORD={DESede}NHQXUshwJ28hShajks96nZ==
######################################################################
#
# Definitions for SKYPORTAL
#
# Credentials to publish Skyportal artifacts
SKY_GROUP=com.tooltwist
SKY_VERSION=1.0.0-SNAPSHOT
SKY_SOURCE_COMPATIBILITY=1.7
SKY_DIRECTORIES_IN_JAR=false
SKY_PUBLISH_ARTIFACTORY_CONTEXTURL=http\://repo.tooltwist.com/artifactory/
SKY_PUBLISH_SNAPSHOT_REPO=sky-snapshot-local
SKY_PUBLISH_RELEASE_REPO=sky-release-local
SKY_PUBLISH_ARTIFACTORY_USER=fred.smith
SKY_PUBLISH_ARTIFACTORY_PASSWORD={DESede}NHQXUshwJ28hShajks96nZ==
The first set of definitions are used while compiling and building, while the second set of definitions are an example of what might be used to publish an extension project named 'Sky'.
The VERSION number above is worth a mention. A snapshot version is used when you are constantly making changes during development. Each time you publish, a new version of your resources are uploaded to Artifactory, and projects that have a dependancy on a snapshot version will always download the most recent snapshot. Using the "-SNAPSHOT" suffix removes the need to constantly update version numbers.
Production systems can only be built using release (non-snapshot) versions. These have a fixed version number, such as 1.2.3.
The PASSWORD value is not the actual password you use to log into Artifactory, but rather a encrypted password. To get this encrypted password, log in to Artifactory then click on you name at the top right, and your user profile will be displayed. Enter your login password in the Current Password field and press Unlock and the Ecrypted Password will be displayed.
--