buildscript { ext { indraVersion = '2.0.4' } } plugins { id 'net.kyori.indra' version "$indraVersion" apply false id 'net.kyori.indra.git' version "$indraVersion" id 'net.kyori.indra.checkstyle' version "$indraVersion" apply false id 'net.kyori.indra.publishing' version "$indraVersion" apply false id 'com.github.johnrengelman.shadow' version '7.0.0' apply false } import org.apache.tools.ant.filters.ReplaceTokens import org.eclipse.jgit.lib.Ref import org.eclipse.jgit.lib.Repository import org.eclipse.jgit.revwalk.RevWalk allprojects { group = 'net.essentialsx' version = '2.19.0-SNAPSHOT' } @SuppressWarnings('GrMethodMayBeStatic') def commitsSinceLastTag() { if (indraGit == null || !indraGit.isPresent() || indraGit.tags().isEmpty()) { return -1 } def tags = indraGit.tags() def depth = 0 def walk = new RevWalk(indraGit.git().getRepository()) def commit = walk.parseCommit(indraGit.commit()) while (true) { for (tag in tags) { if (walk.parseCommit(tag.getLeaf().getObjectId()) == commit) { walk.dispose() indraGit.git().close() return depth } } depth++ commit = walk.parseCommit(commit.getParents()[0]) } } @SuppressWarnings('GrMethodMayBeStatic') def headBranchName() { if (System.getenv("GITHUB_HEAD_REF") != null) { return System.getenv("GITHUB_HEAD_REF") } if (!indraGit.isPresent()) { return "detached-head" } Ref ref = indraGit.git().getRepository().exactRef('HEAD')?.target if (ref == null) { return "detached-head" } return Repository.shortenRefName(ref.name) } project.ext { GIT_COMMIT = !indraGit.isPresent() ? "unknown" : indraGit.commit().abbreviate(7).name() GIT_DEPTH = commitsSinceLastTag() GIT_BRANCH = headBranchName() fullVersion = "${version}".replace("-SNAPSHOT", "-dev+${GIT_DEPTH}-${GIT_COMMIT}") checkstyleVersion = '8.36.2' spigotVersion = '1.16.5-R0.1-SNAPSHOT' junit5Version = '5.7.0' mockitoVersion = '3.2.0' } subprojects { apply plugin: 'java' apply plugin: 'net.kyori.indra' apply plugin: 'net.kyori.indra.checkstyle' apply plugin: 'net.kyori.indra.publishing' apply plugin: 'com.github.johnrengelman.shadow' repositories { maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' } maven { url = 'https://papermc.io/repo/repository/maven-public/' } maven { url = 'https://jitpack.io' content { includeGroup "com.github.milkbowl" } } maven { url = 'https://repo.codemc.org/repository/maven-public' content { includeGroup "org.bstats" } } mavenCentral() { content { includeGroup "net.kyori" } } } dependencies { testImplementation "org.junit.jupiter:junit-jupiter:${junit5Version}" testImplementation "org.junit.vintage:junit-vintage-engine:${junit5Version}" testImplementation "org.mockito:mockito-core:${mockitoVersion}" if (project.name != "1_8Provider" && project.name != "PaperProvider" && project.name != "NMSReflectionProvider") { // These providers use their own bukkit versions api "org.spigotmc:spigot-api:${spigotVersion}" } } // Dependency caching configurations.all { resolutionStrategy.cacheChangingModulesFor 5, 'minutes' } // Version Injection processResources { // Always process resources if version string or git branch changes inputs.property('fullVersion', fullVersion) inputs.property('gitBranch', GIT_BRANCH) filter(ReplaceTokens, beginToken: '${', endToken: '}', tokens: ["full.version": fullVersion, "git.branch": GIT_BRANCH]) } indra { checkstyle "$checkstyleVersion" github('EssentialsX', 'Essentials') gpl3OnlyLicense() publishReleasesTo('essx', 'https://repo.essentialsx.net/releases/') publishSnapshotsTo('essx', 'https://repo.essentialsx.net/snapshots/') configurePublications { pom { description = 'The essential plugin suite for Minecraft servers.' url = 'https://essentialsx.net' developers { developer { id = 'mdcfe' name = 'MD' email = 'md@n3fs.co.uk' } developer { id = 'pop4959' } developer { id = 'JRoy' name = 'Josh Roy' } } ciManagement { system = 'Jenkins' url = 'https://ci.ender.zone/job/EssentialsX' } } } javaVersions { target 8 minimumToolchain 16 } } compileJava { options.compilerArgs.add('-Xlint:-deprecation') } javadoc { title = "${project.name} API (v${rootProject.ext.fullVersion})" options.links( 'https://hub.spigotmc.org/javadocs/spigot/' ) options.addBooleanOption('Xdoclint:none', true) } // undo https://github.com/KyoriPowered/indra/blob/master/indra-common/src/main/kotlin/net/kyori/indra/IndraPlugin.kt#L57 archivesBaseName = project.name tasks.withType(Jar) { archiveVersion.set(fullVersion) } } def outputTasks() { [":EssentialsX:shadowJar", ":EssentialsXAntiBuild:jar", ":EssentialsXChat:jar", ":EssentialsXGeoIP:shadowJar", ":EssentialsXProtect:jar", ":EssentialsXSpawn:jar", ":EssentialsXXMPP:shadowJar"].stream().map({ tasks.findByPath(it) }) } task copyToJars(type: Copy) { dependsOn tasks.findByPath(":EssentialsX:processResources") outputTasks().forEach { from(it) } rename '(.*)-all.jar', '$1.jar' into file('jars') } task cleanJars() { delete file('jars') } task clean() { dependsOn cleanJars } task build() { dependsOn copyToJars }