Skip to content

Instantly share code, notes, and snippets.

@makotan
Created April 4, 2012 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makotan/2301257 to your computer and use it in GitHub Desktop.
Save makotan/2301257 to your computer and use it in GitHub Desktop.
build.gradle でsrc系のディレクトリと.gitignoreを作成するタスク
version = '0.1-SNAPSHOT'
group = 'foo.bar'
task init << {
def ignores = ["/.*","/build","/lib","/bin","/repo"
,"/gradle*","!gradle","!gradle.bat"
,"target","/out","/logs","/log","/bin"
,"*.iml","*.ipr","*.iws",".idea"
,".DS_Store"
]
def ignoreFile = file(".gitignore")
if(ignoreFile.canRead()) {
ignores = ignores - ignoreFile.readLines()
}
ignores.each {ignoreFile.append("$it\n") }
file('logs').mkdirs()
}
subprojects {
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'idea'
group = parent.group
versionnn = parent.version
// プロジェクトディレクトリの作成
task createBuilds(dependsOn: init) << {
projectDir.mkdirs()
def buildFile = file("$projectDir.absolutePath/build.gradle")
if(buildFile.canRead() == false) {
buildFile.createNewFile()
}
}
// srcディレクトリの作成
task createDirs(dependsOn: createBuilds) << {
if(childProjects.size() == 0) {
sourceSets*.allSource.srcDirs.each { for(dir in it) { dir.mkdirs() } }
}
}
}
@makotan
Copy link
Author

makotan commented Apr 7, 2012

settings.gradle
include 'prj1', 'prj2' , 'libs:p1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment