Server technology First day (Gradle configuration and Getting started)

Source: Internet
Author: User

Gradle Overview:

In Gradle, there are two basic concepts: projects and tasks

Gradle just provides a framework for building projects, and what really works is plugin

1.gradle configuration (MAC):

(1) Download Gradle from official website:

Address: http://gradle.org/gradle-download/

(2) Installation Gradle:

1) Place the Gradle package file under/applications/gradle-2.6

2) Open the console to set environment variables:

VI. bash_profile

Add path= $PATH:/applications/gradle-2.6/bin/, Save and exit (: Wq)

Then enter the following command on the console
SOURCE ~/.bash_profile

3) Successful Installation

2.gradle Small Try A:

(1) Build a project (to get Gradle to build in the root directory of this project)

(2) Create a directory structure

Mkdir-p Src/main/java/hello (Create a multilevel package with the console or you can create it directly in the user interface)

      Project

└──SRC    └──main        └──java  └──hello        

(3) Create two Java files in the Hello directory, respectively Helloworld.java and Greeter.java

1 //Helloworld.java-----Src/main/java/hello/helloworld.java2        PackageHello;3   4        Public classHelloWorld {5          Public Static voidMain (string[] args) {6LocalTime currenttime =Newlocaltime ();7System.out.println ("The current local time is:" +currenttime);8 9Greeter Greeter =NewGreeter ();Ten System.out.println (Greeter.sayhello ()); One } A } -   -   the      //Greeter.java-----Src/main/java/hello/greeter.java -       PackageHello; -   -       Public classGreeter { +         PublicString SayHello () { -          return"Hello world!"; + } A}

(4) Create a build.gradle root directory: (gradle build Script build.gradle specifies a project and its tasks)

1repositories {//Import Web site2 mavencentral ()3     }4 5Apply plugin: ' java '//Apply ' Java ' plugin to enable it to be compiled (Gradle build)6 7Apply plugin: ' Application '//Apply ' application ' plugin to enable it to be run (Gradle run)8 9Mainclassname = ' Hello '. HelloWorld '//Setting the main classTen  Onedependencies {//Download the supplemental package from the Web ACompile "joda-time:joda-time:2.2"//format is name: Name: Version -     } -         

(5) Now, you have a project, the can build with Gradle ^_^

    cd/users/zhouhongming/desktop/project/

Gradle Build

Gradle Run

    

Server technology First day (Gradle configuration and Getting started)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.