Multiverse-Core/build.gradle

350 lines
10 KiB
Groovy
Raw Normal View History

2023-02-02 23:07:51 +01:00
import org.apache.tools.ant.filters.ReplaceTokens
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2023-02-02 23:07:51 +01:00
plugins {
id 'java-library'
id 'maven-publish'
id 'com.gradleup.shadow' version '8.3.5'
id "org.jetbrains.kotlin.jvm" version "2.0.21"
2023-02-02 23:07:51 +01:00
}
2023-02-20 06:04:43 +01:00
version = System.getenv('GITHUB_VERSION') ?: 'local'
2024-09-14 10:28:10 +02:00
group = 'org.mvplugins.multiverse.core'
2023-02-02 23:07:51 +01:00
description = 'Multiverse-Core'
compileJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
compileTestKotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
javaParameters.set(true)
2023-03-02 08:07:38 +01:00
}
}
2023-02-02 23:07:51 +01:00
repositories {
mavenLocal()
mavenCentral()
2023-02-02 23:07:51 +01:00
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
maven {
url = uri('https://repo.onarandombox.com/content/groups/public')
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/groups/public/')
}
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.minebench.de/')
}
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
2023-02-20 13:29:08 +01:00
maven {
name = 'aikar repo'
url = uri('https://repo.aikar.co/content/groups/aikar/')
}
maven {
name = 'glaremasters repo'
url = 'https://repo.glaremasters.me/repository/towny/'
}
2023-09-06 17:19:24 +02:00
maven {
2024-09-15 03:43:41 +02:00
name = "helpchatRepoReleases"
url = uri("https://repo.helpch.at/releases/")
}
2023-09-06 17:19:24 +02:00
maven {
name = 'papermc repo'
url = 'https://repo.papermc.io/repository/maven-public/'
}
2023-02-02 23:07:51 +01:00
}
2023-03-02 07:20:38 +01:00
configurations {
2023-08-28 21:33:41 +02:00
// Add configuration for server API
compileOnly.extendsFrom serverApi
runtimeClasspath.extendsFrom serverApi
// Add configuration for external plugins
implementation.extendsFrom externalPlugin
// Add configuration for dependencies that will be included in fat jar
compileClasspath.extendsFrom shadowed
testCompileClasspath.extendsFrom shadowed
testRuntimeClasspath.extendsFrom shadowed
oldTestCompileClasspath.extendsFrom shadowed
oldTestRuntimeClasspath.extendsFrom shadowed
// Add configuration for old tests
2023-03-02 07:20:38 +01:00
oldTestImplementation.extendsFrom implementation
oldTestRuntime.extendsFrom runtime
2023-02-02 23:07:51 +01:00
}
dependencies {
2023-09-07 04:21:21 +02:00
serverApi 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
2023-02-02 23:07:51 +01:00
2023-02-20 13:29:08 +01:00
// Economy
2023-08-28 21:33:41 +02:00
externalPlugin('com.github.MilkBowl:VaultAPI:1.7.1') {
2023-02-02 23:07:51 +01:00
exclude group: 'org.bukkit', module: 'bukkit'
}
// PlaceholderAPI
2024-09-15 03:43:41 +02:00
externalPlugin 'me.clip:placeholderapi:2.11.6'
2023-02-20 13:29:08 +01:00
// Command Framework
2023-08-28 21:33:41 +02:00
shadowed 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
2023-02-20 13:29:08 +01:00
// Config
shadowed('io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.1') {
2023-02-20 13:29:08 +01:00
exclude group: 'org.spigotmc', module: 'spigot-api'
2023-02-02 23:07:51 +01:00
}
2023-02-20 13:29:08 +01:00
// Utils
2023-08-28 21:33:41 +02:00
shadowed 'io.vavr:vavr:0.10.4'
shadowed 'org.glassfish.hk2:hk2-locator:3.0.3'
shadowed('org.glassfish.hk2:hk2-inhabitant-generator:3.0.3') {
exclude group: 'org.apache.maven', module: 'maven-core'
}
2023-08-28 21:33:41 +02:00
shadowed('com.dumptruckman.minecraft:Logging:1.1.1') {
2023-02-02 23:07:51 +01:00
exclude group: 'junit', module: 'junit'
}
2023-08-28 21:33:41 +02:00
shadowed 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
shadowed('org.bstats:bstats-bukkit:3.1.0') {
exclude group: 'org.bukkit', module: 'bukkit'
}
2023-09-07 04:21:21 +02:00
shadowed 'net.minidev:json-smart:2.4.9'
2023-08-28 21:33:41 +02:00
shadowed 'org.jetbrains:annotations:22.0.0'
shadowed 'io.papermc:paperlib:1.0.8'
2023-02-02 23:07:51 +01:00
2023-02-20 13:29:08 +01:00
// Tests
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21'
2024-11-16 10:03:11 +01:00
testImplementation 'org.mockbukkit.mockbukkit:mockbukkit-v1.21:4.3.1'
2023-03-02 06:44:32 +01:00
testImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
2023-03-02 08:10:36 +01:00
testImplementation 'org.jetbrains.kotlin:kotlin-test'
2023-03-12 22:04:38 +01:00
testImplementation 'com.natpryce:hamkrest:1.8.0.1'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.1.0'
2023-03-02 07:20:38 +01:00
// Old Tests
2023-09-07 04:21:21 +02:00
oldTestImplementation 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
2023-03-02 07:20:38 +01:00
oldTestImplementation('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit', module: 'junit'
}
oldTestImplementation 'junit:junit:4.13.1'
oldTestImplementation 'org.mockito:mockito-core:3.11.2'
oldTestImplementation 'commons-io:commons-io:2.7'
2023-03-06 05:00:28 +01:00
// Annotation Processors
annotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
2023-03-12 22:30:46 +01:00
testAnnotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.0.3'
2023-02-02 23:07:51 +01:00
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaCompile).configureEach {
2023-02-02 23:07:51 +01:00
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc).configureEach {
2023-02-02 23:07:51 +01:00
options.encoding = 'UTF-8'
}
2023-02-20 00:58:13 +01:00
configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(shadowJar)
}
}
2023-03-02 07:20:38 +01:00
sourceSets {
oldTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/old-test/java')
}
resources.srcDir file('src/old-test/resources')
}
}
2023-02-02 23:07:51 +01:00
publishing {
publications {
maven(MavenPublication) {
2023-02-20 00:58:13 +01:00
from components.java
pom.withXml {
2023-08-28 21:33:41 +02:00
Node pomNode = asNode()
// Remove Kotlin dependency
pomNode.dependencies.'*'.findAll() {
it.groupId.text() == 'org.jetbrains.kotlin'
}.each() {
it.parent().remove(it)
}
// Switch runtime deps to provided
pomNode.dependencies.'*'.findAll() {
it.scope.text() == 'runtime'
}.each() {
it.scope*.value = 'provided'
}
2023-08-28 21:33:41 +02:00
// Add spigot api to pom
project.configurations.serverApi.allDependencies.each { dependency ->
pomNode.dependencies[0].appendNode("dependency").with {
it.appendNode("groupId", dependency.group)
it.appendNode("artifactId", dependency.name)
it.appendNode("version", dependency.version)
it.appendNode("scope", "provided")
}
}
}
2023-02-20 00:58:13 +01:00
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Core"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
2023-02-02 23:07:51 +01:00
}
}
2024-11-16 05:19:53 +01:00
maven {
name = "multiverse"
def releasesRepoUrl = "https://repo.dumptruckman.com/multiverse-releases"
def snapshotsRepoUrl = "https://repo.dumptruckman.com/multiverse-snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
2024-11-16 05:19:53 +01:00
credentials(PasswordCredentials)
}
2024-11-23 11:06:53 +01:00
maven {
// todo: remove before mv5 release
name = "multiverseBeta"
url = "https://repo.c0ding.party/multiverse-beta"
credentials(PasswordCredentials)
}
2023-02-02 23:07:51 +01:00
}
}
ext.bitlyAccessToken = System.getenv('BITLY_ACCESS_TOKEN') ?: 'bitly-access-token'
task prepareSource(type: Sync) {
inputs.property 'bitlyAccessToken', bitlyAccessToken
from sourceSets.main.java
into "$buildDir/src"
filter(ReplaceTokens, tokens: [
'bitly-access-token': bitlyAccessToken,
])
}
compileJava {
source = prepareSource.outputs
}
2023-03-12 22:30:46 +01:00
tasks.withType(JavaCompile) {
configure(options) {
options.compilerArgs << '-Aorg.glassfish.hk2.metadata.location=META-INF/hk2-locator/Multiverse-Core'
}
2023-02-02 23:07:51 +01:00
}
2023-03-02 08:07:38 +01:00
compileKotlin {
// We're not using Kotlin in the plugin itself, just tests!
enabled = false
}
configurations.findAll { !it.name.startsWith('test') }.each {
it.exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
2023-03-02 08:07:38 +01:00
}
2023-02-02 23:07:51 +01:00
processResources {
2023-02-20 00:58:13 +01:00
def props = [version: "${project.version}"]
2023-02-02 23:07:51 +01:00
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
// This task should never be skipped. The tests depend on this having been run but we want the new version number
// that is created after tests are run and before we run again to publish.
outputs.upToDateWhen { false }
2023-02-02 23:07:51 +01:00
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
}
project.configurations.api.canBeResolved = true
shadowJar {
relocate 'co.aikar', 'org.mvplugins.multiverse.external.acf'
relocate 'com.dumptruckman.minecraft.util.Logging', 'org.mvplugins.multiverse.core.utils.CoreLogging'
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'org.mvplugins.multiverse.core.utils.DebugFileLogger'
relocate 'de.themoep.idconverter', 'org.mvplugins.multiverse.external.idconverter'
relocate 'io.github.townyadvanced.commentedconfiguration', 'org.mvplugins.multiverse.external.commentedconfiguration'
relocate 'me.main__.util', 'org.mvplugins.multiverse.external.serializationconfig'
relocate 'org.bstats', 'org.mvplugins.multiverse.external.bstats'
relocate 'com.sun', 'org.mvplugins.multiverse.external.sun'
relocate 'net.minidev', 'org.mvplugins.multiverse.external.minidev'
relocate 'org.objectweb', 'org.mvplugins.multiverse.external.objectweb'
relocate 'io.vavr', 'org.mvplugins.multiverse.external.vavr'
relocate 'jakarta', 'org.mvplugins.multiverse.external.jakarta'
relocate 'javassist', 'org.mvplugins.multiverse.external.javassist'
relocate 'org.aopalliance', 'org.mvplugins.multiverse.external.aopalliance'
relocate 'org.glassfish', 'org.mvplugins.multiverse.external.glassfish'
relocate 'org.jvnet', 'org.mvplugins.multiverse.external.jvnet'
relocate 'org.intellij', 'org.mvplugins.multiverse.external.intellij'
relocate 'org.jetbrains', 'org.mvplugins.multiverse.external.jetbrains'
relocate 'io.papermc.lib', 'org.mvplugins.multiverse.external.paperlib'
2023-08-24 19:28:02 +02:00
configurations = [project.configurations.shadowed]
2023-02-02 23:07:51 +01:00
archiveClassifier.set('')
2023-03-02 08:07:38 +01:00
dependencies {
exclude(dependency {
it.moduleGroup == 'org.jetbrains.kotlin'
})
}
2023-08-28 21:33:41 +02:00
//classifier = ''
2023-02-02 23:07:51 +01:00
}
build.dependsOn shadowJar
jar.enabled = false
2023-02-20 13:29:08 +01:00
test {
2023-03-02 08:10:36 +01:00
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
2023-02-20 13:29:08 +01:00
}