Gradle方式構建Java多項目

來源:互聯網
上載者:User

標籤:

 

1. 首先,安裝Gradle。 簡單的步驟:

Prerequired: Java SDK installed

1. Dowload Gradle from: http://gradle.org/downloads2. Set gradle home environment variable: GRADLE_HOME. Pointing to the place where the gradle binaries is3. Add %GRADLE_HOME%\bin; to your PATH environment variable string4. Run gradle -v command to test your installation and configuration is correct 2. 其次,Git上下載安裝一個Gradle 的Template外掛程式。 步驟如下
http://www.cnblogs.com/ygshen/p/4321283.html 3. 最後規劃我們的工程結果,在Java的項目中不存在.NET的Solution, Project,... 的概念。 只有Project在Project下面建立新的子Project的方式。這裡我們說一下這個建立Project和子Project以及各個Project內部關於包的引用案例 a. 建立一個空檔案夾 ABCb. IDEA裡面Import Project, 選擇上面的空目錄c. IDEA根目錄下添加新檔案 build.gradled. IDEA根目錄下面建立一個Moduel, Moduel類型選擇gradle. 新的Moduel名字subproject1e. cd 到這個Moduel所在的目錄執行 gradle initjavaprojectf. 刪除該目錄下的build.gradle和LISCENSE檔案重複c-f建立其他的library 工程。 如果想建立一個webproject在第4部執 gradle initwebappprojectg. 後退到ABC目錄執行gradle projects可以看到所有的subprojects會被列出來4. 在根目錄的build.gradle檔案中管理所有的subproject資訊
project(‘:WebProject‘){    apply plugin: ‘application‘    // Where the main class come from, it is in a sub project    mainClassName=‘‘    // Dependencies for current project    dependencies{        compile project(‘:subproject2‘)        compile ‘mysql:mysql-connector-java:5.1.21‘    }}project(‘:subproject1‘){}project(‘:subproject2‘){}// Defined all the sub-projects behavior. here theysubprojects{    group=‘‘    version=‘1.0‘    apply plugin: ‘java‘    sourceCompatibility=‘1.7‘    repositories{        mavenCentral()    }    dependencies {        testCompile ‘junit:junit:4.11‘    }}

  

 

Gradle方式構建Java多項目

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.