Skip to content

Instantly share code, notes, and snippets.

@ysb33r
Last active March 15, 2016 20:24
Show Gist options
  • Save ysb33r/a105cd0ee27b16eac777 to your computer and use it in GitHub Desktop.
Save ysb33r/a105cd0ee27b16eac777 to your computer and use it in GitHub Desktop.
// This is a workaround for the Grain plugin for Gradle
// It generates the Grain build into a subproject if one runs grainInstall
// It also elimnates the current way Grain drops stuff all over your build area.
// IN reality the Grain plugin needs a rewrite, but this is a workaround for now.
plugins {
id "com.sysgears.grain" version "0.2.3"
}
grain {
projectDir = file 'site'
}
task grainInstall(type: com.sysgears.grain.gradle.GrainInstallTask) {
theme = 'portfolio'
version = '0.4.3'
outputs.upToDateWhen { file(grain.projectDir).exists() }
doLast {
['gradle','gradlew','gradlew.bat'].each {
project.delete "${grain.projectDir}/${it}"
}
def settingsFile = new File('settings.gradle')
String settingsText = "include 'site'"
if(!settingsFile.exists() || settingsFile.text.contains(settingsText)) {
settingsFile.withWriterAppend { w ->
w.println settingsText
}
}
def addPlugin = new File(grain.projectDir,'build.gradle')
def baseText = addPlugin.text
addPlugin.withWriter { w ->
w.println "apply plugin : 'com.sysgears.grain'"
w.println "grain.projectDir = project.projectDir"
w.println "grainInstall.ebaled = false"
w << baseText
}
}
}
['grainClean','grainDeploy','grainGenerate','grainPreview'].each {
tasks."${it}".enabled = false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment