Skip to content

Commit 2347872

Browse files
feat: add support for core modules in Gradle plugin configuration
1 parent 6e09127 commit 2347872

File tree

7 files changed

+44
-2
lines changed

7 files changed

+44
-2
lines changed

surf-api-gradle-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
group = groupId
2121
version = buildString {
2222
append(mcVersion)
23-
append("-1.6.4")
23+
append("-1.6.5")
2424
if (snapshot) append("-SNAPSHOT")
2525
}
2626

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package dev.slne.surf.surfapi.gradle
2+
3+
internal enum class SurfCoreModules(val module: String) {
4+
COMMON("surf-core-api-common"),
5+
PAPER("surf-core-api-paper"),
6+
VELOCITY("surf-core-api-velocity"),
7+
}

surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/VelocityPluginFile.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ class VelocityPluginFile(project: Project) : CommonPluginFile() {
7676
optional = false
7777
}
7878
}
79+
80+
if (extension.coreModule.isPresent) {
81+
register("surf-core-velocity") {
82+
optional = false
83+
}
84+
}
7985
}
8086
}
8187

surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfExtension.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package dev.slne.surf.surfapi.gradle.platform.common
22

33
import dev.slne.surf.surfapi.gradle.SurfCloudModules
4+
import dev.slne.surf.surfapi.gradle.SurfCoreModules
45
import org.gradle.api.model.ObjectFactory
56
import org.gradle.kotlin.dsl.property
67
import org.jetbrains.annotations.MustBeInvokedByOverriders
78

89
abstract class CommonSurfExtension(protected val objects: ObjectFactory) {
910
internal val addSurfApiToClasspath = objects.property<Boolean>().convention(true)
1011
internal val surfApiScope = objects.property<String>()
11-
internal val publishingUrl = objects.property<String>().convention("https://repo.slne.dev/repository/maven-releases")
12+
internal val publishingUrl =
13+
objects.property<String>().convention("https://repo.slne.dev/repository/maven-releases")
1214
internal val publishingRepoName = objects.property<String>().convention("maven-releases")
1315
internal val cloudModule = objects.property<SurfCloudModules>()
16+
internal val coreModule = objects.property<SurfCoreModules>()
1417
internal val dependOnCloud = objects.property<Boolean>().convention(true)
1518
internal val migrationMainClass = objects.property<String>()
1619

surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPlugin.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ abstract class CommonSurfPlugin<E : CommonSurfExtension>(
217217
}
218218
}
219219

220+
extension.coreModule.orNull?.let {
221+
dependencies {
222+
add(
223+
COMPILE_ONLY,
224+
"dev.slne.surf.core:${it.module}:${Constants.SURF_API_VERSION}"
225+
)
226+
}
227+
}
228+
220229
afterEvaluated0(extension)
221230
}
222231

surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/core/CoreSurfExtension.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.slne.surf.surfapi.gradle.platform.core
22

33
import dev.slne.surf.surfapi.gradle.SurfCloudModules
4+
import dev.slne.surf.surfapi.gradle.SurfCoreModules
45
import dev.slne.surf.surfapi.gradle.platform.common.CommonSurfExtension
56
import org.gradle.api.model.ObjectFactory
67
import org.gradle.kotlin.dsl.listProperty
@@ -22,6 +23,18 @@ open class CoreSurfExtension @Inject constructor(objects: ObjectFactory) :
2223
cloudModule.set(SurfCloudModules.SERVER)
2324
}
2425

26+
fun withCoreCommon() {
27+
coreModule.set(SurfCoreModules.COMMON)
28+
}
29+
30+
fun withCorePaper() {
31+
coreModule.set(SurfCoreModules.PAPER)
32+
}
33+
34+
fun withCoreVelocity() {
35+
coreModule.set(SurfCoreModules.VELOCITY)
36+
}
37+
2538
fun migrationMainClass(value: String) {
2639
migrationMainClass.set(value)
2740
migrationMainClass.finalizeValue()

surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/paper/plugin/PaperPluginSurfPlugin.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ internal class PaperPluginSurfPlugin :
6363
if (extension.cloudModule.isPresent && extension.dependOnCloud.get()) {
6464
registerRequired("surf-cloud-bukkit")
6565
}
66+
if (extension.coreModule.isPresent) {
67+
registerRequired("surf-core-paper")
68+
}
69+
6670
extension.serverDependencies.orNull?.execute(this)
6771
}
6872
}

0 commit comments

Comments
 (0)