| buildscript { |
| repositories { |
| mavenCentral() |
| maven { |
| url 'https://jitpack.io' |
| } |
| } |
| dependencies { |
| classpath group: 'com.github.HurricaneGamesOrg', name: 'ManualGradleDependencySupplier', version: 'f6f36bec29' |
| } |
| } |
| |
| plugins { |
| id 'java' |
| id 'com.github.johnrengelman.shadow' version '7.0.0' |
| id 'maven-publish' |
| } |
| |
| apply plugin: 'org.hurricanegames.ManualGradleDependencySupplier' |
| |
| |
| gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.ALWAYS |
| |
| |
| defaultTasks 'build' |
| |
| |
| group 'protocolsupport' |
| version '1.17-1-dev' |
| |
| |
| import java.nio.file.Path |
| import java.nio.file.Paths |
| import java.nio.file.Files |
| import java.nio.file.SimpleFileVisitor |
| import java.nio.file.FileVisitResult |
| import java.nio.file.attribute.BasicFileAttributes |
| |
| import org.hurricanegames.manualgradledependencysupplier.DependencySupplier |
| import org.hurricanegames.manualgradledependencysupplier.BuildDependencySupplier |
| import org.hurricanegames.manualgradledependencysupplier.ManualGradleDependencySupplier |
| |
| |
| Path projectDirectoryPath = projectDir.toPath().toAbsolutePath() |
| Path projectBuildDirectoryPath = getBuildDir().toPath() |
| |
| |
| Path generatedResourcesDirectoryPath = projectDirectoryPath.resolve('gen') |
| String resourcesDirectoryName = 'resources'; |
| Path generatedResourcesResourcesDirectoryPath = generatedResourcesDirectoryPath.resolve(resourcesDirectoryName) |
| |
| task setupFolders(type: DefaultTask) {doLast{ |
| generatedResourcesDirectoryPath.toFile().deleteDir() |
| Files.createDirectories(generatedResourcesDirectoryPath) |
| Files.createDirectories(generatedResourcesResourcesDirectoryPath) |
| }} |
| |
| |
| sourceCompatibility = JavaVersion.VERSION_16 |
| |
| 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://papermc.io/repo/repository/maven-public/' |
| } |
| } |
| |
| configurations { |
| runtimeDependencies |
| compileOnly { |
| extendsFrom runtimeDependencies |
| } |
| testImplementation { |
| extendsFrom runtimeDependencies |
| } |
| } |
| |
| dependencies { |
| Path spigotBuildDirectoryPath = projectBuildDirectoryPath.resolve('spigot') |
| FileCollection runtimeLibraries = ManualGradleDependencySupplier.supplyDependecies( |
| projectDirectoryPath.resolve('libraries_runtime'), |
| [ |
| new BuildDependencySupplier( |
| 'spigot-1.17-1.jar', |
| new URL('https://hub.spigotmc.org/jenkins/job/BuildTools/128/artifact/target/BuildTools.jar'), |
| spigotBuildDirectoryPath, |
| 'BuildTools.jar', |
| ['java', '-jar', 'BuildTools.jar', '--rev', '1.17'], |
| ['spigot-1.17.jar'] |
| ).setBuildEnv([ |
| 'MAVEN_OPTS': '-Dmaven.repo.local=' + spigotBuildDirectoryPath.resolve('m2').toString() + ' -Xmx1024M' |
| ]) |
| ], |
| true |
| ) |
| |
| FileCollection annotationProcessors = fileTree(dir: projectDirectoryPath.resolve('processors'), include: '*.jar') |
| |
| runtimeDependencies group: 'io.papermc.paper', name: 'paper-api', version: '1.17-R0.1-SNAPSHOT' |
| runtimeDependencies annotationProcessors |
| runtimeDependencies runtimeLibraries |
| |
| |
| implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11' |
| implementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.4.2' |
| implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' |
| implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2' |
| |
| annotationProcessor annotationProcessors |
| |
| testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0' |
| testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0' |
| } |
| |
| compileJava { |
| doFirst { |
| classpath -= configurations.runtimeDependencies |
| classpath += configurations.runtimeDependencies |
| } |
| |
| options.encoding = 'UTF-8' |
| options.incremental = false |
| options.compilerArgs << ('-Aprotocolsupportbuildprocessor.generatedresourcesdirectory=' + generatedResourcesResourcesDirectoryPath.resolve('preload').toString()) |
| } |
| |
| |
| test { |
| Path workingDirectoryPath = projectDirectoryPath.resolve('testsRun'); |
| |
| doFirst { |
| classpath -= configurations.runtimeDependencies |
| classpath += configurations.runtimeDependencies |
| |
| Files.createDirectories(workingDirectoryPath) |
| } |
| |
| useJUnitPlatform() |
| |
| workingDir = workingDirectoryPath; |
| } |
| |
| |
| 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 'it.unimi.dsi.fastutil', relocatePrefix + 'it.unimi.dsi.fastutil' |
| relocate 'com.google.gson', relocatePrefix + 'com.google.gson' |
| relocate 'javax.annotation', relocatePrefix + 'javax.annotation' |
| |
| minimize() |
| } |
| |
| |
| 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'), |
| java.nio.file.StandardCopyOption.REPLACE_EXISTING |
| ) |
| }} |
| |
| |
| compileJava.dependsOn(clean) |
| compileJava.dependsOn(setupFolders) |
| test.dependsOn(cleanTest) |
| compileJava.finalizedBy(test) |
| jar.enabled = false |
| jar.finalizedBy(shadowJar) |
| shadowJar.finalizedBy(copyFinalJarToTarget) |
| |
| |
| tasks.withType(GenerateModuleMetadata) { |
| enabled = false |
| } |
| |
| publishing { |
| publications { |
| release(MavenPublication) { |
| from components.java |
| |
| artifacts = [shadowJar] |
| } |
| } |
| } |