home wiki.fukuchiharuki.me
Menu
#author("2017-02-08T02:18:50+00:00","default:haruki","haruki")
* Gradleをインストールする [#ed1f3822]

- https://gradle.org/

* Gradleを設定する [#e8d2cb56]

 cd multiproject
 gradle init

** サブプロジェクトを定義する [#rf7e11c4]

- settings.gradle

 rootProject.name = 'multiproject'
 include 'domain'
 include 'persistence'
 include 'web'

** 依存関係を定義する [#d9cef332]

- build.gradle

次を想定しています。

- 依存関係
-- domain
-- persistence -> domain
-- web -> domain
-- web -> persistence
- domainはLombokしか使わない
- persistenceはMyBatisでMySQLに接続する
- webはThymeleafを使う

 buildscript {
 	ext {
 		springBootVersion = '1.5.1.RELEASE'
 	}
 	repositories {
 		mavenCentral()
 	}
 	dependencies {
 		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
 	}
 }
 
 subprojects {
 	apply plugin: 'java'
 	apply plugin: 'eclipse'
 	sourceCompatibility = 1.8
 	repositories {
 		mavenCentral()
 	}
 	dependencies {
 		compileOnly "org.projectlombok:lombok:1.16.12"
 	}
 }
 
 project(':domain') {
 }
 
 project(':persistence') {
 	dependencies {
 		compile project(':domain')
 		compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.2.0')
 	}
 }
 
 project(':web') {
 	apply plugin: 'org.springframework.boot'
 	jar {
 		baseName = 'demo'
 		version = '0.0.1-SNAPSHOT'
 	}
 	dependencies {
 		compile project(':domain')
 		compile project(':persistence')
 		compile('org.springframework.boot:spring-boot-starter-web')
 		compile('org.springframework.boot:spring-boot-starter-thymeleaf')
 		runtime('mysql:mysql-connector-java')
 		testCompile('org.springframework.boot:spring-boot-starter-test')
 	}
 }

途中。