From e6f4e4f997172178f7a9004fdc5ac1e321292e12 Mon Sep 17 00:00:00 2001 From: William Date: Mon, 29 Aug 2022 15:39:30 +0100 Subject: [PATCH] Add JitPack integration and maven publishing --- .scripts/ensure-java-16 | 19 +++++++++++ build.gradle | 34 +++++++++++++++++-- .../huskhomes/api/HuskHomesAPI.java | 5 +-- jitpack.yml | 12 +++++++ 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100755 .scripts/ensure-java-16 create mode 100644 jitpack.yml diff --git a/.scripts/ensure-java-16 b/.scripts/ensure-java-16 new file mode 100755 index 00000000..9bb37ccc --- /dev/null +++ b/.scripts/ensure-java-16 @@ -0,0 +1,19 @@ +#!/bin/bash + +JV=$(java -version 2>&1 >/dev/null | head -1) +echo "$JV" | sed -E 's/^.*version "([^".]*)\.[^"]*".*$/\1/' + +if [ "$JV" != 16 ]; then + case "$1" in + install) + echo "installing sdkman..." + curl -s "https://get.sdkman.io" | bash + source ~/.sdkman/bin/sdkman-init.sh + sdk install java 16.0.1-open + ;; + use) + echo "must source ~/.sdkman/bin/sdkman-init.sh" + exit 1 + ;; + esac +fi \ No newline at end of file diff --git a/build.gradle b/build.gradle index af4892ba..7bc2a2b9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.ajoberstar.grgit' version '5.0.0' id 'java' + id 'maven-publish' } group 'net.william278' @@ -22,9 +23,9 @@ allprojects { apply plugin: 'java' compileJava.options.encoding = 'UTF-8' - javadoc.options.encoding = 'UTF-8' - compileJava.options.release.set 16 + javadoc.options.encoding = 'UTF-8' + javadoc.options.addStringOption('Xdoclint:none', '-quiet') repositories { mavenLocal() @@ -65,6 +66,35 @@ subprojects { destinationDirectory.set(file("$rootDir/target")) archiveClassifier.set('') } + + // API publishing + if ('bukkit'.contains(project.name)) { + java { + withSourcesJar() + withJavadocJar() + } + sourcesJar { + destinationDirectory.set(file("$rootDir/target")) + } + javadocJar { + destinationDirectory.set(file("$rootDir/target")) + } + shadowJar.dependsOn(sourcesJar, javadocJar) + + publishing { + publications { + mavenJava(MavenPublication) { + groupId = 'net.william278' + artifactId = 'huskhomes' + version = "$rootProject.version" + artifact shadowJar + artifact javadocJar + artifact sourcesJar + } + } + } + } + jar.dependsOn shadowJar clean.delete "$rootDir/target" } diff --git a/bukkit/src/main/java/net/william278/huskhomes/api/HuskHomesAPI.java b/bukkit/src/main/java/net/william278/huskhomes/api/HuskHomesAPI.java index c4762c36..1040c550 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/api/HuskHomesAPI.java +++ b/bukkit/src/main/java/net/william278/huskhomes/api/HuskHomesAPI.java @@ -16,8 +16,8 @@ import java.util.Objects; /** * The HuskHomes API implementation for the Bukkit platform, providing methods to access player data, homes, warps - * & process teleports - *

+ * and process teleports + *

* Retrieve an instance of the API class via {@link #getInstance()}. */ @SuppressWarnings("unused") @@ -97,6 +97,7 @@ public class HuskHomesAPI extends BaseHuskHomesAPI { * * @param location the bukkit location to get the {@link Position} instance for * @param server the {@link Server} the position is on + * @return the {@link Position} instance for the given bukkit {@link Location} on the given {@link Server} * @see Position#server * @since 3.0 */ diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 00000000..8b19a311 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,12 @@ +# This file ensures jitpack builds HuskSync correctly by setting the JDK to 16 +jdk: + - 'openjdk16' +before_install: + - 'git clone https://github.com/WiIIiam278/HuskHomes2.git --recurse-submodules' + - 'chmod +x gradlew' + - 'chmod +x ./.scripts/ensure-java-16' + - 'bash ./.scripts/ensure-java-16 install' +install: + - 'if ! ./.scripts/ensure-java-16 use; then source ~/.sdkman/bin/sdkman-init.sh; fi' + - 'java -version' + - './gradlew publishToMavenLocal' \ No newline at end of file