-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make most things not use coroutines, improve component metadata rules…
…, fix access wideners, improve run configuration argument handling
- Loading branch information
Showing
55 changed files
with
893 additions
and
924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...tlin/net/msrandom/minecraftcodev/core/MinecraftDependenciesOperatingSystemMetadataRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package net.msrandom.minecraftcodev.core | ||
|
||
import net.msrandom.minecraftcodev.core.resolve.MinecraftVersionMetadata | ||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.nativeplatform.OperatingSystemFamily | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
@CacheableRule | ||
abstract class MinecraftDependenciesOperatingSystemMetadataRule @Inject constructor( | ||
private val cacheDirectory: File, | ||
private val versions: List<String>, | ||
private val versionManifestUrl: String, | ||
private val isOffline: Boolean, | ||
) : ComponentMetadataRule { | ||
abstract val objectFactory: ObjectFactory | ||
@Inject get | ||
|
||
override fun execute(context: ComponentMetadataContext) { | ||
val versionList = getVersionList(cacheDirectory.toPath(), versionManifestUrl, isOffline) | ||
|
||
val id = context.details.id | ||
|
||
val libraries = versions.asSequence().flatMap { | ||
versionList.version(it).libraries | ||
}.filter { | ||
it.name.group == id.group && it.name.module == id.name && it.name.version == id.version | ||
} | ||
|
||
val classifierOperatingSystems = libraries.flatMap { | ||
buildList { | ||
if (it.name.classifier != null) { | ||
val osName = it.rules.firstOrNull { | ||
it.action == MinecraftVersionMetadata.RuleAction.Allow | ||
}?.os?.name | ||
|
||
if (osName != null) { | ||
add(osName to it.downloads.artifact!!.path.substringAfterLast('/')) | ||
} | ||
} | ||
|
||
addAll(it.natives.entries.map { (key, value) -> | ||
key to it.downloads.classifiers.getValue(value).path.substringAfterLast('/') | ||
}) | ||
} | ||
} | ||
|
||
for ((operatingSystem, file) in classifierOperatingSystems.distinctBy { (operatingSystem, _) -> operatingSystem }) { | ||
context.details.addVariant(operatingSystem, "runtime") { variant -> | ||
variant.attributes { attribute -> | ||
attribute.attribute( | ||
OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, | ||
objectFactory.named(OperatingSystemFamily::class.java, operatingSystem), | ||
) | ||
} | ||
|
||
variant.withFiles { files -> | ||
files.addFile(file) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.