plugins {
    id 'modernfix.common-conventions'
    id 'dev.architectury.loom'
}

loom {
    silentMojangMappingsLicense()
    accessWidenerPath = file("${rootDir}/common/src/main/resources/modernfix.accesswidener")
    mixin {
        useLegacyMixinAp = true
    }
}

dependencies {
    minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
    mappings loom.layered() {
        officialMojangMappings()
        if(rootProject.hasProperty("parchment_version")) {
            parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
        }
    }
    implementation project(":annotations")
    annotationProcessor project(path: ":annotation-processor", configuration: 'shadow')
}

project.sourceSets {
    main.resources.srcDirs += [layout.buildDirectory.dir("generated/sources/annotationProcessor/java/main/resources")]
}
// hack to shut up gradle about the hack to include generated resources
tasks {
    processResources {
        dependsOn compileJava
    }
}

tasks.withType(JavaCompile) {
    configure(options) {
        if (!name.toLowerCase().contains('test')) {
        options.compilerArgs << "-ArootProject.name=${rootProject.name}" << "-Aproject.name=${project.name}"
        }
    }
}
