1+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13plugins {
24 id ' java-library'
35 id ' maven-publish'
46 id ' checkstyle'
57 id ' com.gradleup.shadow' version ' 8.3.5'
8+ id " org.jetbrains.kotlin.jvm" version " 2.0.21"
69}
710
811version = System . getenv(' GITHUB_VERSION' ) ?: ' local'
@@ -14,11 +17,23 @@ compileJava {
1417 targetCompatibility = JavaVersion . VERSION_17
1518}
1619
17- // todo: Enable test when convert them to use mockbukkit like mv-core
18- compileTestJava {
20+ compileKotlin {
21+ // We're not using Kotlin in the plugin itself, just tests!
1922 enabled = false
2023}
2124
25+ compileTestJava {
26+ sourceCompatibility = JavaVersion . VERSION_21
27+ targetCompatibility = JavaVersion . VERSION_21
28+ }
29+
30+ compileTestKotlin {
31+ compilerOptions {
32+ jvmTarget. set(JvmTarget . JVM_21 )
33+ javaParameters. set(true )
34+ }
35+ }
36+
2237repositories {
2338 mavenLocal()
2439 mavenCentral()
@@ -55,14 +70,15 @@ repositories {
5570
5671dependencies {
5772 // Spigot
58- implementation (' org.spigotmc:spigot-api:1.21.4 -R0.1-SNAPSHOT' ) {
73+ compileOnly (' org.spigotmc:spigot-api:1.21.3 -R0.1-SNAPSHOT' ) {
5974 exclude group : ' junit' , module : ' junit'
6075 }
6176
6277 // Core
6378 // TODO update to correct version once we have it published
6479 implementation ' org.mvplugins.multiverse.core:multiverse-core:5.0.0-SNAPSHOT'
6580
81+
6682 // Config
6783 api ' com.dumptruckman.minecraft:JsonConfiguration:1.2-SNAPSHOT'
6884 api ' net.minidev:json-smart:2.5.1'
@@ -82,9 +98,18 @@ dependencies {
8298 }
8399
84100 // Tests
85- testImplementation ' com.github.MilkBowl:VaultAPI:1.7.1'
86- testImplementation ' junit:junit:4.13.2'
87- testImplementation ' org.mockito:mockito-core:3.11.2'
101+ testImplementation ' org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21'
102+ testImplementation ' org.mockbukkit.mockbukkit:mockbukkit-v1.21:4.24.1'
103+ testImplementation ' org.jetbrains.kotlin:kotlin-test'
104+ testImplementation ' com.natpryce:hamkrest:1.8.0.1'
105+ testImplementation ' org.mockito.kotlin:mockito-kotlin:4.1.0'
106+
107+ // hk2 for annotation processing only
108+ compileOnly(' org.glassfish.hk2:hk2-api:3.0.3' ) {
109+ exclude group : ' *' , module : ' *'
110+ }
111+ annotationProcessor ' org.glassfish.hk2:hk2-metadata-generator:3.0.3'
112+ testAnnotationProcessor ' org.glassfish.hk2:hk2-metadata-generator:3.0.3'
88113}
89114
90115
@@ -97,37 +122,27 @@ tasks.withType(JavaCompile).configureEach {
97122 options. encoding = ' UTF-8'
98123}
99124
125+ tasks. withType(JavaCompile ) {
126+ configure(options) {
127+ options. compilerArgs << ' -Aorg.glassfish.hk2.metadata.location=META-INF/hk2-locator/Multiverse-Inventories'
128+ }
129+ }
130+
100131tasks. withType(Javadoc ). configureEach {
101132 options. encoding = ' UTF-8'
102133}
103134
104-
105135configurations {
106136 [apiElements, runtimeElements]. each {
107137 it. outgoing. artifacts. removeIf { it. buildDependencies. getDependencies(null ). contains(jar) }
108138 it. outgoing. artifact(shadowJar)
109139 }
110140}
111141
112- publishing {
113- publications {
114- maven(MavenPublication ) {
115- from components. java
116- }
117- }
118- repositories {
119- maven {
120- name = " GitHubPackages"
121- url = " https://maven.pkg.github.com/Multiverse/Multiverse-Inventories"
122- credentials {
123- username = System . getenv(" GITHUB_ACTOR" )
124- password = System . getenv(" GITHUB_TOKEN" )
125- }
126- }
127- }
142+ configurations. findAll { ! it. name. startsWith(' test' ) }. each {
143+ it. exclude group : ' org.jetbrains.kotlin' , module : ' kotlin-stdlib-jdk8'
128144}
129145
130-
131146processResources {
132147 def props = [version : " ${ project.version} " ]
133148 inputs. properties props
@@ -141,44 +156,60 @@ processResources {
141156 outputs. upToDateWhen { false }
142157}
143158
144-
145159checkstyle {
146160 toolVersion = ' 6.1.1'
147161 configFile file(' config/mv_checks.xml' )
148162 ignoreFailures = true
149163}
150164
151-
152165javadoc {
153166 source = sourceSets. main. allJava
154167 classpath = configurations. compileClasspath
155168}
156169
157-
158170project. configurations. api. canBeResolved = true
159171
160172shadowJar {
161173 relocate ' com.dumptruckman.minecraft.util.Logging' , ' org.mvplugins.multiverse.inventories.utils.InvLogging'
162174 relocate ' com.dumptruckman.minecraft.util.DebugLog' , ' org.mvplugins.multiverse.inventories.utils.DebugFileLogger'
163175 relocate ' com.dumptruckman.bukkit.configuration' , ' org.mvplugins.multiverse.inventories.utils.configuration'
164176 relocate ' io.papermc.lib' , ' org.mvplugins.multiverse.inventories.utils.paperlib'
165- relocate ' net.minidev.json ' , ' org.mvplugins.multiverse.inventories.utils.json '
177+ relocate ' net.minidev' , ' org.mvplugins.multiverse.inventories.utils.minidev '
166178
167179 configurations = [project. configurations. api]
168180
169181 archiveClassifier. set(' ' )
182+
183+ dependencies {
184+ exclude(dependency {
185+ it. moduleGroup == ' org.jetbrains.kotlin'
186+ })
187+ exclude(dependency {
188+ it. moduleGroup == ' org.jetbrains'
189+ })
190+ exclude(dependency {
191+ it. moduleGroup == ' org.ow2.asm'
192+ })
193+ }
170194}
171195
172196build. dependsOn shadowJar
173197jar. enabled = false
174198
175- tasks. register(' runHabitatGenerator' , JavaExec ) {
176- classpath = configurations[" compileClasspath" ]
177- mainClass. set(' org.mvplugins.multiverse.external.jvnet.hk2.generator.HabitatGenerator' )
178-
179- args = [
180- ' --file' , " build/libs/multiverse-inventories-$version " + " .jar" ,
181- ' --locator' , ' Multiverse-Inventories' ,
182- ]
199+ publishing {
200+ publications {
201+ maven(MavenPublication ) {
202+ from components. java
203+ }
204+ }
205+ repositories {
206+ maven {
207+ name = " GitHubPackages"
208+ url = " https://maven.pkg.github.com/Multiverse/Multiverse-Inventories"
209+ credentials {
210+ username = System . getenv(" GITHUB_ACTOR" )
211+ password = System . getenv(" GITHUB_TOKEN" )
212+ }
213+ }
214+ }
183215}
184- tasks. named(" build" ) { finalizedBy(" runHabitatGenerator" ) }
0 commit comments