diff --git a/api/build.gradle.kts b/api/build.gradle.kts index aa15faab..5dfe9379 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -3,99 +3,28 @@ plugins { id("apollo.publish-conventions") } -val bukkitConfig = configurations.register("bukkit") -val bungeeConfig = configurations.register("bungee") -val velocityConfig = configurations.register("velocity") +setupPlatforms() -val main by sourceSets - -val bukkitSource by sourceSets.register("bukkit") { - project.dependencies.add(this.implementationConfigurationName, main.output) - - compileClasspath += main.compileClasspath - compileClasspath += main.runtimeClasspath - - configurations.named(implementationConfigurationName) { - extendsFrom(bukkitConfig.get()) - } -} - -val bungeeSource by sourceSets.register("bungee") { - project.dependencies.add(this.implementationConfigurationName, main.output) - - compileClasspath += main.compileClasspath - compileClasspath += main.runtimeClasspath - - configurations.named(implementationConfigurationName) { - extendsFrom(bungeeConfig.get()) - } -} - -val velocitySource by sourceSets.register("velocity") { - project.dependencies.add(this.implementationConfigurationName, main.output) - - compileClasspath += main.compileClasspath - compileClasspath += main.runtimeClasspath +setupPlatformDependency("bukkit", "bukkitJar") +setupPlatformDependency("bungee", "bungeeJar") +setupPlatformDependency("velocity", "velocityJar") - configurations.named(implementationConfigurationName) { - extendsFrom(velocityConfig.get()) - } -} +val main by sourceSets dependencies { api(project(":extra:apollo-extra-adventure4")) api(libs.geantyref) - val bukkit = bukkitConfig.name - bukkit(main.output) - bukkit(libs.bukkit.api) - bukkit(libs.bukkit) - - val bungee = bungeeConfig.name - bungee(main.output) - bungee(libs.bungee) - - val velocity = velocityConfig.name - velocity(main.output) - velocity(libs.velocity) -} - -tasks { - val bukkitJar by registering(Jar::class) { - archiveClassifier.set("bukkit") - from(bukkitSource.output) - } + "bukkit"(main.output) + "bukkit"(libs.bukkit.api) + "bukkit"(libs.bukkit) - val bungeeJar by registering(Jar::class) { - archiveClassifier.set("bungee") - from(bungeeSource.output) - } - - val velocityJar by registering(Jar::class) { - archiveClassifier.set("velocity") - from(velocitySource.output) - } - - shadowJar { - configurations = listOf() - - from(jar) - from(bukkitJar) - from(bungeeJar) - from(velocityJar) - } - - javadoc { - source(sourceSets.map { it.allJava }) - classpath += sourceSets.map { it.compileClasspath }.reduce { first, second -> first + second } - } -} + "bungee"(main.output) + "bungee"(libs.bungee) -artifacts { - add("bukkit", tasks["bukkitJar"]) - add("bungee", tasks["bungeeJar"]) - add("velocity", tasks["velocityJar"]) + "velocity"(main.output) + "velocity"(libs.velocity) } publishShadowJar() diff --git a/build-logic/src/main/kotlin/extensions.kt b/build-logic/src/main/kotlin/extensions.kt index 27184bf6..b5187835 100644 --- a/build-logic/src/main/kotlin/extensions.kt +++ b/build-logic/src/main/kotlin/extensions.kt @@ -1,9 +1,10 @@ -import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.javadoc.Javadoc +import org.gradle.jvm.tasks.Jar import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.* @@ -20,6 +21,55 @@ fun ShadowJar.configureExclusions() { exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA") } +fun Project.setupPlatforms() { + extensions.configure { + val jar by tasks.named("jar") + + val shadowJar by tasks.named("shadowJar", ShadowJar::class) { + configurations = listOf() + + from(jar) + } + + tasks.named("javadoc", Javadoc::class) { + source(sourceSets.map { it.allJava }) + classpath += sourceSets.map { it.compileClasspath }.reduce { first, second -> first + second } + } + } +} + +fun Project.setupPlatformDependency(configurationName: String, jarTaskName: String) { + extensions.configure { + val configuration = configurations.register(configurationName) + + val main by sourceSets + + val source by sourceSets.register(configurationName) { + project.dependencies.add(this.implementationConfigurationName, main.output) + + compileClasspath += main.compileClasspath + compileClasspath += main.runtimeClasspath + + configurations.named(this.implementationConfigurationName) { + extendsFrom(configuration.get()) + } + } + + val jarTask by tasks.register(jarTaskName, Jar::class) { + archiveClassifier.set(configurationName) + from(source.output) + } + + tasks.named("shadowJar", ShadowJar::class) { + from(jarTask) + } + + artifacts { + add(configurationName, jarTask) + } + } +} + fun Project.setupDynamicLoader() { extensions.configure { val loaderCompileOnlyConfig = configurations.register("loaderCompileOnly") diff --git a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java index 8bfbc95a..e597e0b3 100644 --- a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java +++ b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java @@ -67,6 +67,7 @@ import com.lunarclient.apollo.option.OptionsImpl; import java.util.logging.Logger; import lombok.Getter; +import lombok.RequiredArgsConstructor; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; @@ -78,6 +79,7 @@ * * @since 1.0.0 */ +@RequiredArgsConstructor public final class ApolloBukkitPlatform implements PlatformPlugin, ApolloPlatform { @Getter private static ApolloBukkitPlatform instance; @@ -86,16 +88,6 @@ public final class ApolloBukkitPlatform implements PlatformPlugin, ApolloPlatfor @Getter private final JavaPlugin plugin; - /** - * Constructs a new {@link ApolloBukkitPlatform}. - * - * @param plugin the plugin instance - * @since 1.0.0 - */ - public ApolloBukkitPlatform(JavaPlugin plugin) { - this.plugin = plugin; - } - @Override public void onEnable() { ApolloBukkitPlatform.instance = this; diff --git a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java index b81d4221..3b62a629 100644 --- a/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java +++ b/bungee/src/main/java/com/lunarclient/apollo/ApolloBungeePlatform.java @@ -30,6 +30,7 @@ import com.lunarclient.apollo.option.OptionsImpl; import java.util.logging.Logger; import lombok.Getter; +import lombok.RequiredArgsConstructor; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Plugin; @@ -38,6 +39,7 @@ * * @since 1.0.0 */ +@RequiredArgsConstructor public final class ApolloBungeePlatform implements PlatformPlugin, ApolloPlatform { @Getter private static ApolloBungeePlatform instance; @@ -46,16 +48,6 @@ public final class ApolloBungeePlatform implements PlatformPlugin, ApolloPlatfor @Getter private final Plugin plugin; - /** - * Constructs a new {@link ApolloBungeePlatform}. - * - * @param plugin the plugin instance - * @since 1.0.0 - */ - public ApolloBungeePlatform(Plugin plugin) { - this.plugin = plugin; - } - @Override public void onEnable() { ApolloBungeePlatform.instance = this; diff --git a/settings.gradle.kts b/settings.gradle.kts index e5c87e7d..ecb0d4e8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,8 +14,6 @@ pluginManagement { } } -enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") - dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) repositories {