Skip to content

Commit

Permalink
Build cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Dec 9, 2023
1 parent a71f23e commit 7d3a91f
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 45 deletions.
2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("publishing-conventions")
id("squaremap.publishing")
}

description = "API for extending squaremap, a minimalistic and lightweight world map viewer for Minecraft servers"
Expand Down
2 changes: 2 additions & 0 deletions build-logic/src/main/kotlin/CopyFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.work.DisableCachingByDefault

@DisableCachingByDefault(because = "Not worth caching")
abstract class CopyFile : DefaultTask() {
@get:InputFile
abstract val fileToCopy: RegularFileProperty
Expand Down
8 changes: 6 additions & 2 deletions build-logic/src/main/kotlin/SquaremapPlatformExtension.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.kotlin.dsl.newInstance
import javax.inject.Inject

abstract class SquaremapPlatformExtension {
abstract class SquaremapPlatformExtension @Inject constructor(objects: ObjectFactory) {
abstract val productionJar: RegularFileProperty
val loom: Loom = objects.newInstance(Loom::class)

abstract class Loom : SquaremapPlatformExtension() {
abstract class Loom {
abstract val modInfoFilePath: Property<String>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ repositories {
sonatype.s01Snapshots()
sonatype.ossSnapshots()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://maven.fabricmc.net/") {
mavenContent { includeGroup("net.fabricmc") }
}
}

tasks.withType(JavaCompile::class).configureEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import me.modmuss50.mpp.ReleaseType

plugins {
id("base-conventions")
id("squaremap.base-conventions")
id("com.github.johnrengelman.shadow")
id("me.modmuss50.mod-publish-plugin")
}

val platformExt = extensions.create(
SquaremapPlatformExtension::class,
"squaremapPlatform",
SquaremapPlatformExtension.Loom::class
)
val platformExt = extensions.create("squaremapPlatform", SquaremapPlatformExtension::class)

decorateVersion()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
plugins {
id("platform-conventions")
id("squaremap.platform")
id("xyz.jpenilla.quiet-architectury-loom")
}

extensions.add(
SquaremapPlatformExtension.Loom::class.java,
"squaremapLoomPlatform",
extensions.getByType<SquaremapPlatformExtension>() as SquaremapPlatformExtension.Loom
)
val loomExt = extensions.getByType<SquaremapPlatformExtension.Loom>()
loomExt.productionJar = tasks.remapJar.flatMap { it.archiveFile }
val platformExt = extensions.getByType<SquaremapPlatformExtension>()
platformExt.productionJar = tasks.remapJar.flatMap { it.archiveFile }

val squaremap: Configuration by configurations.creating
val shade: Configuration by configurations.creating
configurations.implementation {
extendsFrom(squaremap)
extendsFrom(shade)
}
val shadeFiltered: Configuration by configurations.creating {
extendsFrom(shade)

exclude("org.checkerframework")
exclude("com.google.errorprone")
}

tasks {
shadowJar {
configurations = listOf(squaremap)
configurations = listOf(shadeFiltered)
listOf(
"javax.inject",
"com.google.inject",
"org.aopalliance",
).forEach(::reloc)
dependencies {
exclude { it.moduleGroup == "org.checkerframework" || it.moduleGroup == "com.google.errorprone" }
}
}
}

Expand All @@ -38,7 +36,7 @@ afterEvaluate {
"description" to project.description,
)
inputs.properties(props)
filesMatching(loomExt.modInfoFilePath.get()) {
filesMatching(platformExt.loom.modInfoFilePath.get()) {
// filter manually to avoid trying to replace $Initializer in initializer class name...
filter { string ->
var result = string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("base-conventions")
id("squaremap.base-conventions")
id("net.kyori.indra.publishing")
}

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

group = "xyz.jpenilla"
version = "1.2.3-SNAPSHOT"
description = "Minimalistic and lightweight world map viewer for Minecraft servers"
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("base-conventions")
id("squaremap.base-conventions")
id("org.spongepowered.gradle.vanilla")
}

Expand Down
8 changes: 4 additions & 4 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("loom-platform-conventions")
id("squaremap.platform.loom")
}

loom.accessWidenerPath.set(layout.projectDirectory.file("src/main/resources/squaremap-fabric.accesswidener"))
loom.accessWidenerPath = layout.projectDirectory.file("src/main/resources/squaremap-fabric.accesswidener")

repositories {
maven("https://maven.ladysnake.org/releases/") {
Expand All @@ -18,7 +18,7 @@ dependencies {
modImplementation(libs.fabricLoader)
modImplementation(libs.fabricApi)

squaremap(projects.squaremapCommon) {
shade(projects.squaremapCommon) {
exclude("cloud.commandframework", "cloud-core")
exclude("cloud.commandframework", "cloud-minecraft-extras")
exclude("io.leangen.geantyref")
Expand All @@ -41,7 +41,7 @@ dependencies {
include(libs.cardinalComponentsEntity)
}

squaremapLoomPlatform.modInfoFilePath = "fabric.mod.json"
squaremapPlatform.loom.modInfoFilePath = "fabric.mod.json"

tasks.remapJar {
archiveFileName = productionJarName(libs.versions.minecraft)
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
group=xyz.jpenilla
version=1.2.3-SNAPSHOT
description=Minimalistic and lightweight world map viewer for Minecraft servers

githubUrl=https://github.com/jpenilla/squaremap/

org.gradle.parallel=true
Expand Down
6 changes: 3 additions & 3 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("loom-platform-conventions")
id("squaremap.platform.loom")
}

repositories {
Expand All @@ -11,7 +11,7 @@ dependencies {
mappings(loom.officialMojangMappings())
neoForge(libs.neoforge)

squaremap(projects.squaremapCommon) {
shade(projects.squaremapCommon) {
exclude("cloud.commandframework", "cloud-core")
exclude("cloud.commandframework", "cloud-minecraft-extras")
exclude("io.leangen.geantyref")
Expand Down Expand Up @@ -43,7 +43,7 @@ tasks.remapJar {
archiveFileName = productionJarName(libs.versions.minecraft)
}

squaremapLoomPlatform.modInfoFilePath = "META-INF/mods.toml"
squaremapPlatform.loom.modInfoFilePath = "META-INF/mods.toml"

publishMods.modrinth {
minecraftVersions.add(libs.versions.minecraft)
Expand Down
4 changes: 2 additions & 2 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io.papermc.hangarpublishplugin.model.Platforms

plugins {
id("platform-conventions")
id("squaremap.platform")
id("io.papermc.paperweight.userdev")
alias(libs.plugins.run.paper)
alias(libs.plugins.hangar.publish)
Expand Down Expand Up @@ -51,7 +51,7 @@ tasks {
"version" to project.version,
"website" to providers.gradleProperty("githubUrl").get(),
"description" to project.description,
"apiVersion" to "'" + minecraftVersion.get().take(4) + "'",
"apiVersion" to minecraftVersion.get().take(4),
)
inputs.properties(props)
filesMatching("plugin.yml") {
Expand Down
2 changes: 1 addition & 1 deletion paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ description: $description
authors:
- jmp
website: $website
api-version: $apiVersion
api-version: '$apiVersion'
folia-supported: true
2 changes: 1 addition & 1 deletion sponge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.spongepowered.gradle.plugin.config.PluginLoaders
import org.spongepowered.plugin.metadata.model.PluginDependency

plugins {
id("platform-conventions")
id("squaremap.platform")
alias(libs.plugins.sponge.gradle.plugin)
id("org.spongepowered.gradle.vanilla")
alias(libs.plugins.sponge.gradle.ore)
Expand Down

0 comments on commit 7d3a91f

Please sign in to comment.