| plugins { |
| id 'java' |
| id 'com.github.johnrengelman.shadow' version '7.1.0' |
| id 'io.github.shevchik.ManualGradleDependencySupplier' version '3.1' |
| id 'maven-publish' |
| } |
| |
| |
| gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.ALWAYS |
| |
| |
| defaultTasks 'build' |
| |
| |
| group 'protocolsupport' |
| version '1.18-1-dev' |
| |
| |
| import java.nio.file.Path |
| import java.nio.file.Paths |
| import java.nio.file.Files |
| import java.nio.file.StandardCopyOption; |
| |
| import io.github.shevchik.manualgradledependencysupplier.ManualGradleDependencySupplier |
| import io.github.shevchik.manualgradledependencysupplier.DependencySupplier |
| import io.github.shevchik.manualgradledependencysupplier.BuildDependencySupplier |
| import io.github.shevchik.manualgradledependencysupplier.UnpackZipFileDependencySupplier |
| import io.github.shevchik.manualgradledependencysupplier.FilterZipFileDependencySupplier |
| |
| |
| Path projectDirectoryPath = projectDir.toPath().toAbsolutePath() |
| Path projectBuildDirectoryPath = getBuildDir().toPath() |
| |
| |
| Path generatedResourcesDirectoryPath = projectBuildDirectoryPath.resolve('gen') |
| Path generatedResourcesResourcesDirectoryPath = generatedResourcesDirectoryPath.resolve('resources') |
| |
| task setupFolders(type: DefaultTask) {doLast{ |
| Files.createDirectories(generatedResourcesDirectoryPath) |
| Files.createDirectories(generatedResourcesResourcesDirectoryPath) |
| }} |
| |
| |
| sourceCompatibility = JavaVersion.VERSION_17 |
| |
| sourceSets { |
| main { |
| java { |
| srcDirs = ['src'] |
| } |
| resources { |
| srcDirs = ['resources'] |
| } |
| } |
| test { |
| java { |
| srcDirs = ['tests'] |
| } |
| } |
| } |
| |
| repositories { |
| mavenCentral() |
| maven { |
| url 'https://oss.sonatype.org/content/repositories/snapshots/' |
| } |
| maven { |
| url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' |
| } |
| maven { |
| url 'https://papermc.io/repo/repository/maven-public/' |
| } |
| maven { |
| url 'https://libraries.minecraft.net/' |
| } |
| maven { |
| url 'https://jitpack.io' |
| } |
| } |
| |
| configurations { |
| spigotLibraries |
| compileOnly { |
| extendsFrom spigotLibraries |
| } |
| testImplementation { |
| extendsFrom spigotLibraries |
| } |
| } |
| |
| dependencies { |
| Path spigotBuildDirectoryPath = projectBuildDirectoryPath.resolve('spigot') |
| |
| DependencySupplier spigotDependencySupplier = new UnpackZipFileDependencySupplier( |
| new BuildDependencySupplier( |
| new URL('https://hub.spigotmc.org/jenkins/job/BuildTools/138/artifact/target/BuildTools.jar'), |
| spigotBuildDirectoryPath, |
| 'BuildTools.jar', |
| ['java', '-jar', 'BuildTools.jar', '--rev', '1.18'], |
| ['spigot-1.18.jar'] |
| ).setBuildEnv([ |
| 'MAVEN_OPTS': '-Dmaven.repo.local=' + spigotBuildDirectoryPath.resolve('m2').toString() + ' -Xmx1024M' |
| ]), |
| 'META-INF/versions/spigot-1.18-R0.1-SNAPSHOT.jar', |
| spigotBuildDirectoryPath, |
| 'spigot-1.18-real.jar' |
| ) |
| |
| compileOnly group: 'com.github.ProtocolSupport', name: 'ProtocolSupportBuildProcessor', version: '907b3e20db' |
| compileOnly group: 'io.papermc.paper', name: 'paper-api', version: '1.18-R0.1-SNAPSHOT' |
| compileOnly ManualGradleDependencySupplier.supplyDependecies([ |
| new FilterZipFileDependencySupplier( |
| spigotDependencySupplier, |
| ['/net/minecraft', '/com/mojang', '/org/bukkit/craftbukkit', '/org/spigotmc'], true, |
| spigotBuildDirectoryPath, |
| 'spigot-1.18-real-filtered-compile.jar' |
| ) |
| ]) |
| compileOnly group: 'io.netty', name: 'netty-all', version: '4.1.70.Final' |
| compileOnly group: 'com.mojang', name: 'authlib', version: '3.2.38' |
| compileOnly group: 'com.mojang', name: 'brigadier', version: '1.0.18' |
| |
| implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11' |
| implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2' |
| |
| annotationProcessor group: 'com.github.ProtocolSupport', name: 'ProtocolSupportBuildProcessor', version: '907b3e20db' |
| |
| testImplementation group: 'org.spigotmc', name: 'spigot-api', version: '1.18-R0.1-SNAPSHOT' |
| testImplementation ManualGradleDependencySupplier.supplyDependecies([ |
| spigotDependencySupplier |
| ]) |
| testImplementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.5.6' |
| testImplementation group: 'io.netty', name: 'netty-all', version: '4.1.70.Final' |
| testImplementation group: 'com.mojang', name: 'authlib', version: '3.2.38' |
| testImplementation group: 'com.mojang', name: 'brigadier', version: '1.0.18' |
| testImplementation group: 'com.mojang', name: 'datafixerupper', version: '4.0.26' |
| testImplementation group: 'com.mojang', name: 'javabridge', version: '1.2.24' |
| testImplementation group: 'org.apache.logging.log4j', name: 'log4j', version: '2.14.1', ext: 'pom' |
| testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1' |
| testImplementation group: 'org.apache.logging.log4j', name: 'log4j-iostreams', version: '2.14.1' |
| testImplementation group: 'net.sf.jopt-simple', name: 'jopt-simple', version: '5.0.4' |
| testImplementation group: 'jline', name: 'jline', version: '2.12.1' |
| testImplementation group: 'com.github.oshi', name: 'oshi-core', version: '5.8.5' |
| testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0' |
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0' |
| } |
| |
| compileJava { |
| options.encoding = 'UTF-8' |
| options.incremental = false |
| options.compilerArgs << ('-Aprotocolsupportbuildprocessor.generatedresourcesdirectory=' + generatedResourcesResourcesDirectoryPath.resolve('preload').toString()) |
| } |
| |
| |
| test { |
| Path workingDirectoryPath = projectDirectoryPath.resolve('testsRun'); |
| |
| doFirst { |
| Files.createDirectories(workingDirectoryPath) |
| } |
| |
| useJUnitPlatform() |
| |
| workingDir = workingDirectoryPath; |
| maxHeapSize = '3G' |
| } |
| |
| |
| processResources { |
| doFirst { |
| Properties properties = new Properties() |
| properties.setProperty('buildtime', new Date().format('yyyy.MM.dd \'at\' HH:mm:ss z')) |
| properties.setProperty('buildhost', System.getProperty('protocolsupport.buildhost', 'unknown')) |
| properties.setProperty('buildnumber', System.getProperty('protocolsupport.buildnumber', 'unknown')) |
| properties.setProperty('buildgit', System.getProperty('protocolsupport.buildgit', 'unknown')) |
| Files.newBufferedWriter(generatedResourcesResourcesDirectoryPath.resolve('buildinfo')).withCloseable({ properties.store(it, 'Build info') }) |
| } |
| |
| from generatedResourcesDirectoryPath |
| |
| filesMatching('plugin.yml') { |
| expand 'version': project.version |
| } |
| } |
| |
| shadowJar { |
| duplicatesStrategy = DuplicatesStrategy.INCLUDE |
| |
| archiveClassifier = '' |
| |
| from sourceSets.main.java.srcDirs |
| from 'LICENSE' |
| |
| exclude 'META-INF/**' |
| exclude 'module-info.class' |
| |
| String relocatePrefix = 'protocolsupport.libs.' |
| |
| relocate 'org.apache', relocatePrefix + 'org.apache' |
| relocate 'javax.annotation', relocatePrefix + 'javax.annotation' |
| } |
| |
| |
| task copyFinalJarToTarget(type: DefaultTask) {doLast{ |
| Path targetJarDirectory = projectDirectoryPath.resolve('target') |
| Files.createDirectories(targetJarDirectory) |
| Files.copy( |
| shadowJar.archiveFile.get().getAsFile().toPath().toAbsolutePath(), |
| targetJarDirectory.resolve(shadowJar.archiveBaseName.get() + '.jar'), |
| StandardCopyOption.REPLACE_EXISTING |
| ) |
| }} |
| |
| |
| compileJava.dependsOn(setupFolders) |
| jar.enabled = false |
| jar.finalizedBy(shadowJar) |
| shadowJar.finalizedBy(copyFinalJarToTarget) |
| |
| |
| tasks.withType(GenerateModuleMetadata) { |
| enabled = false |
| } |
| |
| publishing { |
| publications { |
| release(MavenPublication) { |
| from components.java |
| |
| artifacts = [shadowJar] |
| } |
| } |
| } |