mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-12-25 13:41:06 +01:00
build: add build logic
This commit is contained in:
parent
675aa86144
commit
d2e7160452
11 changed files with 104 additions and 65 deletions
|
@ -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,12 +30,27 @@ subprojects {
|
|||
fun determinePatchVersion(project: Project): Int {
|
||||
val tagInfo = ByteArrayOutputStream()
|
||||
|
||||
return try {
|
||||
exec {
|
||||
commandLine("git", "describe", "--tags")
|
||||
standardOutput = tagInfo
|
||||
}
|
||||
|
||||
val result = tagInfo.toString()
|
||||
|
||||
if (result.contains("-")) result.split("-")[1].toInt() else 0
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fun determineCommitHash(project: Project): String {
|
||||
val commitHashInfo = ByteArrayOutputStream()
|
||||
|
||||
exec {
|
||||
commandLine("git", "describe", "--tags")
|
||||
standardOutput = tagInfo
|
||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||
standardOutput = commitHashInfo
|
||||
}
|
||||
|
||||
val result = tagInfo.toString()
|
||||
|
||||
return if (result.contains("-")) result.split("-")[1].toInt() else 0
|
||||
return commitHashInfo.toString()
|
||||
}
|
13
buildSrc/build.gradle.kts
Normal file
13
buildSrc/build.gradle.kts
Normal 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")
|
||||
}
|
26
buildSrc/src/main/kotlin/lighteco.base-logic.gradle.kts
Normal file
26
buildSrc/src/main/kotlin/lighteco.base-logic.gradle.kts
Normal 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()
|
||||
}
|
||||
}
|
13
buildSrc/src/main/kotlin/lighteco.platform-logic.gradle.kts
Normal file
13
buildSrc/src/main/kotlin/lighteco.platform-logic.gradle.kts
Normal 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"))
|
||||
}
|
||||
}
|
13
buildSrc/src/main/kotlin/lighteco.shadow-logic.gradle.kts
Normal file
13
buildSrc/src/main/kotlin/lighteco.shadow-logic.gradle.kts
Normal 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)
|
||||
}
|
||||
}
|
|
@ -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")
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package dev.xhyrom;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package dev.xhyrom.lighteco.bukkit;
|
||||
|
||||
public class BukkitLightEcoPlugin extends JavaPlugin {
|
||||
}
|
|
@ -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")
|
||||
}
|
|
@ -7,4 +7,4 @@ sequenceOf(
|
|||
).forEach {
|
||||
include("lighteco-$it")
|
||||
project(":lighteco-$it").projectDir = file(it)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
Loading…
Reference in a new issue