Skip to content

Commit

Permalink
Merge branch 'master' into feature/adventure-api
Browse files Browse the repository at this point in the history
  • Loading branch information
vectrixdevelops committed Aug 22, 2023
2 parents 39fb169 + d6c4ce3 commit f4ff0d7
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 23 deletions.
3 changes: 3 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ dependencies {

api(libs.geantyref)

"commonsCompileOnly"(libs.jetbrains.annotations)
"commonsCompileOnly"(libs.lombok)

"bukkitCompileOnly"(libs.bukkit.api)
"bukkitCompileOnly"(libs.bukkit)

Expand Down
1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

dependencies {
implementation(libs.artifactregistry)
implementation(libs.idea)
implementation(libs.spotless)
implementation(libs.shadow)
}
Expand Down
19 changes: 19 additions & 0 deletions build-logic/src/main/kotlin/apollo.parent-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
eclipse
id("org.jetbrains.gradle.plugin.idea-ext")
}

eclipse {
val shadowJar = tasks.getByPath(":apollo-api:shadowJar")
synchronizationTasks(shadowJar)
}

idea {
if(project != null) {
(project as ExtensionAware).extensions["settings"].run {
(this as ExtensionAware).extensions.getByType(org.jetbrains.gradle.ext.TaskTriggersConfig::class).run {
afterSync(":apollo-api:shadowJar")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ plugins {
tasks {
jar {
archiveClassifier.set("dev")
// archiveFileName.set("${project.name}-${project.version}-dev.jar")
}

val shadowJar = named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
configureRelocations()
// archiveFileName.set("${project.name}-${project.version}.jar")
}

assemble {
Expand Down
65 changes: 46 additions & 19 deletions build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,71 @@ 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.configure
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.*

fun JavaPluginExtension.javaTarget(version: Int) {
toolchain.languageVersion.set(JavaLanguageVersion.of(version))
}

fun Project.createApiSources(vararg names: String) {
extensions.configure<JavaPluginExtension> {
val mainSource by sourceSets.named("main")
val platformSources = mutableListOf(mainSource)
platformSources.addAll(names.map {
val commonsCompileOnly by configurations.register("commonsCompileOnly")

val main by sourceSets
names.forEach {
sourceSets.register(it) {
java.setSrcDirs(setOf("src/$it/java"))
compileClasspath += mainSource.compileClasspath
runtimeClasspath += mainSource.runtimeClasspath
dependencies.add(implementationConfigurationName, objects.fileCollection().from(mainSource.output.classesDirs))

project.dependencies.add(this.implementationConfigurationName, main.output)

configurations.named(compileOnlyConfigurationName) {
extendsFrom(commonsCompileOnly)
}
}.get()
})
}

tasks.named<ShadowJar>("shadowJar") {
platformSources.forEach {
from(it.output)
sourceSets.configureEach {
val sourceSet = this
val sourceName = sourceSet.name
if (sourceName.equals("main")) return@configureEach

tasks.register("${sourceName}Jar", Jar::class.java) {
archiveClassifier.set(sourceName)
from(sourceSet.output)
}
}

tasks.named<Jar>("sourcesJar") {
platformSources.forEach {
from(it.allSource)
tasks.named<ShadowJar>("shadowJar") {
sourceSets.forEach {
val sourceName = it.name
val sourceJarName = if (sourceName.equals("main")) "sourcesJar" else "${sourceName}Jar"

val sourceJar by tasks.named<Jar>(sourceJarName)
from(sourceJar)
}
}

tasks.named<Javadoc>("javadoc") {
source(platformSources.map { it.allJava })
classpath += platformSources.map { it.compileClasspath }.reduce { first, second -> first + second }
source(sourceSets.map { it.allJava })
classpath += sourceSets.map { it.compileClasspath }.reduce { first, second -> first + second }
}

// tasks.named<ShadowJar>("shadowJar") {
// platformSources.forEach {
// from(it.output)
// }
// }
//
// tasks.named<Jar>("sourcesJar") {
// platformSources.forEach {
// from(it.allSource)
// }
// }
//
// tasks.named<Javadoc>("javadoc") {
// source(platformSources.map { it.allJava })
// classpath += platformSources.map { it.compileClasspath }.reduce { first, second -> first + second }
// }
}
}

Expand Down
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
plugins {
id("apollo.parent-conventions")
}

// Project metadata is configured in gradle.properties
2 changes: 1 addition & 1 deletion bukkit-example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("apollo.base-conventions")
id("apollo.shadow-conventions")
}

dependencies {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bukkit = "1.8.8-R0.1-SNAPSHOT"
bungee = "1.19-R0.1-SNAPSHOT"
configurate = "4.2.0-SNAPSHOT"
geantyref = "1.3.11"
idea = "1.1.7"
jetbrains = "24.0.1"
lombok = "1.18.26"
protobuf = "1.0-SNAPSHOT"
Expand Down Expand Up @@ -46,6 +47,7 @@ velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocit
artifactregistry = { module = "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin", version.ref = "artifactregistry" }
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }
shadow = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "shadow" }
idea = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext", version.ref = "idea" }

stylecheck = "ca.stellardrift:stylecheck:0.1"

Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
maven("https://repo.lunarclient.dev")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://us-maven.pkg.dev/moonsworth-299m4oir/maven-public")
Expand Down

0 comments on commit f4ff0d7

Please sign in to comment.