mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
Changed gradle to allow publication to maven central.
This commit is contained in:
parent
14d2397bcf
commit
74b31124fd
3 changed files with 128 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
|||
/.gradle/
|
||||
/build/
|
||||
/out/
|
||||
.lastDeploymentsId
|
||||
|
|
|
|||
124
build.gradle.kts
124
build.gradle.kts
|
|
@ -1,13 +1,26 @@
|
|||
import cn.lalaki.pub.BaseCentralPortalPlusExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.24"
|
||||
kotlin("jvm") version "2.0.0"
|
||||
java
|
||||
id("org.jetbrains.dokka").version("1.9.20")
|
||||
id("com.github.johnrengelman.shadow").version("7.1.2")
|
||||
id("io.github.goooler.shadow").version("8.1.8") // using fork of com.github.johnrengelman.shadow to support java 1.21
|
||||
// Maven publish
|
||||
`maven-publish`
|
||||
signing
|
||||
id("cn.lalaki.central").version("1.2.5")
|
||||
}
|
||||
|
||||
group = "xyz.alexcrea"
|
||||
version = "1.5.2"
|
||||
|
||||
java {
|
||||
disableAutoTargetJvm()
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(20))
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
|
|
@ -48,6 +61,20 @@ tasks.getByName<Test>("test") {
|
|||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// Set target version
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
sourceCompatibility = "16" // We aim for java 16 for minecraft 1.16.5. even if it not really suported.
|
||||
targetCompatibility = "16"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
|
||||
jvmTarget.set(JvmTarget.JVM_16)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fat-jar builder
|
||||
val fatJar = tasks.register<Jar>("fatJar") {
|
||||
manifest {
|
||||
|
|
@ -65,7 +92,98 @@ tasks.getByName("build") {
|
|||
dependsOn(fatJar)
|
||||
}
|
||||
|
||||
// Shadow recesary dependency
|
||||
// Shadow necessary dependency
|
||||
tasks.shadowJar {
|
||||
relocate("com.github.stefvanschie.inventoryframework", "xyz.alexcrea.inventoryframework")
|
||||
}
|
||||
|
||||
val sourcesJar by tasks.registering(Jar::class) {
|
||||
archiveClassifier.set("sources")
|
||||
from(kotlin.sourceSets.main.get().kotlin)
|
||||
}
|
||||
|
||||
val javadocJar by tasks.creating(Jar::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
description = "Assembles Javadoc JAR"
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.named("dokkaHtml"))
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
val extension = extensions
|
||||
.getByName("publishing") as PublishingExtension
|
||||
sign(extension.publications)
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
// PUBLISHING TO SONATYPE CONFIGURATION
|
||||
// ------------------------------------
|
||||
|
||||
val localMavenRepo = uri("E:\\WorkSpace\\Java\\Maven\\repo") // The path is recommended to be set to an empty directory
|
||||
centralPortalPlus {
|
||||
url = localMavenRepo
|
||||
username = System.getenv("SONATYPE_USERNAME")
|
||||
password = System.getenv("SONATYPE_PASSWORD")
|
||||
publishingType = BaseCentralPortalPlusExtension.PublishingType.USER_MANAGED // or PublishingType.AUTOMATIC
|
||||
}
|
||||
|
||||
object Meta {
|
||||
const val desc = "spigot plugin to control every aspect of the anvil."
|
||||
const val license = "GPL-3.0"
|
||||
const val githubRepo = "alexcrea/CustomAnvil"
|
||||
const val release = "https://s01.oss.sonatype.org/service/local/"
|
||||
const val snapshot = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
url = localMavenRepo // Specify the same local repo path in the configuration.
|
||||
}
|
||||
}
|
||||
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = project.group.toString()
|
||||
artifactId = project.name
|
||||
version = project.version.toString()
|
||||
from(components["kotlin"])
|
||||
artifact(tasks["sourcesJar"])
|
||||
artifact(tasks["javadocJar"])
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(Meta.desc)
|
||||
url.set("https://github.com/${Meta.githubRepo}")
|
||||
licenses {
|
||||
license {
|
||||
name.set(Meta.license)
|
||||
url.set("https://www.gnu.org/licenses/gpl-3.0.en.html")
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("alexcrea")
|
||||
name.set("alexcrea")
|
||||
email.set("alexcrea.of@laposte.net")
|
||||
url.set("https://github.com/alexcrea")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url.set(
|
||||
"https://github.com/${Meta.githubRepo}.git"
|
||||
)
|
||||
connection.set(
|
||||
"scm:git:git://github.com/${Meta.githubRepo}.git"
|
||||
)
|
||||
developerConnection.set(
|
||||
"scm:git:git://github.com/${Meta.githubRepo}.git"
|
||||
)
|
||||
}
|
||||
issueManagement {
|
||||
url.set("https://github.com/${Meta.githubRepo}/issues")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,6 @@
|
|||
kotlin.code.style=official
|
||||
kotlin.code.style=official
|
||||
|
||||
# Signing
|
||||
signing.gnupg.executable=gpg
|
||||
signing.gnupg.useLegacyGpg=true
|
||||
signing.gnupg.keyName=B0DBF91F
|
||||
Loading…
Add table
Add a link
Reference in a new issue