-
-
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.
add more robust mod dependency system
- Loading branch information
1 parent
d10c049
commit 0708157
Showing
9 changed files
with
189 additions
and
65 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
33 changes: 33 additions & 0 deletions
33
...main/kotlin/com/github/minecraftschurlimods/helperplugin/moddependencies/ModDependency.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,33 @@ | ||
package com.github.minecraftschurlimods.helperplugin.moddependencies | ||
|
||
import com.github.minecraftschurlimods.helperplugin.localGradleProperty | ||
import org.gradle.api.Project | ||
import org.gradle.api.provider.Property | ||
import org.gradle.kotlin.dsl.property | ||
|
||
class ModDependency(val name: String, project: Project) { | ||
|
||
val modId: Property<String> = project.objects.property<String>() | ||
.convention(name) | ||
val version: Property<String> = project.objects.property<String>() | ||
.convention(project.localGradleProperty(modId.map { "dependency.${it}.version" })) | ||
val versionRange: Property<String> = project.objects.property<String>() | ||
.convention(project.localGradleProperty(modId.map { "dependency.${it}.version.range" })) | ||
val type: Property<Type> = project.objects.property() | ||
val ordering: Property<Ordering> = project.objects.property() | ||
val side: Property<Side> = project.objects.property() | ||
val modrinthId: Property<String> = project.objects.property() | ||
val curseforgeId: Property<String> = project.objects.property() | ||
|
||
enum class Type { | ||
REQUIRED, OPTIONAL, INCOMPATIBLE, DISCOURAGED | ||
} | ||
|
||
enum class Ordering { | ||
BEFORE, AFTER, NONE | ||
} | ||
|
||
enum class Side { | ||
CLIENT, SERVER, BOTH | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...in/com/github/minecraftschurlimods/helperplugin/moddependencies/ModDependencyContainer.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,36 @@ | ||
package com.github.minecraftschurlimods.helperplugin.moddependencies | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.NamedDomainObjectContainer | ||
import org.gradle.api.Project | ||
import javax.inject.Inject | ||
|
||
open class ModDependencyContainer @Inject constructor(project: Project) : NamedDomainObjectContainer<ModDependency> by project.objects.domainObjectContainer(ModDependency::class.java, { name -> ModDependency(name, project) }) { | ||
fun optional(name: String, cfg: Action<ModDependency> = Action {}) = register(name) { | ||
type.set(ModDependency.Type.OPTIONAL) | ||
cfg.execute(this) | ||
} | ||
fun required(name: String, cfg: Action<ModDependency> = Action {}) = register(name) { | ||
type.set(ModDependency.Type.REQUIRED) | ||
cfg.execute(this) | ||
} | ||
|
||
fun jei(cfg: Action<ModDependency> = Action {}) = optional("jei", cfg) | ||
fun jade(cfg: Action<ModDependency> = Action {}) = optional("jade", cfg) | ||
fun theoneprobe(cfg: Action<ModDependency> = Action {}) = optional("theoneprobe") { | ||
curseforgeId.set("the-one-probe") | ||
modrinthId.set("the-one-probe") | ||
cfg.execute(this) | ||
} | ||
fun curios(cfg: Action<ModDependency> = Action {}) = optional("curios") { | ||
side.set(ModDependency.Side.BOTH) | ||
cfg.execute(this) | ||
} | ||
fun configured(cfg: Action<ModDependency> = Action {}) = optional("configured", cfg) | ||
fun catalogue(cfg: Action<ModDependency> = Action {}) = optional("catalogue", cfg) | ||
|
||
operator fun invoke(cfg: Action<ModDependencyContainer>): ModDependencyContainer { | ||
cfg.execute(this) | ||
return this | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...mods/helperplugin/GenerateModsTomlTask.kt → ...erplugin/modstoml/GenerateModsTomlTask.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
Oops, something went wrong.