Fix: Publishing (hopefully)
This commit is contained in:
parent
d9aff99d57
commit
e1df9d3d9d
2 changed files with 85 additions and 15 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
import groovy.util.Node
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`java-library`
|
`java-library`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
|
@ -14,6 +17,8 @@ repositories {
|
||||||
maven("https://repo.codemc.io/repository/maven-snapshots/")
|
maven("https://repo.codemc.io/repository/maven-snapshots/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isShadow = project.pluginManager.hasPlugin("io.github.goooler.shadow")
|
||||||
|
|
||||||
java {
|
java {
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
|
@ -23,6 +28,11 @@ java {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
withType<JavaCompile> {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release = 8
|
||||||
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property("version", project.version)
|
inputs.property("version", project.version)
|
||||||
filesMatching(listOf("plugin.yml", "velocity-plugin.json")) {
|
filesMatching(listOf("plugin.yml", "velocity-plugin.json")) {
|
||||||
|
@ -30,25 +40,72 @@ tasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
withType<JavaCompile> {
|
jar {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
archiveClassifier = "default"
|
||||||
options.release = 8
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
groupId = project.group.toString()
|
|
||||||
artifactId = project.name
|
|
||||||
version = project.version.toString()
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTasks("build")
|
defaultTasks("build")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("shadow") {
|
||||||
|
groupId = project.group as String
|
||||||
|
artifactId = "EntityLib-" + project.name
|
||||||
|
version = project.version as String
|
||||||
|
|
||||||
|
if (isShadow) {
|
||||||
|
artifact(project.tasks.withType<ShadowJar>().getByName("shadowJar").archiveFile)
|
||||||
|
|
||||||
|
val allDependencies = project.provider {
|
||||||
|
project.configurations.getByName("shadow").allDependencies
|
||||||
|
.filter { it is ProjectDependency || it !is SelfResolvingDependency }
|
||||||
|
}
|
||||||
|
|
||||||
|
pom {
|
||||||
|
withXml {
|
||||||
|
val (libraryDeps, projectDeps) = allDependencies.get().partition { it !is ProjectDependency }
|
||||||
|
val dependenciesNode = asNode().get("dependencies") as? Node ?: asNode().appendNode("dependencies")
|
||||||
|
|
||||||
|
libraryDeps.forEach {
|
||||||
|
val dependencyNode = dependenciesNode.appendNode("dependency")
|
||||||
|
dependencyNode.appendNode("groupId", it.group)
|
||||||
|
dependencyNode.appendNode("artifactId", it.name)
|
||||||
|
dependencyNode.appendNode("version", it.version)
|
||||||
|
dependencyNode.appendNode("scope", "compile")
|
||||||
|
}
|
||||||
|
|
||||||
|
projectDeps.forEach {
|
||||||
|
val dependencyNode = dependenciesNode.appendNode("dependency")
|
||||||
|
dependencyNode.appendNode("groupId", it.group)
|
||||||
|
dependencyNode.appendNode("artifactId", "packetevents-" + it.name)
|
||||||
|
dependencyNode.appendNode("version", it.version)
|
||||||
|
dependencyNode.appendNode("scope", "compile")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact(tasks["sourcesJar"])
|
||||||
|
} else {
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
|
||||||
|
pom {
|
||||||
|
name = "${rootProject.name}-${project.name}"
|
||||||
|
description = rootProject.description
|
||||||
|
url = "https://github.com/Tofaa2/EntityLib"
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name = "GPL-3.0"
|
||||||
|
url = "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// So that SNAPSHOT is always the latest SNAPSHOT
|
// So that SNAPSHOT is always the latest SNAPSHOT
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
|
resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
|
||||||
|
|
13
jitpack.yml
13
jitpack.yml
|
@ -1,2 +1,15 @@
|
||||||
jdk:
|
jdk:
|
||||||
- temurin-21
|
- temurin-21
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- name: build
|
||||||
|
- name: publish
|
||||||
|
depends_on: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
script:
|
||||||
|
- ./gradlew build
|
||||||
|
|
||||||
|
publish:
|
||||||
|
script:
|
||||||
|
- ./gradlew publishToMavenLocal
|
Loading…
Reference in a new issue