Skip to content

Commit

Permalink
build: use buildsrc (#256)
Browse files Browse the repository at this point in the history
* build: use buildsrc

* build: remove useless define

* build: update
  • Loading branch information
CoolLoong authored Jun 11, 2024
1 parent 202efb4 commit 6e08b4f
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 168 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
/Allay-Server/ban-info.yml
/Allay-Server/whitelist.yml
/.jacoco/
/.vscode/
/.vscode/
/buildSrc/.gradle/
2 changes: 1 addition & 1 deletion .run/Allay.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration default="false" name="Allay" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="org.allaymc.server.Allay" />
<module name="Allay.Allay-Server.main" />
<option name="VM_PARAMETERS" value="-Dfile.encoding=UTF-8 -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI"/>
<option name="VM_PARAMETERS" value="-Dfile.encoding=UTF-8 -XX:+UseZGC -XX:+ZGenerational"/>
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.run" />
<method v="2">
<option name="Make" enabled="true" />
Expand Down
1 change: 1 addition & 0 deletions Allay-API/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
`java-library`
id("buildlogic.common")
}

group = "org.allaymc"
Expand Down
4 changes: 4 additions & 0 deletions Allay-CodeGen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("buildlogic.common")
}

group = "org.allaymc"
description = "codegen"
version = "1.0.0"
Expand Down
4 changes: 4 additions & 0 deletions Allay-Data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("buildlogic.common")
}

group = "org.allaymc"
description = "data"
version = "1.0.0"
Expand Down
3 changes: 2 additions & 1 deletion Allay-ExamplePlugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
`java-library`
id("buildlogic.common")
}


group = "org.allaymc"
description = "example-plugin"
version = "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions Allay-Server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
application
id("me.champeau.jmh") version "0.7.2"
id("com.gorylenko.gradle-git-properties") version "2.4.2"
id("buildlogic.common")
}

group = "org.allaymc"
Expand Down
2 changes: 1 addition & 1 deletion Allay-SparkPlugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
id("com.google.protobuf") version "0.9.4"
id("buildlogic.common")
}

group = "org.allaymc"
Expand Down
155 changes: 0 additions & 155 deletions build.gradle.kts

This file was deleted.

18 changes: 18 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
java
`kotlin-dsl`
}

repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
}

dependencies {
implementation("com.github.johnrengelman:shadow:8.1.1")
}
1 change: 1 addition & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "buildSrc"
103 changes: 103 additions & 0 deletions buildSrc/src/main/kotlin/buildlogic.common.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import java.nio.charset.StandardCharsets

plugins {
// Apply the java Plugin to add support for Java.
java
idea
`maven-publish`
id("com.github.johnrengelman.shadow")
}

java {
withJavadocJar()
withSourcesJar()
}

repositories {
// Use Maven Central for resolving dependencies.
mavenLocal()
mavenCentral()
maven("https://www.jitpack.io/")
maven("https://repo.opencollab.dev/maven-releases/")
maven("https://repo.opencollab.dev/maven-snapshots/")
maven("https://storehouse.okaeri.eu/repository/maven-public/")
}

dependencies {
//libs.versions.toml cannot be used in public plugin scripts
compileOnly("org.projectlombok:lombok:1.18.32")

testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")

testCompileOnly("org.projectlombok:lombok:1.18.32")

annotationProcessor("org.projectlombok:lombok:1.18.32")
testAnnotationProcessor("org.projectlombok:lombok:1.18.32")
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.build {
//control the task group is "alpha build"
group = "alpha build"
dependsOn("shadowJar")
}

tasks.register<DefaultTask>("fastBuild") {
dependsOn(tasks.build)
group = "alpha build"
tasks["javadoc"].enabled = false
tasks["javadocJar"].enabled = false
tasks["sourcesJar"].enabled = false
tasks["compileTestJava"].enabled = false
tasks["processTestResources"].enabled = false
tasks["testClasses"].enabled = false
tasks["test"].enabled = false
tasks["check"].enabled = false
}

tasks.register<DefaultTask>("buildForGithubAction") {
dependsOn(tasks.build)
group = "alpha build"
tasks["javadoc"].enabled = false
tasks["javadocJar"].enabled = false
}

tasks.clean {
group = "alpha build"
}

// disable assemble
tasks.assemble {
enabled = false
}

tasks.test {
useJUnitPlatform()
workingDir = File("${rootProject.projectDir}/.run/")
}

tasks.withType<JavaCompile> {
options.encoding = StandardCharsets.UTF_8.name()
}

tasks.withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.withType<Javadoc> {
options.encoding = StandardCharsets.UTF_8.name()
val javadocOptions = options as CoreJavadocOptions
javadocOptions.addStringOption(
"source",
java.sourceCompatibility.toString()
)
// Suppress some meaningless warnings
javadocOptions.addStringOption("Xdoclint:none", "-quiet")
}
9 changes: 0 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[versions]
log4j = "2.23.1"
junit = "5.10.2"
mockito = "5.12.0"
graalvm = "24.0.1"

[libraries]
Expand Down Expand Up @@ -42,11 +40,6 @@ log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.
progressbar = { group = "me.tongfei", name = "progressbar", version = "0.10.1" }
picocli = { group = "info.picocli", name = "picocli", version = "4.7.6" }
mcterminal = { group = "net.minecrell", name = "terminalconsoleappender", version = "1.3.0" }
# Testing dependencies
junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
mockito = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
mockito-junit = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockito" }
# Code generating
javapoet = { group = "com.squareup", name = "javapoet", version = "1.13.0" }
# Reflections
Expand Down Expand Up @@ -75,8 +68,6 @@ oshi = { group = "com.github.oshi", name = "oshi-core", version = "6.6.1" }
flatlaf = { group = "com.formdev", name = "flatlaf", version = "3.4.1" }
formsrt = { group = "com.intellij", name = "forms_rt", version = "7.0.3" }


[bundles]
logging = ["log4j-slf4j2-impl", "log4j-core"]
test = ["junit-jupiter-api", "junit-jupiter-engine", "mockito", "mockito-junit"]
graalvm = ["sdk", "js", "polyglot", "chromeinspector-tool", "profiler-tool"]
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rootProject.name = "Allay"

// include multi modules
include(":Allay-API")
include(":Allay-Server")
include(":Allay-CodeGen")
Expand Down

0 comments on commit 6e08b4f

Please sign in to comment.