1、新建Gradle Project,點下一步輸入項目名java
一、在Gradle distribution選擇Local installation directory,填寫Gradle Home路徑api
E:\gradle-2.11app
二、在Advanced options裏填寫Gradle user home directory,這隻存放gradle下載的jar包的路徑,默認在C盤的User文件夾下maven
E:\gradle學習
三、點下一步,在點擊finish就完成項目建立gradle
2、build.gradle文件ui
apply plugin: 'java' // In this section you declare where to find the dependencies of your project repositories { // Use 'jcenter' for resolving your dependencies. // You can declare any Maven/Ivy/file repository here. jcenter() //gradle默認的中央倉庫 mavenCentral() //本身添加的Maven中央倉庫 } // In this section you declare the dependencies for your production and test code dependencies { // The production code uses the SLF4J logging API at compile time compile 'org.slf4j:slf4j-api:1.7.14' compile 'com.google.code.gson:gson:2.6.2' //添加本身要用的jar包依賴 // Declare the dependency for your favourite test framework you want to use in your tests. // TestNG is also supported by the Gradle Test task. Just change the // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add // 'test.useTestNG()' to your build script. testCompile 'junit:junit:4.12' }
右鍵項目,選擇Gradle--》Refresh Gradle Project將自動下載依賴this
至此,就能夠使用gson包了google