plugins {
	id 'fabric-loom' version '1.11-SNAPSHOT' apply false
	id "com.diffplug.spotless" version "6.23.3" apply false
	id 'checkstyle'
}

subprojects {
	apply plugin: 'fabric-loom'
	apply plugin: 'checkstyle'
	apply plugin: 'com.diffplug.spotless'

	base {
		archivesName = "fabric-docs-reference-${project.name}"
	}

	loom {
		splitEnvironmentSourceSets()

		mods {
			"fabric-docs-reference" {
				sourceSet sourceSets.main
				sourceSet sourceSets.client
			}
		}

		runs.configureEach {
			ideConfigGenerated = true
		}
	}

	dependencies {
		modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

		// :::automatic-testing:1
		testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
		// :::automatic-testing:1
	}

	// :::datagen-setup:configure
	fabricApi {
		configureDataGeneration() {
			client = true
		}
	}
	// :::datagen-setup:configure

	tasks.withType(JavaCompile).configureEach {
		it.options.release = 21
	}

	java {
		withSourcesJar()

		sourceCompatibility = JavaVersion.VERSION_21
		targetCompatibility = JavaVersion.VERSION_21
	}

	spotless {
		lineEndings = com.diffplug.spotless.LineEnding.UNIX

		java {
			removeUnusedImports()
			importOrder('java', 'javax', '', 'net.minecraft', 'net.fabricmc', 'com.example')
			indentWithTabs()
			trimTrailingWhitespace()
		}
	}

	checkstyle {
		configFile = rootProject.file('checkstyle.xml')
		toolVersion = "10.12.1"
	}
}