/*
 * Bootstrap project for the Xtext language. It contains an MWE2 generator workflow with
 * dedicated configuration code. The workflow generates into the core and generic ide projects,
 * which are defined in different source repositories. The path to these other repositories is
 * assumed to be ../xtext-eclipse, respectively.
 */

apply from: "${rootDir}/gradle/mwe2-workflows.gradle"

dependencies {
	// We cannot use the projects within the workspace, as we would have
	// to compile them before generating the code, so we need to stick to the bootstrapping version.
	// Buildship, however, links the workspace projects anyway if a composite build is used.
	api "org.eclipse.xtext:org.eclipse.xtext:$versions.xtext_bootstrap"
	api "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:$versions.xtext_bootstrap"
}

sourceSets.main.java.srcDirs = []
sourceSets.main.resources.srcDirs = []
sourceSets.test.java.srcDirs = []
sourceSets.test.resources.srcDirs = []

sourceSets.mwe2 {
	java.srcDir 'src'
	if (findProperty('compileXtend') == 'true') {
		xtendOutputDir = 'xtend-gen'
	} else {
		java.srcDir 'xtend-gen'
	}
}
configurations.mwe2Implementation.extendsFrom configurations.api
jar.from sourceSets.mwe2.output
sourcesJar {
	if (findProperty('compileXtend') == 'true') {
		dependsOn generateMwe2Xtext
	}
	from sourceSets.mwe2.allSource
}
task generateXtextLanguage(type: XtextGeneratorTask) {
	workflow = file('src/org/eclipse/xtext/xtext/bootstrap/GenerateXtext.mwe2')
}

eclipse {
	project {
		natures 'org.eclipse.xtext.ui.shared.xtextNature'
		buildCommands.add(0,new org.gradle.plugins.ide.eclipse.model.BuildCommand('org.eclipse.xtext.ui.shared.xtextBuilder'))
	}
}
