plugins {
	id 'com.github.johnrengelman.shadow' version '2.0.1'
	id 'com.eriwen.gradle.css' version '2.14.0'
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'css'

group 'net.querz.mcaselector'
version '1.7.4'

sourceCompatibility = 1.8

idea {
	module.downloadSources = true
}

repositories {
	mavenCentral()
	maven {
		url 'https://jitpack.io/'
	}
}

dependencies {
	compile 'com.github.Querz:NBT:4.0'
	shadow 'com.github.Querz:NBT:4.0'
	testCompile group: 'junit', name: 'junit', version: '4.12'
}

jar {
	manifest {
		attributes 'Main-Class': 'net.querz.mcaselector.Main', 'Application-Version': project.version
	}
}

shadowJar {
	manifest {
		attributes 'Main-Class': 'net.querz.mcaselector.Main'
	}
	configurations = [project.configurations.shadow]
}

minifyCss {
	source = "${sourceSets.main.resources.srcDirs[0]}/style.css"
	dest = "${sourceSets.main.output.resourcesDir}/style.css"
}

task updateVersion {
	doLast {
		ant.replaceregexp(
				match: '(?:Download Version )\\d+\\.\\d+(?:\\.\\d+)?',
				replace: "Download Version ${version}",
				flags: 'g',
				byline: true) {
			fileset(dir: '.', includes: 'README.md')
		}

		ant.replaceregexp(
				match: '(?:download/)\\d+\\.\\d+(?:\\.\\d+)?',
				replace: "download/${version}",
				flags: 'g',
				byline: true) {
			fileset(dir: '.', includes: 'README.md')
		}

		ant.replaceregexp(
				match: '(?:mcaselector-)\\d+\\.\\d+(?:\\.\\d+)?',
				replace: "mcaselector-${version}",
				flags: 'g',
				byline: true) {
			fileset(dir: '.', includes: 'README.md')
		}
	}
}