buildscript {
	repositories {
		maven { url = 'https://files.minecraftforge.net/maven' }
		jcenter()
		mavenCentral()
	}
	dependencies {
		classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
	}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
//----------------------------------------------------------------------------------------------------------------------

version = '3.1.0'
group = 'flaxbeard.immersivepetroleum'
archivesBaseName = 'ImmersivePetroleum-1.16.3'

repositories {
	maven {	name = "BlameJared";	url = "https://maven.blamejared.com/" }         // IE & CT Files
	maven { name = "DVS1 Maven FS"; url = "https://dvs1.progwml6.com/files/maven" } // JEI & Tinkers Files
	maven { url = 'https://maven.latmod.com/' }                                     // Needed for JEI
	maven { url = 'https://www.dogforce-games.com/maven/' }                         // gigaherz maven for 1.16.2 mappings
}

sourceSets {
	main {
		resources {
			srcDirs = [
				"$rootDir/src/main/resources",
				"$rootDir/src/generated/resources"
			]
		}
	}
}

minecraft {
	mappings channel: 'snapshot', version: '20200916-1.16.2'
	accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
	
	runs {
		client {
			workingDirectory project.file('run')
			property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
			property 'forge.logging.console.level', 'debug'
			property 'fml.earlyprogresswindow', 'false'
			mods {
				immersivepetroleum {
					source sourceSets.main
				}
			}
		}

		server {
			workingDirectory project.file('run')
			property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
			property 'forge.logging.console.level', 'debug'
			property 'fml.earlyprogresswindow', 'false'
			mods {
				immersivepetroleum {
					source sourceSets.main
				}
			}
		}

		data {
			workingDirectory project.file('run')
			property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
			property 'forge.logging.console.level', 'debug'
			property 'fml.earlyprogresswindow', 'false'
			
			args '--mod', 'immersivepetroleum', '--all', '--output', file('src/generated/resources/'), '--validate', '--existing', sourceSets.main.resources.srcDirs[0], '--existing', 'C:/Users/TwistedGate/.gradle/caches/forge_gradle/deobf_dependencies/blusunrize/immersiveengineering/ImmersiveEngineering/1.16.3-4.1.1-127_mapped_snapshot_20200916-1.16.2/ImmersiveEngineering-1.16.3-4.1.1-127_mapped_snapshot_20200916-1.16.2.jar'
			
			mods {
				immersivepetroleum {
					source sourceSets.main
				}
			}
		}
	}
}

dependencies {
	minecraft "net.minecraftforge:forge:1.16.3-34.1.25"
	
	compile fg.deobf("blusunrize.immersiveengineering:ImmersiveEngineering:1.16.3-4.1.1-127")
	compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.3:7.0.0.45")
	
	compileOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25:api")
	//compileOnly fg.deobf('com.feed_the_beast.mods:ftb-gui-library:1.0.0.18')
	
	//runtimeOnly fg.deobf("mezz.jei:jei-1.16.3:7.3.2.34")
}

processResources {
	from(sourceSets.main.resources.srcDirs) {
		include 'META-INF/mods.toml'
		expand 'version': project.version
	}
	from(sourceSets.main.resources.srcDirs) {
		exclude 'META-INF/mods.toml'
	}
	outputs.upToDateWhen { false }
}

jar {
	manifest {
		attributes([
			"Specification-Title": "immersivepetroleum",
			"Specification-Vendor": "flaxbeard",
			"Specification-Version": "1",
			"Implementation-Title": project.name,
			"Implementation-Version": "${version}",
			"Implementation-Vendor" :"flaxbeard",
			"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
		])
	}
}

def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) { type 'jar'; builtBy 'reobfJar'; }

publishing {
	publications { mavenJava(MavenPublication) { artifact reobfArtifact } }
	repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } }
}
