Skip to content

Commit

Permalink
(Optional) Gradle build
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Sep 29, 2019
1 parent d0470bd commit 68c79dc
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,17 @@ pyvenv.cfg
pip-selfcheck.json
.idea
cache.sqlite
.gradle
/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ These scripts analyze the macrogenetic data from the data/xml/macrogenesis folde

### Installation and Usage

Python ≥ 3.6 and GraphViz ≤ 2.38 or ≥ 2.41 need to be installed separately.
Python ≥ 3.7 and GraphViz ≤ 2.38 or ≥ 2.41 need to be installed separately.

```bash
git submodules update --init --remote
Expand All @@ -15,6 +15,10 @@ macrogen

will produce the output.

### Using the Gradle build

The included Gradle script provides tasks to setup a suitable python version, install the macrogenesis library and all of its dependencies, and run the analysis. It still requires Graphviz to be installed.

### Additional Configuration

Macrogenesis data structure is documented elsewhere (TODO Link).
Expand Down
81 changes: 81 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
plugins {
id "base"
id "com.jetbrains.python.envs" version "0.0.30"
}

if (project != rootProject) {
project.buildDir = rootProject.buildDir
logger.info("Using root project's buildDir: $buildDir")
}

if (!project.hasProperty('dataDir')) {
def dataDirCandidate = rootProject.file('data/xml')
if (dataDirCandidate.isDirectory())
project.ext.dataDir = dataDirCandidate
else {
throw new FileNotFoundException("Data directory not found. Either put data into $dataDirCandidate, or set the dataDir property.")
}
logger.info("Using data from $dataDirCandidate")
}


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')
}

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"
workingDir projectDir
args "install", "-U", "-e", "."
}

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

task runMacrogenAnalysis(type: Exec) {
description 'Runs the macrogenesis analysis phase'
dependsOn installMacrogen
args "--skip-reports"
args "-o", "$buildDir/macrogen-graphs.zip"
args "--order", "$buildDir/order.xml"
outputs.file "$buildDir/macrogen-graphs.zip"
outputs.file "$buildDir/order.xml"
}

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

configureMacrogenTasks(runMacrogenAnalysis, runMacrogenReporting, runMacrogenComplete)

0 comments on commit 68c79dc

Please sign in to comment.