mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Better build script and create offline build
This commit is contained in:
parent
6fa7cc0168
commit
be53cbf5bd
2 changed files with 66 additions and 13 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import cn.lalaki.pub.BaseCentralPortalPlusExtension
|
import cn.lalaki.pub.BaseCentralPortalPlusExtension
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
|
@ -14,7 +15,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
version = "1.6.3"
|
version = "1.6.3-test"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// EcoEnchants
|
// EcoEnchants
|
||||||
|
|
@ -56,6 +57,9 @@ dependencies {
|
||||||
implementation(project(":nms:v1_20R3", configuration = "reobf"))
|
implementation(project(":nms:v1_20R3", configuration = "reobf"))
|
||||||
implementation(project(":nms:v1_20R4", configuration = "reobf"))
|
implementation(project(":nms:v1_20R4", configuration = "reobf"))
|
||||||
implementation(project(":nms:v1_21R1", configuration = "reobf"))
|
implementation(project(":nms:v1_21R1", configuration = "reobf"))
|
||||||
|
|
||||||
|
// include kotlin for the offline jar
|
||||||
|
implementation(kotlin("stdlib"))
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
@ -112,21 +116,66 @@ val fatJar = tasks.register<Jar>("fatJar") {
|
||||||
manifest {
|
manifest {
|
||||||
attributes.apply { put("Main-Class", "io.delilaheve.CustomAnvil") }
|
attributes.apply { put("Main-Class", "io.delilaheve.CustomAnvil") }
|
||||||
}
|
}
|
||||||
archiveFileName.set("${rootProject.name}-${archiveVersion}.jar")
|
archiveFileName.set("${rootProject.name}-${project.version}.jar")
|
||||||
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
|
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
|
||||||
duplicatesStrategy = DuplicatesStrategy.WARN
|
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||||
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
|
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
|
||||||
with(tasks.jar.get() as CopySpec)
|
with(tasks.jar.get() as CopySpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure fatJar and copyJar are run
|
tasks {
|
||||||
tasks.getByName("build") {
|
// Online jar (use of libraries)
|
||||||
dependsOn(fatJar)
|
shadowJar {
|
||||||
}
|
// No suffix for this jar
|
||||||
|
archiveClassifier.set("")
|
||||||
|
|
||||||
|
// Exclude kotlin std and its annotation
|
||||||
|
exclude("**/kotlin-stdlib*.jar")
|
||||||
|
exclude("**/annotations*.jar")
|
||||||
|
|
||||||
// Shadow necessary dependency
|
// Shadow necessary dependency
|
||||||
tasks.shadowJar {
|
|
||||||
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework")
|
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework")
|
||||||
|
|
||||||
|
// Replace version and example fields in plugin.yml
|
||||||
|
filesMatching("plugin.yml") {
|
||||||
|
expand(
|
||||||
|
"version" to project.version,
|
||||||
|
"libraries" to " \"org.jetbrains.kotlin:kotlin-stdlib:1.9.24\" "
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process resource for plugin.yml
|
||||||
|
dependsOn(processResources)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offline jar (include kotlin std in the final jar fine)
|
||||||
|
val offlineJar by creating(ShadowJar::class) {
|
||||||
|
archiveClassifier.set("offline")
|
||||||
|
|
||||||
|
// Shadow necessary dependency
|
||||||
|
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework")
|
||||||
|
|
||||||
|
filesMatching("plugin.yml") {
|
||||||
|
expand(
|
||||||
|
"version" to "${project.version}-offline",
|
||||||
|
"libraries" to ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include all project other dependencies
|
||||||
|
from(project.configurations.runtimeClasspath)
|
||||||
|
|
||||||
|
// Add custom anvil compiled
|
||||||
|
from(sourceSets.main.get().output)
|
||||||
|
|
||||||
|
dependsOn(processResources)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the online and offline jar on build
|
||||||
|
named("build") {
|
||||||
|
dependsOn(shadowJar, offlineJar)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesJar by tasks.registering(Jar::class) {
|
val sourcesJar by tasks.registering(Jar::class) {
|
||||||
|
|
@ -152,7 +201,12 @@ signing {
|
||||||
// PUBLISHING TO SONATYPE CONFIGURATION
|
// PUBLISHING TO SONATYPE CONFIGURATION
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
val localMavenRepo = uri("E:\\WorkSpace\\Java\\Maven\\repo") // The path is recommended to be set to an empty directory
|
// The path is recommended to be set to an empty directory
|
||||||
|
val localMavenRepo = uri(
|
||||||
|
project.findProperty("localMavenRepo") as String?
|
||||||
|
?: rootProject.layout.buildDirectory.dir("local-maven-repo").get().asFile.toURI() // Convert to URI
|
||||||
|
)
|
||||||
|
|
||||||
centralPortalPlus {
|
centralPortalPlus {
|
||||||
url = localMavenRepo
|
url = localMavenRepo
|
||||||
username = System.getenv("SONATYPE_USERNAME")
|
username = System.getenv("SONATYPE_USERNAME")
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
main: io.delilaheve.CustomAnvil
|
main: io.delilaheve.CustomAnvil
|
||||||
name: CustomAnvil
|
name: CustomAnvil
|
||||||
prefix: "Custom Anvil"
|
prefix: "Custom Anvil"
|
||||||
version: 1.6.3
|
version: ${version}
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
description: Allow to customise anvil mechanics
|
description: Allow to customise anvil mechanics
|
||||||
api-version: 1.16
|
api-version: 1.16
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
authors: [ DelilahEve, alexcrea ]
|
authors: [ DelilahEve, alexcrea ]
|
||||||
libraries:
|
libraries: [${libraries}]
|
||||||
- org.jetbrains.kotlin:kotlin-stdlib:1.9.24
|
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
anvilconfigreload:
|
anvilconfigreload:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue