dependencies {
    
	testCompile "junit:junit:4.12"
	testCompile project(':dsl:model')
	testCompile "org.eclipse.xtext:org.eclipse.xtext.testing:${xtextVersion}"
	testCompile "org.eclipse.xtext:org.eclipse.xtext.xbase.testing:${xtextVersion}"
    	
	compile project(':dsl:model')
    compile "org.eclipse.xtext:org.eclipse.xtext:${xtextVersion}"
    compile "org.eclipse.xtext:org.eclipse.xtext.xbase:${xtextVersion}"
	compile "org.eclipse.xtext:org.eclipse.xtext.ecore:${xtextVersion}"    
}
configurations {
    mwe2 {
        extendsFrom compile
    }
}

dependencies {
    mwe2 "org.eclipse.emf:org.eclipse.emf.mwe2.launch:2.9.1.201705291010"
    mwe2 "org.eclipse.xtext:org.eclipse.xtext.common.types:${xtextVersion}"
    mwe2 "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}"
    mwe2 "org.eclipse.xtext:xtext-antlr-generator:[2.1.1, 3)"

	// added for Xcore support
	mwe2 'org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.3.1'
	mwe2 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.2.0'
}

task generateXtextLanguage(type: JavaExec) {
    main = 'org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher'
    classpath = configurations.mwe2
    inputs.file "src/main/java/com/db/plexus/interop/dsl/protobuf/GenerateProtoLang.mwe2"
    inputs.file "src/main/java/com/db/plexus/interop/dsl/protobuf/ProtoLang.xtext"
    outputs.dir "src/main/xtext-gen"
    args += "src/main/java/com/db/plexus/interop/dsl/protobuf/GenerateProtoLang.mwe2"
    args += "-p"
    args += "rootPath=/${projectDir}/.."
}

generateXtext.dependsOn(generateXtextLanguage)
clean.dependsOn(cleanGenerateXtextLanguage)
eclipse.classpath.plusConfigurations += [configurations.mwe2]

// workaround for Java 8 xtext plugin issue, see https://github.com/eclipse/xtext/issues/1976
configurations.all {
    resolutionStrategy {
        eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.core.runtime') {
                details.useVersion "3.19.0"
            }
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.equinox.common') {
                details.useVersion "3.13.0"
            }
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.core.resources') {
                details.useVersion "3.12.0"
            }
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.text') {
                details.useVersion "3.10.0"
            }
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.core.jobs') {
                details.useVersion "3.11.0"
            }
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.core.contenttype') {
                details.useVersion "3.7.0"
            }
            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.equinox.preferences') {
                details.useVersion "3.9.0"
            }
        }
    }
}
