Skip to content

Commit be488d5

Browse files
authored
feat: add support for surf-core api integration (#175)
2 parents 351e776 + 55112a6 commit be488d5

File tree

7 files changed

+45
-3
lines changed

7 files changed

+45
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
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.8.2")
23+
append("-1.9.0")
2424
if (snapshot) append("-SNAPSHOT")
2525
}
2626

@@ -163,4 +163,4 @@ idea {
163163
java {
164164
withJavadocJar()
165165
withSourcesJar()
166-
}
166+
}
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
@@ -245,6 +245,15 @@ abstract class CommonSurfPlugin<E : CommonSurfExtension>(
245245
}
246246
}
247247

248+
extension.coreModule.orNull?.let {
249+
dependencies {
250+
add(
251+
COMPILE_ONLY,
252+
"dev.slne.surf.core:${it.module}:${Constants.SURF_API_VERSION}"
253+
)
254+
}
255+
}
256+
248257
afterEvaluated0(extension)
249258
}
250259

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
@@ -49,6 +50,18 @@ open class CoreSurfExtension @Inject constructor(objects: ObjectFactory) :
4950
cloudModule.set(SurfCloudModules.SERVER)
5051
}
5152

53+
fun withCoreCommon() {
54+
coreModule.set(SurfCoreModules.COMMON)
55+
}
56+
57+
fun withCorePaper() {
58+
coreModule.set(SurfCoreModules.PAPER)
59+
}
60+
61+
fun withCoreVelocity() {
62+
coreModule.set(SurfCoreModules.VELOCITY)
63+
}
64+
5265
fun migrationMainClass(value: String) {
5366
migrationMainClass.set(value)
5467
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)