Tuesday 1 October 2019

My Journey with Gradle

In this blog, I will write about my experience in working with Gradle; most of the samples I have kept it in below github link for reference


https://github.com/venkatesh-mohanram/gradle-experiments

Converting the maven project in gradle:

Gradle has its utility which can easily convert maven project into a gradle project with one command. This will be very useful when we want to move from maven to a gradle build system. However at the time of writing, it does not support multi-project environments.
$gradle init
We need to execute the above command where we have the pom.xml file

Push to artifactory


Pushing to JFrog artifactory can be done either by using the JFrog Arifactory plugin or if we are using maven repo in artifactory then we can use the default maven plugin to push the jar into the artifactory which I found it to be simple and easy.


https://github.com/venkatesh-mohanram/gradle-experiments/tree/master/gradle-maven-publish

Force download dependency


If we want to download the dependencies everytime we build the code, then use the 'refresh-dependencies' option along with the build
$gradle build --refresh-dependencies


gradle wrapper


Gradle wrapper is a useful tool and helps in using the same gradle version anywhere we build our source code. Also, t works in the system where gradle is not installed as well.

Instead of using 'gradle' as a command use './gradlew'
$./gradlew build


.gitignore

By default, the .gitignore will contain build and .gradle file which we do not want to source control it


Setting the proxy while running

$./gradlew -Dhttps.proxyHost=<HOST> -Dhttps.proxyPort=<PORT> build