Skip to content

Commit 9b939d1

Browse files
committed
refactor: remove deprecated elements, fix TODOs
1 parent 70191c2 commit 9b939d1

File tree

31 files changed

+178
-643
lines changed

31 files changed

+178
-643
lines changed

core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ plugins {
66

77
dependencies {
88
api(libs.bundles.asm)
9-
api(libs.bundles.jackson)
109
api(libs.mapping.io)
10+
implementation(libs.bundles.jackson)
1111
implementation(libs.bundles.kotlin)
1212
implementation(libs.kotlin.logging.jvm)
1313
implementation(libs.kotlinx.coroutines.core.jvm)

core/src/main/kotlin/me/kcra/takenaka/core/VersionManifest.kt

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package me.kcra.takenaka.core
2020
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
2121
import com.fasterxml.jackson.annotation.JsonProperty
2222
import com.fasterxml.jackson.core.JacksonException
23-
import com.fasterxml.jackson.databind.ObjectMapper
2423
import com.fasterxml.jackson.module.kotlin.readValue
2524
import me.kcra.takenaka.core.util.*
2625
import java.io.IOException
@@ -37,17 +36,6 @@ import kotlin.io.path.isRegularFile
3736
*/
3837
const val VERSION_MANIFEST_V2 = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"
3938

40-
/**
41-
* Fetches and deserializes the version manifest from Mojang's API.
42-
*
43-
* @return the version manifest
44-
*/
45-
@Deprecated(
46-
"Jackson will be an implementation detail in the future.",
47-
ReplaceWith("versionManifestOf()", "me.kcra.takenaka.core.versionManifestOf")
48-
)
49-
fun ObjectMapper.versionManifest(): VersionManifest = readValue(URL(VERSION_MANIFEST_V2))
50-
5139
/**
5240
* Fetches and deserializes the version manifest from Mojang's API.
5341
*
@@ -86,43 +74,6 @@ fun versionManifestFrom(cacheFile: Path, url: String = VERSION_MANIFEST_V2): Ver
8674
}
8775
}
8876

89-
/**
90-
* Retrieves the version manifest from Mojang's API or a cache file,
91-
* fetching it if it could not be deserialized or the content length changed.
92-
*
93-
* @param cacheFile the cache file, does not need to exist
94-
* @return the version manifest
95-
*/
96-
@Deprecated(
97-
"Jackson will be an implementation detail in the future.",
98-
ReplaceWith("versionManifestFrom(cacheFile)", "me.kcra.takenaka.core.versionManifestFrom")
99-
)
100-
fun ObjectMapper.cachedVersionManifest(cacheFile: Path): VersionManifest {
101-
val url = URL(VERSION_MANIFEST_V2)
102-
103-
if (cacheFile.isRegularFile()) {
104-
val length = url.contentLength
105-
if (cacheFile.fileSize() == length) {
106-
try {
107-
return readValue(cacheFile)
108-
} catch (_: JacksonException) {
109-
// failed to read cached file, corrupted? fetch it again
110-
}
111-
}
112-
}
113-
114-
url.httpRequest {
115-
if (it.ok) {
116-
cacheFile.parent.createDirectories()
117-
it.copyTo(cacheFile)
118-
119-
return readValue(cacheFile)
120-
}
121-
122-
throw IOException("Failed to fetch v2 Mojang manifest, received ${it.responseCode}")
123-
}
124-
}
125-
12677
/**
12778
* Mojang's v2 version manifest.
12879
*

core/src/main/kotlin/me/kcra/takenaka/core/Workspace.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ open class WorkspaceBuilder {
9494
*/
9595
open var rootDirectory by Delegates.notNull<Path>()
9696

97-
/**
98-
* The resolver options.
99-
*/
100-
@Deprecated("Unused.")
101-
var options = 0
102-
10397
/**
10498
* Sets the root directory.
10599
*

core/src/main/kotlin/me/kcra/takenaka/core/mapping/resolve/impl/MojangManifestAttributeProvider.kt

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
package me.kcra.takenaka.core.mapping.resolve.impl
1919

2020
import com.fasterxml.jackson.core.JacksonException
21-
import com.fasterxml.jackson.databind.ObjectMapper
21+
import io.github.oshai.kotlinlogging.KotlinLogging
2222
import me.kcra.takenaka.core.VersionAttributes
2323
import me.kcra.takenaka.core.VersionedWorkspace
2424
import me.kcra.takenaka.core.util.MAPPER
2525
import me.kcra.takenaka.core.util.copyTo
2626
import me.kcra.takenaka.core.util.readValue
27-
import io.github.oshai.kotlinlogging.KotlinLogging
2827
import java.net.URL
2928

3029
private val logger = KotlinLogging.logger {}
@@ -35,28 +34,15 @@ private val logger = KotlinLogging.logger {}
3534
* This class is thread-safe and presumes multiple instances operate on a single workspace.
3635
*
3736
* @property workspace the workspace
38-
* @property objectMapper an [ObjectMapper] that can deserialize JSON data
3937
* @property relaxedCache whether output cache verification constraints should be relaxed
4038
* @author Matouš Kučera
4139
*/
42-
class MojangManifestAttributeProvider @Deprecated(
43-
"Jackson will be an implementation detail in the future.",
44-
ReplaceWith("MojangManifestAttributeProvider(workspace, relaxedCache)")
45-
) constructor(val workspace: VersionedWorkspace, private val objectMapper: ObjectMapper, val relaxedCache: Boolean = true) {
40+
class MojangManifestAttributeProvider(val workspace: VersionedWorkspace, val relaxedCache: Boolean = true) {
4641
/**
4742
* The version attributes.
4843
*/
4944
val attributes: VersionAttributes by lazy(::readAttributes)
5045

51-
/**
52-
* Creates a new attribute provider.
53-
*
54-
* @param workspace the workspace
55-
* @param relaxedCache whether output cache verification constraints should be relaxed
56-
*/
57-
@Suppress("DEPRECATION")
58-
constructor(workspace: VersionedWorkspace, relaxedCache: Boolean = true) : this(workspace, MAPPER, relaxedCache)
59-
6046
/**
6147
* Reads the attributes of the targeted version from cache, fetching it if the cache missed.
6248
*
@@ -68,7 +54,7 @@ class MojangManifestAttributeProvider @Deprecated(
6854

6955
if (relaxedCache && ATTRIBUTES in workspace) {
7056
try {
71-
return@withLock objectMapper.readValue<VersionAttributes>(file).apply {
57+
return@withLock MAPPER.readValue<VersionAttributes>(file).apply {
7258
logger.info { "read cached ${workspace.version.id} attributes" }
7359
}
7460
} catch (e: JacksonException) {
@@ -79,7 +65,7 @@ class MojangManifestAttributeProvider @Deprecated(
7965
URL(workspace.version.url).copyTo(file)
8066

8167
logger.info { "fetched ${workspace.version.id} attributes" }
82-
return@withLock objectMapper.readValue(file)
68+
return@withLock MAPPER.readValue(file)
8369
}
8470
}
8571

core/src/main/kotlin/me/kcra/takenaka/core/mapping/resolve/impl/MojangMappingResolver.kt

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717

1818
package me.kcra.takenaka.core.mapping.resolve.impl
1919

20-
import com.fasterxml.jackson.databind.ObjectMapper
20+
import io.github.oshai.kotlinlogging.KotlinLogging
2121
import kotlinx.coroutines.CoroutineName
2222
import kotlinx.coroutines.Dispatchers
2323
import kotlinx.coroutines.withContext
2424
import me.kcra.takenaka.core.VersionedWorkspace
2525
import me.kcra.takenaka.core.mapping.MappingContributor
26-
import me.kcra.takenaka.core.mapping.resolve.*
26+
import me.kcra.takenaka.core.mapping.resolve.AbstractMappingResolver
27+
import me.kcra.takenaka.core.mapping.resolve.LicenseResolver
28+
import me.kcra.takenaka.core.mapping.resolve.Output
29+
import me.kcra.takenaka.core.mapping.resolve.lazyOutput
2730
import me.kcra.takenaka.core.util.*
28-
import io.github.oshai.kotlinlogging.KotlinLogging
2931
import net.fabricmc.mappingio.MappingUtil
3032
import net.fabricmc.mappingio.MappingVisitor
3133
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch
@@ -176,21 +178,6 @@ class MojangClientMappingResolver(
176178
workspace: VersionedWorkspace,
177179
val mojangProvider: MojangManifestAttributeProvider
178180
) : AbstractMojangMappingResolver(workspace) {
179-
/**
180-
* Creates a new resolver with a default metadata provider.
181-
*
182-
* @param workspace the workspace
183-
* @param objectMapper an [ObjectMapper] that can deserialize JSON data
184-
* @param relaxedCache whether output cache verification constraints should be relaxed
185-
*/
186-
@Deprecated(
187-
"Jackson will be an implementation detail in the future.",
188-
ReplaceWith("MojangClientMappingResolver(workspace, relaxedCache)")
189-
)
190-
@Suppress("DEPRECATION")
191-
constructor(workspace: VersionedWorkspace, objectMapper: ObjectMapper, relaxedCache: Boolean = true) :
192-
this(workspace, MojangManifestAttributeProvider(workspace, objectMapper, relaxedCache))
193-
194181
/**
195182
* Creates a new resolver with a default metadata provider.
196183
*
@@ -225,21 +212,6 @@ class MojangServerMappingResolver(
225212
workspace: VersionedWorkspace,
226213
val mojangProvider: MojangManifestAttributeProvider
227214
) : AbstractMojangMappingResolver(workspace) {
228-
/**
229-
* Creates a new resolver with a default metadata provider.
230-
*
231-
* @param workspace the workspace
232-
* @param objectMapper an [ObjectMapper] that can deserialize JSON data
233-
* @param relaxedCache whether output cache verification constraints should be relaxed
234-
*/
235-
@Deprecated(
236-
"Jackson will be an implementation detail in the future.",
237-
ReplaceWith("MojangServerMappingResolver(workspace, relaxedCache)")
238-
)
239-
@Suppress("DEPRECATION")
240-
constructor(workspace: VersionedWorkspace, objectMapper: ObjectMapper, relaxedCache: Boolean = true) :
241-
this(workspace, MojangManifestAttributeProvider(workspace, objectMapper, relaxedCache))
242-
243215
/**
244216
* Creates a new resolver with a default metadata provider.
245217
*

core/src/main/kotlin/me/kcra/takenaka/core/mapping/resolve/impl/SpigotManifestProvider.kt

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
package me.kcra.takenaka.core.mapping.resolve.impl
1919

2020
import com.fasterxml.jackson.core.JacksonException
21-
import com.fasterxml.jackson.databind.ObjectMapper
22-
import me.kcra.takenaka.core.*
23-
import me.kcra.takenaka.core.util.*
24-
import me.kcra.takenaka.core.util.MAPPER
2521
import io.github.oshai.kotlinlogging.KotlinLogging
22+
import me.kcra.takenaka.core.SpigotVersionAttributes
23+
import me.kcra.takenaka.core.SpigotVersionManifest
24+
import me.kcra.takenaka.core.VersionedWorkspace
25+
import me.kcra.takenaka.core.util.*
2626
import java.net.URL
2727

2828
private val logger = KotlinLogging.logger {}
@@ -33,14 +33,10 @@ private val logger = KotlinLogging.logger {}
3333
* This class is thread-safe and presumes multiple instances operate on a single workspace.
3434
*
3535
* @property workspace the workspace
36-
* @property objectMapper an [ObjectMapper] that can deserialize JSON data
3736
* @property relaxedCache whether output cache verification constraints should be relaxed
3837
* @author Matouš Kučera
3938
*/
40-
class SpigotManifestProvider @Deprecated(
41-
"Jackson will be an implementation detail in the future.",
42-
ReplaceWith("SpigotManifestProvider(workspace, relaxedCache)")
43-
) constructor(val workspace: VersionedWorkspace, private val objectMapper: ObjectMapper, val relaxedCache: Boolean = true) {
39+
class SpigotManifestProvider(val workspace: VersionedWorkspace, val relaxedCache: Boolean = true) {
4440
/**
4541
* The version manifest.
4642
*/
@@ -57,15 +53,6 @@ class SpigotManifestProvider @Deprecated(
5753
val isAliased: Boolean
5854
get() = attributes?.let { workspace.version.id != it.minecraftVersion } ?: false
5955

60-
/**
61-
* Creates a new manifest provider.
62-
*
63-
* @param workspace the workspace
64-
* @param relaxedCache whether output cache verification constraints should be relaxed
65-
*/
66-
@Suppress("DEPRECATION")
67-
constructor(workspace: VersionedWorkspace, relaxedCache: Boolean = true) : this(workspace, MAPPER, relaxedCache)
68-
6956
/**
7057
* Reads the manifest of the targeted version from cache, fetching it if the cache missed.
7158
*
@@ -77,7 +64,7 @@ class SpigotManifestProvider @Deprecated(
7764

7865
if (relaxedCache && MANIFEST in workspace) {
7966
try {
80-
return@withLock objectMapper.readValue<SpigotVersionManifest>(file).apply {
67+
return@withLock MAPPER.readValue<SpigotVersionManifest>(file).apply {
8168
logger.info { "read cached ${workspace.version.id} Spigot manifest" }
8269
}
8370
} catch (e: JacksonException) {
@@ -90,7 +77,7 @@ class SpigotManifestProvider @Deprecated(
9077
it.copyTo(file)
9178

9279
logger.info { "fetched ${workspace.version.id} Spigot manifest" }
93-
return@withLock objectMapper.readValue(file)
80+
return@withLock MAPPER.readValue(file)
9481
}
9582

9683
logger.warn { "failed to fetch ${workspace.version.id} Spigot manifest, received ${it.responseCode}" }
@@ -113,7 +100,7 @@ class SpigotManifestProvider @Deprecated(
113100

114101
if (relaxedCache && BUILDDATA_INFO in workspace) {
115102
try {
116-
return@withLock objectMapper.readValue<SpigotVersionAttributes>(file).apply {
103+
return@withLock MAPPER.readValue<SpigotVersionAttributes>(file).apply {
117104
logger.info { "read cached ${workspace.version.id} Spigot attributes" }
118105
}
119106
} catch (e: JacksonException) {
@@ -124,7 +111,7 @@ class SpigotManifestProvider @Deprecated(
124111
URL("https://hub.spigotmc.org/stash/projects/SPIGOT/repos/builddata/raw/info.json?at=${manifest!!.refs["BuildData"]}").copyTo(file)
125112

126113
logger.info { "fetched ${workspace.version.id} Spigot attributes" }
127-
return@withLock objectMapper.readValue(file)
114+
return@withLock MAPPER.readValue(file)
128115
}
129116
}
130117

0 commit comments

Comments
 (0)