plugins {
	id 'java'
	id 'net.fabricmc.fabric-loom-remap' version '1.16.3'
	id 'ploceus' version '1.16.1'
	// Also builds a babric variant of your mod (build/libs/<name>-babric.jar) so you can
	// share it to babric users too. Run `./gradlew build`; the babric jar appears alongside.
	id 'com.periut.retroconvert' version "${retroconvert_version}"
}

base {
	archivesName = project.archives_base_name
}
version = "${project.version}+mc${project.minecraft_version}"
group = project.maven_group

ploceus {
	setIntermediaryGeneration(2)
}

repositories {
	// Add repositories to retrieve artifacts from in here.
	// You should only use this when depending on other mods because
	// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
	// See https://docs.gradle.org/current/userguide/declaring_repositories.html
	// for more information about repositories.
	mavenLocal()
	maven { url = 'https://matthewperiut.github.io/repository' } // gen2 mod deps
	maven { url = 'https://maven.glass-launcher.net/releases/' } // biny
}


dependencies {
	minecraft "com.mojang:minecraft:${project.minecraft_version}"
	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

	mappings ploceus.mappings("net.glasslauncher:biny-ornithe:b1.7.3+build.${project.biny_mappings}:mergedv2")

	clientExceptions ploceus.raven(project.client_raven_build, 'client')
	serverExceptions ploceus.raven(project.server_raven_build, 'server')
	clientSignatures ploceus.sparrow(project.client_sparrow_build, 'client')
	serverSignatures ploceus.sparrow(project.server_sparrow_build, 'server')
	clientNests "net.glasslauncher:biny-nests:b1.7.3-client+build.${project.biny_nests_build}"
	serverNests "net.glasslauncher:biny-nests:b1.7.3-server+build.${project.biny_nests_build}"

	ploceus.dependOsl(project.osl_version)

	modImplementation "com.periut:retroapi:${project.retroapi_version}"
	modImplementation("com.periut:retrocommands:${project.retrocommands_version}") {
		exclude group: 'net.modificationstation'
		exclude group: 'net.glasslauncher.mods'
		exclude group: 'com.github.GeyserMC'
	}
	// starac brings LWJGL 3, which would clash with vanilla
	// Minecraft's LWJGL 2 API, so keep it off the compile classpath.
	modRuntimeOnly "com.periut:starac:${project.starac_version}"
}

// Exclude the Legacy Fabric LWJGL 2 wrapper at RUNTIME only (starac provides LWJGL 3).
// It must stay on the compile/minecraft classpath so Condor (Ploceus LVT generator)
// can resolve org.lwjgl.* classes referenced by b1.7.3 — a blanket exclude here
// strips LWJGL 2 from minecraftCompileLibraries and crashes LVT generation.
configurations.matching { it.name.toLowerCase().contains('runtime') }.configureEach {
	exclude group: 'org.lwjgl.lwjgl'
}

processResources {
	inputs.property 'version', version

	filesMatching('fabric.mod.json') {
		expand 'version': version
	}
}

tasks.withType(JavaCompile).configureEach {
	it.options.encoding = 'UTF-8'
	it.options.release = 21
}

java {
	// Still required by IDEs such as Eclipse and Visual Studio Code
	sourceCompatibility = JavaVersion.VERSION_21
	targetCompatibility = JavaVersion.VERSION_21

	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task if it is present.
	// If you remove this line, sources will not be generated.
	withSourcesJar()

	// If this mod is going to be a library, then it should also generate Javadocs in order to aid with development.
	// Uncomment this line to generate them.
	// withJavadocJar()
}

// If you plan to use a different file for the license, don't forget to change the file name here!
jar {
	from('LICENSE') {
		rename { "${it}_${base.archivesName.get()}" }
	}
}
