1
0
Fork 0
mirror of https://github.com/xHyroM/lighteco.git synced 2024-11-10 01:18:07 +01:00

build: add build logic

This commit is contained in:
xHyroM 2023-07-30 17:04:46 +02:00
parent 675aa86144
commit d2e7160452
No known key found for this signature in database
GPG key ID: BE0423F386C436AA
11 changed files with 104 additions and 65 deletions

View file

@ -4,23 +4,24 @@ plugins {
id("java")
}
val majorVersion = 0;
val minorVersion = 1;
val patchVersion = determinePatchVersion(project);
val majorVersion = 0
val minorVersion = 1
val patchVersion = determinePatchVersion(project)
val commitHash = determineCommitHash(project)
allprojects {
group = "dev.xhyrom"
version = "1.0-SNAPSHOT"
version = "$majorVersion.$minorVersion.$patchVersion"
ext {
set("version", "$majorVersion.$minorVersion.$patchVersion+$commitHash")
}
}
subprojects {
apply(plugin = "java")
apply(plugin = "java-library")
ext {
set("version", "$majorVersion.$minorVersion.$patchVersion")
}
repositories {
mavenCentral()
}
@ -29,6 +30,7 @@ subprojects {
fun determinePatchVersion(project: Project): Int {
val tagInfo = ByteArrayOutputStream()
return try {
exec {
commandLine("git", "describe", "--tags")
standardOutput = tagInfo
@ -36,5 +38,19 @@ fun determinePatchVersion(project: Project): Int {
val result = tagInfo.toString()
return if (result.contains("-")) result.split("-")[1].toInt() else 0
if (result.contains("-")) result.split("-")[1].toInt() else 0
} catch (e: Exception) {
0
}
}
fun determineCommitHash(project: Project): String {
val commitHashInfo = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = commitHashInfo
}
return commitHashInfo.toString()
}

13
buildSrc/build.gradle.kts Normal file
View file

@ -0,0 +1,13 @@
plugins {
`kotlin-dsl`
`groovy-gradle-plugin`
}
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2")
}

View file

@ -0,0 +1,26 @@
plugins {
`java-library`
`maven-publish`
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
withSourcesJar()
}
tasks {
processResources {
filesMatching(listOf("plugin.yml")) {
expand(
"name" to project.name,
"version" to project.version,
"description" to project.description,
"author" to "xHyroM"
)
}
}
compileJava {
options.encoding = Charsets.UTF_8.name()
}
}

View file

@ -0,0 +1,13 @@
plugins {
id("lighteco.shadow-logic")
}
val Project.platform: String
get() = project.name.split("-")[1]
tasks {
shadowJar {
archiveFileName.set("lighteco-${project.platform}-${project.version}.jar")
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
}
}

View file

@ -0,0 +1,13 @@
plugins {
id("lighteco.base-logic")
id("com.github.johnrengelman.shadow")
}
tasks {
named<Jar>("jar") {
archiveClassifier.set("unshaded")
}
named("build") {
dependsOn(tasks.shadowJar)
}
}

View file

@ -1,18 +1,11 @@
plugins {
id("java")
id("lighteco.platform-logic")
}
group = "dev.xhyrom"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
}

View file

@ -1,7 +0,0 @@
package dev.xhyrom;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View file

@ -0,0 +1,4 @@
package dev.xhyrom.lighteco.bukkit;
public class BukkitLightEcoPlugin extends JavaPlugin {
}

View file

@ -1,19 +1,3 @@
plugins {
id("java")
}
group = "dev.xhyrom"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
id("lighteco.shadow-logic")
}

View file

@ -1,19 +1,3 @@
plugins {
id("java")
}
group = "dev.xhyrom"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
id("lighteco.platform-logic")
}