Skip to content

Commit

Permalink
Moved task configuration to separate class
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Sep 30, 2019
1 parent 68c79dc commit 39416f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
36 changes: 8 additions & 28 deletions build.gradle
Expand Up @@ -20,48 +20,30 @@ if (!project.hasProperty('dataDir')) {


envs {
bootstrapDirectory = new File(buildDir, 'tools')
envsDirectory = new File(buildDir, 'envs')
bootstrapDirectory = new File(buildDir, 'tools')
envsDirectory = new File(buildDir, 'envs')

python "python37", "3.7.4", []
virtualenv "macrogen", "python37"
project.ext.venv = new File(buildDir, 'envs/macrogen')
python "python37", "3.7.4", []
virtualenv "macrogen", "python37"
}

def addInputArg(AbstractExecTask task, GString option, Object file) {
task.args(option, file)
task.inputs(file)
}

def configureMacrogenTasks(AbstractExecTask... tasks) {
for (AbstractExecTask task in tasks) {
task.group 'macrogen'
task.executable("$venv/bin/macrogen")

if (rootProject != project) {
addInputArg(task, '--sigils', "$buildDir/sigils.json")
addInputArg(task, '--paralipomena', "$buildDir/www/data/paralipomena.js")
task.args('--progressbar', 'false')
}
}
}

task installMacrogen(type: Exec) {
description 'Installs the macrogenesis tool and its requirements'
group 'macrogen'
dependsOn 'build_envs'

executable "$venv/bin/pip"
executable "$buildDir/envs/macrogen/bin/pip"
workingDir projectDir
args "install", "-U", "-e", "."
}

task runMacrogenComplete(type: Exec) {
task runMacrogenComplete(type: MacrogenExec) {
description 'Runs the complete macrogenesis analysis and configuration'
dependsOn installMacrogen
}

task runMacrogenAnalysis(type: Exec) {
task runMacrogenAnalysis(type: MacrogenExec) {
description 'Runs the macrogenesis analysis phase'
dependsOn installMacrogen
args "--skip-reports"
Expand All @@ -71,11 +53,9 @@ task runMacrogenAnalysis(type: Exec) {
outputs.file "$buildDir/order.xml"
}

task runMacrogenReporting(type: Exec) {
task runMacrogenReporting(type: MacrogenExec) {
description 'Runs the macrogenesis reporting phase'
dependsOn runMacrogenAnalysis
args "-i", "$buildDir/macrogen-graphs.zip"
inputs.file("$buildDir/macrogen-graphs.zip")
}

configureMacrogenTasks(runMacrogenAnalysis, runMacrogenReporting, runMacrogenComplete)
23 changes: 23 additions & 0 deletions buildSrc/src/main/groovy/MacrogenExec.groovy
@@ -0,0 +1,23 @@
import org.gradle.api.tasks.AbstractExecTask

class MacrogenExec extends AbstractExecTask<MacrogenExec> {

def addInputArg(GString option, Object file) {
this.args(option, file)
this.inputs(file)
}

MacrogenExec() {
super(MacrogenExec)

group = 'macrogen'
executable("$project.buildDir/envs/macrogen/bin/macrogen")

if (project.rootProject != project) {
addInputArg('--sigils', "$buildDir/sigils.json")
addInputArg('--paralipomena', "$buildDir/www/data/paralipomena.js")
args('--progressbar', 'false')
}
}

}

0 comments on commit 39416f7

Please sign in to comment.