Created
April 19, 2016 12:47
-
-
Save tiqwab/81e4761300b6da56a6b93f4d74f306fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subprojects { | |
apply plugin: 'eclipse' | |
apply plugin: 'java' | |
// 全ソースがUTF-8であることを指定する、 | |
// この記述であればsourceSetが増えても対応可能。 | |
def defaultEncoding = 'UTF-8' | |
tasks.withType(JavaCompile) { | |
options.encoding = defaultEncoding | |
} | |
// コンパイル対象バージョンの指定 | |
sourceCompatibility = 1.8 | |
targetCompatibility = 1.8 | |
// version指定 | |
version = '0.0.1-SNAPSHOT' | |
repositories { | |
mavenCentral() | |
} | |
// 全てのprojectで設定される依存性 | |
dependencies { | |
compile 'org.projectlombok:lombok:1.16.8' | |
testCompile 'junit:junit:4.12' | |
} | |
} | |
project(':module-core') { | |
} | |
project(':module-core-export') { | |
// 個々のprojectでのみ必要な依存性 | |
// 他のprojectの依存性も設定可能であり、eclipseの.classpathファイルにも反映される。 | |
dependencies { | |
compile project(':module-core') | |
} | |
} | |
project(':module-core-import') { | |
dependencies { | |
compile project(':module-core') | |
} | |
} | |
project(':module-export-foo') { | |
apply plugin: 'application' | |
mainClassName = 'org.tiqwab.example.gradle.multi.BatMainExport' | |
project.ext['scriptType'] = 'export' | |
dependencies { | |
compile project(':module-core-export') | |
compile 'org.apache.commons:commons-lang3:3.4' | |
} | |
} | |
project(':module-import-bar') { | |
apply plugin: 'application' | |
mainClassName = 'org.tiqwab.example.gradle.multi.BatMainImport' | |
project.ext['scriptType'] = 'import' | |
dependencies { | |
compile project(':module-core-import') | |
} | |
} | |
// buildScriptタスクで作成されるdirectoryを消去する。 | |
task clean { | |
doLast { | |
delete 'build' | |
} | |
} | |
// カスタムbuildタスク | |
task buildScript << { | |
// build先のdirectory作成 | |
// gradle.propertiesで定義しているdot表記のproperties取得は要注意 | |
def scriptDir = rootProject.properties['build.dir'] | |
def baseDir = rootProject.properties['base.dir'] | |
copy { | |
from "${baseDir}" | |
into "${scriptDir}" | |
exclude '**/*.bat' | |
exclude '**/*.sh' | |
includeEmptyDirs = true | |
} | |
// 依存libraryと各modleのcopy | |
def libDir = rootProject.properties['build.lib.dir'] | |
def deps = [] | |
subprojects.each { p -> | |
p.configurations.compile.each { dep -> | |
if (!deps.contains(dep)) { | |
deps << dep | |
} | |
} | |
def archiveJarPath = p.jar.archivePath | |
if (!deps.contains(archiveJarPath)) { | |
deps << archiveJarPath | |
} | |
} | |
copy { | |
from files(deps) | |
into libDir | |
} | |
// 各moduleの実行用スクリプトファイルの作成 | |
def baseBinDir = rootProject.properties['base.bin.dir'] | |
def binDir = rootProject.properties['build.bin.dir'] | |
def execLibDir = rootProject.properties['exec.lib.dir'] | |
subprojects.each { p -> | |
if (p.plugins.hasPlugin('application')) { | |
def classPath = [p.jar.archivePath] + p.configurations.compile | |
copy { | |
from baseBinDir | |
into binDir | |
include "**/${p.ext.scriptType}.sh" | |
rename '.*\\.sh', p.name + '.sh' | |
expand( | |
mainClassName: p.mainClassName, | |
classPath: classPath.collect{x -> "${execLibDir}/${x.name}"}.join(':') | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For set encoding of eclipse project