Standardize publishing (releases on plugin portal, snapshots on paper repo), combine -lib sources into plugin source jars.
This commit is contained in:
parent
307fc2e606
commit
6b158a2b7a
147 changed files with 103 additions and 119 deletions
6
.github/workflows/deploy.yml
vendored
6
.github/workflows/deploy.yml
vendored
|
@ -16,7 +16,7 @@ jobs:
|
|||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Deploy release
|
||||
run: ./gradlew -Dorg.gradle.parallel=true publish --no-daemon --stacktrace
|
||||
run: ./gradlew publishPlugins --no-daemon --stacktrace
|
||||
env:
|
||||
ORG_GRADLE_PROJECT_paperUsername: ${{ secrets.DEPLOY_USER }}
|
||||
ORG_GRADLE_PROJECT_paperPassword: ${{ secrets.DEPLOY_PASS }}
|
||||
GRADLE_PUBLISH_KEY: "${{ secrets.GRADLE_PLUGIN_PORTAL_KEY }}"
|
||||
GRADLE_PUBLISH_SECRET: "${{ secrets.GRADLE_PLUGIN_PORTAL_SECRET }}"
|
||||
|
|
|
@ -14,6 +14,7 @@ dependencies {
|
|||
implementation(libs.gradle.shadow)
|
||||
implementation(libs.gradle.kotlin.dsl)
|
||||
implementation(libs.gradle.plugin.kotlin.withVersion(embeddedKotlinVersion))
|
||||
implementation(libs.gradle.plugin.publish)
|
||||
}
|
||||
|
||||
fun Provider<MinimalExternalModuleDependency>.withVersion(version: String): Provider<String> {
|
||||
|
|
|
@ -7,11 +7,13 @@ plugins {
|
|||
id("org.jlleitschuh.gradle.ktlint")
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
(this as JavaToolchainSpec).apply {
|
||||
languageVersion.set(JavaLanguageVersion.of(11))
|
||||
}
|
||||
languageVersion.set(JavaLanguageVersion.of(11))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,10 +49,6 @@ dependencies {
|
|||
compileOnly(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
isAutomatedPublishing = false
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
`maven-publish`
|
||||
id("org.jetbrains.kotlin.jvm")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("com.gradle.plugin-publish")
|
||||
}
|
||||
|
||||
fun version(): String = version.toString()
|
||||
val noRelocate = project.hasProperty("disable-relocation")
|
||||
if (noRelocate) {
|
||||
if (version().contains("-SNAPSHOT")) {
|
||||
version = version().substringBefore("-SNAPSHOT") + "-NO-RELOCATE-SNAPSHOT"
|
||||
} else {
|
||||
version = version() + "-NO-RELOCATE"
|
||||
}
|
||||
}
|
||||
|
||||
val shade: Configuration by configurations.creating
|
||||
|
@ -23,11 +33,37 @@ fun ShadowJar.configureStandard() {
|
|||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
val kotlinSourcesJar by tasks.existing
|
||||
val sourcesJar by tasks.existing(AbstractArchiveTask::class) {
|
||||
from(
|
||||
zipTree(project(":paperweight-lib").tasks
|
||||
.named("sourcesJar", AbstractArchiveTask::class)
|
||||
.flatMap { it.archiveFile })
|
||||
) {
|
||||
exclude("META-INF/**")
|
||||
}
|
||||
}
|
||||
|
||||
val prefix = project.name.substringAfter("paperweight-")
|
||||
|
||||
gradlePlugin {
|
||||
website.set("https://github.com/PaperMC/paperweight")
|
||||
vcsUrl.set("https://github.com/PaperMC/paperweight")
|
||||
plugins.create("paperweight-$prefix") {
|
||||
id = "io.papermc.paperweight." + prefix
|
||||
displayName = "paperweight $prefix"
|
||||
description = "paperweight $prefix"
|
||||
tags.set(listOf("paper", "minecraft"))
|
||||
}
|
||||
}
|
||||
|
||||
val shadowJar by tasks.existing(ShadowJar::class) {
|
||||
archiveClassifier.set(null as String?)
|
||||
configureStandard()
|
||||
|
||||
if (noRelocate) {
|
||||
return@existing
|
||||
}
|
||||
|
||||
val prefix = "paper.libs"
|
||||
listOf(
|
||||
"com.github.salomonbrys.kotson",
|
||||
|
@ -55,88 +91,20 @@ val shadowJar by tasks.existing(ShadowJar::class) {
|
|||
}
|
||||
}
|
||||
|
||||
val devShadowJar by tasks.registering(ShadowJar::class) {
|
||||
configureStandard()
|
||||
|
||||
from(project.sourceSets.main.get().output)
|
||||
|
||||
archiveClassifier.set("dev")
|
||||
}
|
||||
|
||||
val isSnapshot = version().endsWith("-SNAPSHOT")
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven("https://repo.papermc.io/repository/maven-snapshots/") {
|
||||
credentials(PasswordCredentials::class)
|
||||
name = "paper"
|
||||
}
|
||||
}
|
||||
|
||||
publications {
|
||||
register<MavenPublication>("shadow") {
|
||||
pluginConfig(version())
|
||||
artifact(shadowJar) {
|
||||
classifier = null
|
||||
withType(MavenPublication::class).configureEach {
|
||||
pom {
|
||||
pomConfig()
|
||||
}
|
||||
}
|
||||
register<MavenPublication>("maven") {
|
||||
standardConfig(version())
|
||||
}
|
||||
register<MavenPublication>("shadowLocal") {
|
||||
pluginConfig(localVersion())
|
||||
artifact(devShadowJar) {
|
||||
classifier = null
|
||||
}
|
||||
}
|
||||
register<MavenPublication>("mavenLocal") {
|
||||
standardConfig(localVersion())
|
||||
}
|
||||
|
||||
repositories {
|
||||
val url = if (isSnapshot) {
|
||||
"https://repo.papermc.io/repository/maven-snapshots/"
|
||||
} else {
|
||||
"https://repo.papermc.io/repository/maven-releases/"
|
||||
}
|
||||
maven(url) {
|
||||
credentials(PasswordCredentials::class)
|
||||
name = "paper"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(PublishToMavenRepository::class).configureEach {
|
||||
onlyIf {
|
||||
!publication.name.endsWith("Local")
|
||||
}
|
||||
}
|
||||
tasks.withType(PublishToMavenLocal::class).configureEach {
|
||||
onlyIf {
|
||||
publication.name.endsWith("Local")
|
||||
}
|
||||
}
|
||||
|
||||
fun MavenPublication.standardConfig(versionName: String) {
|
||||
groupId = project.group.toString()
|
||||
artifactId = project.name
|
||||
version = versionName
|
||||
|
||||
from(components["java"])
|
||||
artifact(devShadowJar)
|
||||
|
||||
withoutBuildIdentifier()
|
||||
pom {
|
||||
pomConfig()
|
||||
}
|
||||
}
|
||||
|
||||
fun MavenPublication.pluginConfig(versionName: String) {
|
||||
val baseName = project.group.toString() + "." + project.name.substringAfter('-')
|
||||
|
||||
groupId = baseName
|
||||
artifactId = "$baseName.gradle.plugin"
|
||||
version = versionName
|
||||
|
||||
artifact(kotlinSourcesJar)
|
||||
|
||||
withoutBuildIdentifier()
|
||||
pom {
|
||||
pomConfig()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +116,6 @@ fun MavenPom.pomConfig() {
|
|||
description.set("Gradle plugin for the PaperMC project")
|
||||
url.set(repoUrl)
|
||||
inceptionYear.set("2020")
|
||||
packaging = "jar"
|
||||
|
||||
licenses {
|
||||
license {
|
||||
|
@ -178,15 +145,3 @@ fun MavenPom.pomConfig() {
|
|||
developerConnection.set("scm:git:git@github.com:$repoPath.git")
|
||||
}
|
||||
}
|
||||
|
||||
fun version(): String {
|
||||
return project.version.toString()
|
||||
}
|
||||
|
||||
fun localVersion(): String {
|
||||
return if (isSnapshot) {
|
||||
version().substringBefore('-') + "-LOCAL-SNAPSHOT"
|
||||
} else {
|
||||
version() + "-LOCAL"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,10 @@ jbsdiff = "io.sigpipe:jbsdiff:1.0"
|
|||
# Gradle
|
||||
gradle-licenser = "org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin:0.6.1"
|
||||
gradle-shadow = "com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:7.1.2"
|
||||
gradle-ktlint = "org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin:10.2.1"
|
||||
gradle-kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.1.7"
|
||||
gradle-ktlint = "org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin:11.1.0"
|
||||
gradle-kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.4.1"
|
||||
gradle-plugin-kotlin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin" }
|
||||
gradle-plugin-publish = "com.gradle.publish:plugin-publish-plugin:1.1.0"
|
||||
|
||||
[bundles]
|
||||
asm = ["asm-core", "asm-tree"]
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
18
gradlew
vendored
18
gradlew
vendored
|
@ -55,7 +55,7 @@
|
|||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
@ -80,10 +80,10 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
@ -143,12 +143,16 @@ fi
|
|||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -205,6 +209,12 @@ set -- \
|
|||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
|
@ -14,7 +14,7 @@
|
|||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
|
@ -25,7 +25,8 @@
|
|||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -8,3 +8,9 @@ dependencies {
|
|||
|
||||
implementation(libs.kotson)
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins.all {
|
||||
implementationClass = "io.papermc.paperweight.core.PaperweightCore"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
implementation-class=io.papermc.paperweight.core.PaperweightCore
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue