|
| 1 | +import io.papermc.paperweight.util.path |
| 2 | + |
| 3 | +plugins { |
| 4 | + `java-library` |
| 5 | + `maven-publish` |
| 6 | + id("io.papermc.paperweight.userdev") version "1.5.11" |
| 7 | + id("xyz.jpenilla.run-paper") version "2.2.3" // Adds runServer and runMojangMappedServer tasks for testing |
| 8 | +} |
| 9 | + |
| 10 | +// = = = |
| 11 | + |
| 12 | +val pluginName = "NyaaCore" |
| 13 | +val majorVersion = 9 |
| 14 | +val minorVersion = 3 |
| 15 | + |
| 16 | +val paperApiName = "1.20.4-R0.1-SNAPSHOT" |
| 17 | + |
| 18 | +// = = = |
| 19 | + |
| 20 | +// for Jenkins CI |
| 21 | +val buildNumber = System.getenv("BUILD_NUMBER") ?: "local" |
| 22 | +val mavenDirectory = |
| 23 | + System.getenv("MAVEN_DIR") |
| 24 | + ?: layout.buildDirectory.dir("repo").path.toString() |
| 25 | +val javaDocDirectory = |
| 26 | + System.getenv("JAVADOC_DIR") |
| 27 | + ?: layout.buildDirectory.dir("javadoc").path.toString() |
| 28 | + |
| 29 | +// Version used for distribution. Different from maven repo |
| 30 | +group = "cat.nyaa" |
| 31 | +//archivesBaseName = "${pluginNameUpper}-mc$minecraftVersion" |
| 32 | +version = |
| 33 | + "$majorVersion.$minorVersion-${getMcVersion(paperApiName)}-b$buildNumber" |
| 34 | + |
| 35 | +java { |
| 36 | + // Configure the java toolchain. This allows gradle to auto-provision JDK 17 on systems that only have JDK 8 installed for example. |
| 37 | + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) |
| 38 | +} |
| 39 | + |
| 40 | +repositories { |
| 41 | + mavenCentral() |
| 42 | + maven { |
| 43 | + url = uri("https://papermc.io/repo/repository/maven-public/") |
| 44 | + } //paper |
| 45 | + maven { url = uri("https://libraries.minecraft.net") } // mojang |
| 46 | + maven { url = uri("https://repo.essentialsx.net/releases/") } // essentials |
| 47 | + maven { url = uri("https://ci.nyaacat.com/maven/") } // nyaacat |
| 48 | + |
| 49 | +} |
| 50 | + |
| 51 | +dependencies { |
| 52 | + paperweightDevelopmentBundle(paperweight.paperDevBundle(paperApiName)) |
| 53 | + // paperweight.foliaDevBundle("1.20.4-R0.1-SNAPSHOT") |
| 54 | + // paperweight.devBundle("com.example.paperfork", "1.20.4-R0.1-SNAPSHOT") |
| 55 | + compileOnly("net.essentialsx:EssentialsX:2.19.6") // soft dep |
| 56 | + compileOnly("org.jetbrains:annotations:23.0.0") |
| 57 | + // Testing |
| 58 | + testImplementation(platform("org.junit:junit-bom:5.9.0")) |
| 59 | + testImplementation("org.junit.jupiter:junit-jupiter") |
| 60 | + testImplementation("com.github.seeseemelk:MockBukkit-v1.19:2.132.3") |
| 61 | + testImplementation("org.mockito:mockito-core:4.8.0") |
| 62 | + testImplementation("org.mockito:mockito-junit-jupiter:4.8.0") |
| 63 | + testImplementation("org.xerial:sqlite-jdbc:3.39.3.0") |
| 64 | + testImplementation("ch.vorburger.mariaDB4j:mariaDB4j:2.6.0") |
| 65 | +} |
| 66 | + |
| 67 | +publishing { |
| 68 | + publications { |
| 69 | + create<MavenPublication>("mavenJava") { |
| 70 | + from(getComponents()["java"]) |
| 71 | + afterEvaluate { |
| 72 | + artifactId = pluginName |
| 73 | + groupId = "$group" |
| 74 | + version = |
| 75 | + "$majorVersion.$minorVersion.$buildNumber-${ |
| 76 | + getMcVersion( |
| 77 | + paperApiName |
| 78 | + ) |
| 79 | + }" |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + repositories { |
| 84 | + maven { |
| 85 | + name = "nyaaMaven" |
| 86 | + url = uri(mavenDirectory) |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +/* |
| 92 | +reobfJar { |
| 93 | + // This is an example of how you might change the output location for reobfJar. It's recommended not to do this |
| 94 | + // for a variety of reasons, however it's asked frequently enough that an example of how to do it is included here. |
| 95 | + outputJar.set(layout.buildDirectory.file("libs/PaperweightTestPlugin-${project.version}.jar")) |
| 96 | +} |
| 97 | +*/ |
| 98 | + |
| 99 | + |
| 100 | +tasks { |
| 101 | + // Configure reobfJar to run when invoking the build task |
| 102 | + assemble { |
| 103 | + dependsOn(reobfJar) |
| 104 | + } |
| 105 | + |
| 106 | + |
| 107 | + compileJava { |
| 108 | + options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything |
| 109 | + |
| 110 | + // Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable. |
| 111 | + // See https://openjdk.java.net/jeps/247 for more information. |
| 112 | + options.release.set(17) |
| 113 | + } |
| 114 | + javadoc { |
| 115 | + with((options as StandardJavadocDocletOptions)) { |
| 116 | + options.encoding = |
| 117 | + Charsets.UTF_8.name() // We want UTF-8 for everything |
| 118 | + links("https://docs.oracle.com/en/java/javase/17/docs/api/") |
| 119 | + links("https://guava.dev/releases/21.0/api/docs/") |
| 120 | + links("https://ci.md-5.net/job/BungeeCord/ws/chat/target/apidocs/") |
| 121 | + links("https://jd.papermc.io/paper/1.20/") |
| 122 | + options.locale = "en_US" |
| 123 | + options.encoding = "UTF-8" |
| 124 | + (options as StandardJavadocDocletOptions).addBooleanOption( |
| 125 | + "keywords", |
| 126 | + true |
| 127 | + ) |
| 128 | + (options as StandardJavadocDocletOptions).addStringOption( |
| 129 | + "Xdoclint:none", |
| 130 | + "-quiet" |
| 131 | + ) |
| 132 | + (options as StandardJavadocDocletOptions).addBooleanOption( |
| 133 | + "html5", |
| 134 | + true |
| 135 | + ) |
| 136 | + options.windowTitle = "$pluginName Javadoc" |
| 137 | + } |
| 138 | + |
| 139 | + |
| 140 | + } |
| 141 | + |
| 142 | +} |
| 143 | + |
| 144 | +private fun getMcVersion(apiNameString: String): String { |
| 145 | + return apiNameString.split('-')[0] |
| 146 | +} |
0 commit comments