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)