version = getSubprojectVersion(project)

loom {
	accessWidenerPath = file("src/main/resources/fabric-resource-loader-v0.accesswidener")
}

moduleDependencies(project, ['fabric-api-base', 'fabric-resource-loader-v1'])

testDependencies(project, [
	':fabric-lifecycle-events-v1',
	':fabric-api-base',
	':fabric-gametest-api-v1',
	':fabric-resource-loader-v0'
])

// Setup 3 test mods used for testing resource sorting
sourceSets {
	testmodA
	testmodB
	testmodC
}

[sourceSets.testmodA, sourceSets.testmodB, sourceSets.testmodC].each { sourceSet ->
	dependencies {
		testmodImplementation sourceSet.output
	}
	rootProject.dependencies {
		testmodImplementation sourceSet.output
	}

	tasks.register("${sourceSet.name}Jar", Jar) {
		from sourceSet.output
		archiveBaseName.set(sourceSet.name)
	}
}

rootProject.allprojects.each { p ->
	if (p.extensions.findByName("loom") == null) {
		return // Skip over the meta projects
	}

	p.loom.mods.register("fabric-resource-loader-v0-testmod-a") {
		sourceSet sourceSets.testmodA
	}
	p.loom.mods.register("fabric-resource-loader-v0-testmod-b") {
		sourceSet sourceSets.testmodB
	}
	p.loom.mods.register("fabric-resource-loader-v0-testmod-c") {
		sourceSet sourceSets.testmodC
	}
}

tasks.named("remapTestmodJar", net.fabricmc.loom.task.RemapJarTask) {
	nestedJars.from(tasks.testmodAJar)
	nestedJars.from(tasks.testmodBJar)
	nestedJars.from(tasks.testmodCJar)
	addNestedDependencies = true
}
