{"id":82,"date":"2013-07-03T02:22:05","date_gmt":"2013-07-03T02:22:05","guid":{"rendered":"https:\/\/code4reference.com\/?p=82"},"modified":"2023-10-01T13:34:22","modified_gmt":"2023-10-01T13:34:22","slug":"code4referencehow-to-install-gradle","status":"publish","type":"post","link":"https:\/\/code4reference.com\/?p=82","title":{"rendered":"How to install gradle."},"content":{"rendered":"<p><a href=\"http:\/\/code4reference.com\/2012\/08\/how-to-install-gradle\/www.gradle.org\">Gradle<\/a> is a simple and yet strong build tool. It is similar to the Ant build tool. It manages the build well and also handles build dependencies. The best part of Gradle is that it is open source project. If you are thinking about installing and giving it a try, then you are at the right place. Gradle development cycle is of 4 weeks, so after every four weeks they roll out a new version of Gradle. Here, I am assuming that you are going to install Gradle on linux\/Ubuntu machine.<\/p>\n<h3>Gradle setup steps<\/h3>\n<ol>\n<li>Download Gradle from <a href=\"http:\/\/gradle.org\/downloads\">here<\/a>. Gradle download comes in three different flavors.\n<ul>\n<li>Binaries, Documentation and Source code<\/li>\n<li>Binaries only<\/li>\n<li>Source code only<\/li>\n<\/ul>\n<p>The first one is recommended since it comes with documentation and source code. If you are not interested in documentation and source file, you can download <em><strong>Binaries only<\/strong><\/em> package.<\/p>\n<\/li>\n<li>unzip the download file\n<pre>\n  $unzip gradle-[version]-[type].zip\n  <\/pre>\n<p>here <em>type<\/em> can be <em>all, bin,<\/em> or <em>src<\/em>. It is based on type of downloaded flavor.<\/p>\n<\/li>\n<li>The bin file should be in the system path, only then you can execute the Gradle command. It can be done either by executing the command given below or by editing \u00a0the .bashrc to set the PATH variable.\n<pre>\n  #modify the directory path according to the setup.\n  $ export PATH=$PATH:\/gradle-directory-path\/gradle-directory\/bin\n <\/pre>\n<\/li>\n<li>Now execute the following command on terminal\n<pre>\n $ gradle     #you will see the output below.\n\n :help\n\nWelcome to Gradle 1.1.\n\nTo run a build, run gradle  ...\nTo see a list of available tasks, run gradle tasks\nTo see a list of command-line options, run gradle --help\nBUILD SUCCESSFUL\nTotal time: 2.607 secs\n<\/pre>\n<p>If you don\u2019t the the above print, then you need to recheck the PATH variable.<\/p>\n<\/li>\n<\/ol>\n<h3>Hello wold!! in Gradle<\/h3>\n<p>After installing Gradle, let\u2019s try a simple Gradle file. Create a file named build.gradle and copy the code given below in this file.<\/p>\n<pre>\ntask(\"hello\"){\n  println \"Hello world!!\"\n}\n<\/pre>\n<p>The way we define targets in Makefile, similarly we define tasks in gradle script. In the above code we have created a simple task called <em>hello<\/em> which prints <strong><em>Hello world!!<\/em><\/strong>.<br \/>\nFor executing this script, just execute the command below on the terminal in the same directory.<\/p>\n<pre>\n$ gradle hello   #you will get similar out put as shown below.\n\nHello world!!\n:hello UP-TO-DATE\n\nBUILD SUCCESSFUL\n<\/pre>\n<p><em><strong>Gradle<\/strong><\/em> command looks for build.gradle file in the current directory and executes the specified task(s) similar to <em><strong>make<\/strong><\/em> command which looks for Makefile in the current directory and executes the specified target(s).<\/p>\n<p>Hope this blog helped you in some way. If you like this blog then please share it. You can also leave your comment below. You can find <a href=\"http:\/\/www.facebook.com\/Code4Reference\">Facebook page here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gradle is a simple and yet strong build tool. It is similar to the Ant build tool. It manages the build well and also handles build dependencies. The best part of Gradle is that it is open source project. If you are thinking about installing and giving it a try, then you are at the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-82","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=82"}],"version-history":[{"count":1,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/82\/revisions\/350"}],"wp:attachment":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}