plugins {
    id 'multiloader-common'
    id 'net.neoforged.moddev'
}

neoForge {
    neoFormVersion = neo_form_version
    // Automatically enable AccessTransformers if the file exists
    def at = file('src/main/resources/META-INF/accesstransformer.cfg')
    if (at.exists()) {
        accessTransformers.from(at.absolutePath)
    }
}


dependencies {
    compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
    // fabric and neoforge both bundle mixinextras, so it is safe to use it in common
    compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.5.3'
    annotationProcessor group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.5.3'

    implementation(group: 'tschipp.carryon', name: 'carryon-common-26.1.2', version: '3.0.1') {
        transitive = false
    }
    // fabric and neoforge both bundle mixinextras, so it is safe to use it in common
    compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.5.3'
    annotationProcessor group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.5.3'
}
configurations {
    commonJava {
        canBeResolved = false
        canBeConsumed = true
    }
    commonResources {
        canBeResolved = false
        canBeConsumed = true
    }
}

artifacts {
    commonJava sourceSets.main.java.sourceDirectories.singleFile
    commonResources sourceSets.main.resources.sourceDirectories.singleFile, file('src/generated/resources')
}

clean {
    delete 'generated'
}

def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', String)
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
    configurations.named("$variant") {
        attributes {
            attribute(loaderAttribute, 'common')
        }
    }
}
sourceSets.configureEach {
    [it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant->
        configurations.named("$variant") {
            attributes {
                attribute(loaderAttribute, 'common')
            }
        }
    }
}
