import org.apache.tools.ant.taskdefs.condition.Os

repositories {
    mavenCentral()
}

dependencies {
    testCompile project(':dsl:gen:common')
    testCompile project(':dsl:gen:meta')
    testCompile project(':dsl:gen:proto')
    testCompile project(':dsl:gen:csharp')
    testCompile project(':dsl:interop-lang')
    testCompile group: 'junit', name: 'junit', version: '4.12'

    compile project(':dsl:gen:common')
    compile project(':dsl:gen:meta')
    compile project(':dsl:gen:ts')
    compile project(':dsl:gen:js')
    compile project(':dsl:gen:proto')
    compile project(':dsl:gen:csharp')
    compile project(':dsl:interop-lang')
    compile group: 'com.beust', name: 'jcommander', version: '1.71'
}

buildscript {
    repositories {
        mavenCentral()
        maven {
           url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
    }
}

apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

mainClassName = 'com.db.plexus.interop.dsl.gen.cli.Main'

task copyJarToRootBin(type: Copy) {
  def outputDir = '../../../bin/win-x86/sdk'
  if (Os.isFamily(Os.FAMILY_MAC)) {
      outputDir='../../../bin/osx-x64/sdk'
  }
  outputs.dir outputDir
  inputs.dir 'build/libs'
  from 'build/libs'
  into outputDir
  include "*-all.jar"
  rename { String fileName ->
    "plexusgen.jar"
  }
}

build.dependsOn(copyJarToRootBin)

defaultTasks 'build'

// 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"
            }
        }
    }
}
