plugins {
    id 'java-library'
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
    implementation 'org.json:json:20230618'
}

jar {
    destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/forge_installer/"))
    manifest {
        attributes("Manifest-Version": "1.0",
                "PreMain-Class": "git.artdeell.installer_agent.Agent")
    }
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    // Makes the jar reproducible so the version file actually is a version file
    preserveFileTimestamps = false
    reproducibleFileOrder = true
    // Write version file
    def versionFile  = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/forge_installer/version")
    def jarFile = archiveFile.get().asFile
    doLast {
        writeVersionFile(jarFile, versionFile)
    }
    outputs.file(versionFile) // Adds the versionFile to outputs
}
