plugins {
	id "com.github.johnrengelman.shadow" version "7.1.0"
}

architectury {
	platformSetupLoomIde()
	forge()
}

configurations {
	common
	shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
	compileClasspath.extendsFrom common
	runtimeClasspath.extendsFrom common
	developmentForge.extendsFrom common
}

repositories {
	mavenLocal()
}

dependencies {
	forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"

	modApi "dev.architectury:architectury-forge:${rootProject.architectury_api_version}"

	modApi("dev.ftb.mods:ftb-library-forge:${rootProject.ftb_library_version}") { transitive false }
	modApi("dev.ftb.mods:ftb-teams-forge:${rootProject.ftb_teams_version}") { transitive false }

	common(project(path: ":common", configuration: "namedElements")) { transitive false }
	shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
}

apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/extra-local-mods.gradle"

processResources {
	inputs.property "version", project.version

	filesMatching("META-INF/mods.toml") {
		expand "version": project.version,
				"archversion": project.architectury_api_version,
				"forgeversion": project.forge_version,
				"forgeloaderversion": project.forge_loader_version,
				"mcversion": project.minecraft_version,
				"ftblibraryversion": project.ftb_library_version,
				"ftbteamsversion": project.ftb_teams_version
	}
}

shadowJar {
	exclude "fabric.mod.json"

	configurations = [project.configurations.shadowCommon]
	setArchiveClassifier("dev-shadow")
}

remapJar {
	input.set shadowJar.archiveFile
	dependsOn shadowJar
	archiveBaseName.set "${rootProject.archives_base_name}-${project.name}"
	archiveClassifier.set null
}

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

	setArchiveClassifier("dev")
}

components.java {
	withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
		skip()
	}
}

publishing {
	publications {
		mavenForge(MavenPublication) {
			artifactId = "${rootProject.archives_base_name}-${project.name}"
			version ftbPublishing.mavenVersion
			from components.java
		}
	}
}

