buildscript {
  repositories {
    jcenter()
    maven {
      name 'forge'
      url 'http://files.minecraftforge.net/maven/'
    }
    maven {
      name = "sonatype"
      url = "https://oss.sonatype.org/content/repositories/snapshots/"
    }
    maven {
      name = 'sponge'
      url = 'http://repo.spongepowered.org/maven'
    }
  }
  dependencies {
    classpath 'net.minecraftforge.gradle:ForgeGradle:' + project.forgeGradleVersion
  }
}
apply plugin: 'net.minecraftforge.gradle.forge'

def ver = "${project.buildType}${project.buildVersion}.${project.buildRevision}"

version = ver
group = project.group
description = project.description

minecraft {
  version = project.mcVersion + '-' + project.mcfVersion
  mappings = project.mcMappings
  runDir = 'run'
  replace '@MODID@', project.modid
  replace '@NAME@', project.name
  replace '@AUTHOR@', project.author
  replace '@VERSION@', ver
  replace '@DESCRIPTION@', project.description
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

sourceSets {
  jei {
    compileClasspath += main.compileClasspath
    compileClasspath += main.output
  }
  external {
    compileClasspath += main.compileClasspath
  }
  main {
    compileClasspath += external.output
    ext.refMap = project.refCore
  }
}

repositories {
  flatDir {
    dir 'lib'
  }
  maven {
    // location of the maven that hosts JEI files
    name = "Progwml6 maven"
    url = "http://dvs1.progwml6.com/files/maven"
  }
  maven {
    // location of a maven mirror for JEI files, as a fallback
    name = "ModMaven"
    url = "modmaven.k-4u.nl"
  }
}
dependencies {
  deobfCompile('com.minelittlepony:jumpingcastle:1.12.2.1.0.0:universal')
  // compile against the JEI API but do not include it at runtime
  deobfProvided "mezz.jei:jei_${project.mcVersion}:${project.jeiVersion}:api"
  // at runtime, use the full JEI jar
  runtime "mezz.jei:jei_${project.mcVersion}:${project.jeiVersion}"
}

processResources {
  def props = [
    modid: project.modid,
    name: project.title,
    description: project.description,
    version: ver,
    revision: project.buildRevision,
    mcversion: project.mcVersion,
    author: project.author
  ]

  from(sourceSets.main.resources.srcDirs) {
    include 'mcmod.info'
    expand props
  }

  from(sourceSets.main.resources.srcDirs) {
    exclude 'mcmod.info'
  }
}

jar {
  from sourceSets.main.output
  from sourceSets.external.output
  from sourceSets.jei.output
  baseName = "Unicopia-mc${project.mcVersion}"
}
