summaryrefslogtreecommitdiff
path: root/plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemySharedExtension.kt
blob: 1e5239b48742741d66d2c6e3cf750e2fed4f3a14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package moe.nea.archenemy.mojang

import org.gradle.api.Project
import java.io.File

abstract class ArchenemySharedExtension(val rootProject: Project) {
    init {
        require(rootProject == rootProject.rootProject)
    }

    fun getLocalCacheDirectory(): File {
        return rootProject.rootDir.resolve(".gradle/archenemy")
    }

    fun getDownloadMinecraftVersionManifestTask(): DownloadMinecraftVersionManifest {
        return rootProject.tasks.getByName("downloadMinecraftVersionManifest") as DownloadMinecraftVersionManifest
    }

    fun getDownloadVersionMetadataTask(version: String): DownloadVersionMetadata {
        val taskName = "downloadMinecraftVersionMetadata$version"
        val task = rootProject.tasks.findByName(taskName)
        if (task != null) {
            return task as DownloadVersionMetadata
        }
        return rootProject.tasks.create(taskName, DownloadVersionMetadata::class.java, version)
    }

    fun getDownloadAssetsTask(version: String): DownloadAssets {
        val taskName = "downloadMinecraftAssets$version"
        val task = rootProject.tasks.findByName(taskName)
        if (task != null) {
            return task as DownloadAssets
        }
        return rootProject.tasks.create(taskName, DownloadAssets::class.java, version)
    }

    fun getGlobalCacheDirectory(): File {
        return rootProject.gradle.gradleUserHomeDir.resolve("caches/archenemy")
    }

    val minecraftProvider = MinecraftProvider(this)
}