diff --git a/main/src/Anotations.kt b/main/src/Anotations.kt index fc407b4..322194b 100644 --- a/main/src/Anotations.kt +++ b/main/src/Anotations.kt @@ -1,7 +1,5 @@ package io.github.liplum.mindustry -import org.gradle.api.Project - /** * It indicates this property will inherit value from its parent project by default. */ @@ -11,44 +9,3 @@ import org.gradle.api.Project ) @MustBeDocumented annotation class InheritFromParent -/** - * It represents the default value of this property. - */ -@Target( - AnnotationTarget.FIELD, - AnnotationTarget.PROPERTY -) -@MustBeDocumented -annotation class DefaultValue( - val default: String, -) -/** - * It indicates this property corresponds to a key in `local.properties` file. - */ -@Target( - AnnotationTarget.FIELD, - AnnotationTarget.PROPERTY -) -annotation class LocalProperty( - /** - * The key in `local.properties` file - */ - val key: String, -) -/** - * It indicates this property will read default value from [Project.getProperties] - */ -@Target( - AnnotationTarget.FIELD, - AnnotationTarget.PROPERTY -) -annotation class PropertyAsDefault( - /** - * The key in [Project.getProperties] - */ - val key: String, - /** - * If the key doesn't exist, this value will be truly default. - */ - val default: String, -) diff --git a/main/src/mindustry/model/Dependency.kt b/main/src/mindustry/model/Dependency.kt index 6afa848..f276d11 100644 --- a/main/src/mindustry/model/Dependency.kt +++ b/main/src/mindustry/model/Dependency.kt @@ -51,7 +51,6 @@ class DependencySpec( * DO NOT trust this behavior, it may change later. */ @InheritFromParent - @DefaultValue("on \"v135\"") val arcDependency = target.prop().apply { convention(ArcDependency()) } @@ -62,7 +61,6 @@ class DependencySpec( * Default: official "v135" */ @InheritFromParent - @DefaultValue("on \"v135\"") val mindustryDependency = target.prop().apply { convention(MindustryDependency()) } diff --git a/main/src/plugin/Main.kt b/main/src/plugin/Main.kt index 99e90b7..e162491 100644 --- a/main/src/plugin/Main.kt +++ b/main/src/plugin/Main.kt @@ -29,8 +29,10 @@ class MindustryPlugin : Plugin { parent?.let { if (it.plugins.hasPlugin()) { val parentEx = it.extensions.getOrCreate(R.x.mindustry) + val parentRun = it.extensions.getOrCreate(R.x.runMindustry) ex._dependency.mindustryDependency.set(parentEx._dependency.mindustryDependency) ex._dependency.arcDependency.set(parentEx._dependency.arcDependency) + run._includeMyMod.set(parentRun._includeMyMod) } } // Register this for dynamically configure tasks without class reference in groovy. @@ -53,7 +55,7 @@ class MindustryPlugin : Plugin { deployX._version.convention(provider { ex._modMeta.get().version }) - plugins.apply() + plugins.apply() GroovyBridge.attach(target) } } diff --git a/main/src/plugin/App.kt b/main/src/plugin/Run.kt similarity index 81% rename from main/src/plugin/App.kt rename to main/src/plugin/Run.kt index b1214e0..40c08bf 100644 --- a/main/src/plugin/App.kt +++ b/main/src/plugin/Run.kt @@ -14,7 +14,7 @@ import org.gradle.api.plugins.JavaPlugin /** * For downloading and running game. */ -class MindustryAppPlugin : Plugin { +class MindustryRunPlugin : Plugin { override fun apply(target: Project) { target.tasks.register(R.task.cleanMindustrySharedCache) { group = BasePlugin.BUILD_GROUP @@ -59,11 +59,13 @@ class MindustryAppPlugin : Plugin { dependsOn(resolveModpackTask) mods.from(resolveModpackTask) } - if (proj.plugins.hasPlugin()) { - mods.from(proj.tasks.getByPath(JavaPlugin.JAR_TASK_NAME)) - } - if (proj.plugins.hasPlugin()) { - mods.from(proj.tasks.getByPath(R.task.zipMod)) + if (x.includeMyMod) { + if (proj.plugins.hasPlugin()) { + mods.from(proj.tasks.getByPath(JavaPlugin.JAR_TASK_NAME)) + } + if (proj.plugins.hasPlugin()) { + mods.from(proj.tasks.getByPath(R.task.zipMod)) + } } } } @@ -90,11 +92,13 @@ class MindustryAppPlugin : Plugin { dependsOn(resolveModpackTask) mods.from(resolveModpackTask) } - if (proj.plugins.hasPlugin()) { - mods.from(proj.tasks.getByPath(JavaPlugin.JAR_TASK_NAME)) - } - if (proj.plugins.hasPlugin()) { - mods.from(proj.tasks.getByPath(R.task.zipMod)) + if (x.includeMyMod) { + if (proj.plugins.hasPlugin()) { + mods.from(proj.tasks.getByPath(JavaPlugin.JAR_TASK_NAME)) + } + if (proj.plugins.hasPlugin()) { + mods.from(proj.tasks.getByPath(R.task.zipMod)) + } } } } diff --git a/main/src/run/RunMindustry.kt b/main/src/run/RunMindustry.kt index fbc2ce6..4ccf96b 100644 --- a/main/src/run/RunMindustry.kt +++ b/main/src/run/RunMindustry.kt @@ -2,9 +2,11 @@ package io.github.liplum.mindustry +import io.github.liplum.dsl.prop import org.gradle.api.Action import org.gradle.api.Project import org.gradle.api.plugins.ExtensionAware +import org.gradle.api.plugins.JavaPlugin /** * Retrieves the `runMindustry`: [RunMindustryExtension] extension. @@ -30,6 +32,22 @@ open class RunMindustryExtension( val clients = ArrayList() val servers = ArrayList() val modpacks = ArrayList() + val _includeMyMod = proj.prop().apply { + convention(true) + } + + /** + * Whether to include the mod that this project output in [R.task.zipMod] and [JavaPlugin.JAR_TASK_NAME]. + * `true` by default. + * + * TODO: maybe configurable for each client/server? + */ + @InheritFromParent + var includeMyMod: Boolean + get() = _includeMyMod.getOrElse(true) + set(value) { + _includeMyMod.set(value) + } /** * ### Kotlin DSL @@ -38,7 +56,7 @@ open class RunMindustryExtension( * official(version="v141") * } * addClient("my name") { - * be latest + * be(latest) * } * addClient { * github(