/*
 * Configuration of source sets, dependencies, and tasks for running MWE2 workflows.
 */

sourceSets {
	mwe2 {

	}
}
eclipse.classpath.plusConfigurations += [configurations.mwe2RuntimeClasspath]

dependencies {
	if (!name.endsWith('bootstrap')) {
		mwe2Implementation project(':org.eclipse.xtext.xtext.generator')
	}
	mwe2Implementation 'org.eclipse.emf:org.eclipse.emf.mwe2.launch'
	mwe2Implementation "org.eclipse.xtext:org.eclipse.xtext.common.types:$versions.xtext_bootstrap"
	mwe2Implementation "org.eclipse.xtext:org.eclipse.xtext.ecore:$versions.xtext_bootstrap"
	mwe2Implementation platform("org.eclipse.xtext:xtext-dev-bom:$project.version")
}

if (findProperty('compileXtend') == 'true') {
	generateMwe2Xtext.xtextClasspath = rootProject.configurations.getByName('xtendCompiler')
}

class XtextGeneratorTask extends JavaExec {
	XtextGeneratorTask() {
		group = 'Build'
		mainClass = 'org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher'
		classpath = project.sourceSets.mwe2.runtimeClasspath
	}
	def setWorkflow(File workflowFile) {
		args = [workflowFile.toURI().toString(), "-p", "rootPath=${project.rootDir}"]
		inputs.file workflowFile
		description "Execute the MWE2 workflow ${workflowFile.name}"
	}
}

ext.XtextGeneratorTask = XtextGeneratorTask
