buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'eclipse'

eclipse {
    project {
        name = "Dynmap(Forge-1.17.1)"
    }
}

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(16) // Need this here so eclipse task generates correctly.

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

ext.buildNumber = System.getenv().BUILD_NUMBER ?: "Dev"

minecraft {
    mappings channel: 'official', version: '1.17.1'
    accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
    runs {
        server {
            workingDirectory project.file('run').canonicalPath
        }
    }
}

project.archivesBaseName = "${project.archivesBaseName}-forge-1.17.1"

dependencies {
    implementation project(path: ":DynmapCore", configuration: "shadow")
    implementation project(path: ':DynmapCoreAPI')
    
    minecraft 'net.minecraftforge:forge:1.17.1-37.0.12'
}

processResources
{
    filesMatching('META-INF/mods.toml') {
        // replace version and mcversion
        expand(
        	version: project.version + '-' + project.ext.buildNumber,
        	mcversion: "1.17.1"
    	)
    }
}

shadowJar {
    dependencies {
        include(dependency(':DynmapCore'))
        exclude("META-INF/maven/**")
        exclude("META-INF/services/**")
    }
    archiveName = "Dynmap-${parent.version}-forge-1.17.1.jar"
    destinationDir = file '../target'
}

shadowJar.doLast {
    task ->
        ant.checksum file: task.archivePath
}

afterEvaluate {
reobf {
    shadowJar {
        mappings = createMcpToSrg.output
    }
}
}

task deobfJar(type: Jar) {
    from sourceSets.main.output
    classifier = 'dev'
}

artifacts {
    archives deobfJar
}

build.dependsOn(shadowJar)
