AGSLunarCore/build.gradle

214 lines
5.5 KiB
Groovy
Raw Normal View History

2023-09-25 13:03:09 +00:00
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.6.3/userguide/tutorial_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application
id 'application'
// Apply the java plugin to add support for Java
id 'java'
2023-09-25 13:03:09 +00:00
// Protoc plugin
id 'com.google.protobuf' version '0.8.19'
2023-09-25 13:03:09 +00:00
id 'eclipse'
id 'idea'
2023-09-25 13:03:09 +00:00
}
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
2024-02-05 23:38:01 +00:00
version = '1.1.1'
2023-11-26 11:12:07 +00:00
var shouldGenerateProto = System.getenv("GENERATE_PROTO") == "true"
System.out.println(shouldGenerateProto ?
"Generating proto files" :
"Skipping proto generation")
2023-09-25 13:03:09 +00:00
repositories {
mavenCentral()
jcenter()
}
protobuf {
protoc {
2023-09-25 13:03:09 +00:00
artifact = 'com.google.protobuf:protoc:3.24.3'
}
plugins {
quickbuf {
artifact = 'us.hebi.quickbuf:protoc-gen-quickbuf:1.3.1'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
quickbuf {
//option 'store_unknown_fields=true'
outputSubDir = ''
}
}
}
}
generatedFilesBaseDir = "$projectDir/src/generated/"
2023-09-25 13:03:09 +00:00
}
dependencies {
implementation fileTree(dir: 'lib', include: ['*.jar'])
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.9'
2023-12-04 03:43:41 +00:00
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.4.14'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.14'
2023-09-25 13:03:09 +00:00
implementation group: 'it.unimi.dsi', name: 'fastutil-core', version: '8.5.12'
implementation group: 'org.reflections', name: 'reflections', version: '0.10.2'
2023-09-25 13:03:09 +00:00
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation group: 'us.hebi.quickbuf', name: 'quickbuf-runtime', version: '1.3.1'
2023-12-04 03:43:41 +00:00
implementation group: 'io.javalin', name: 'javalin', version: '5.6.3'
2023-12-04 03:43:41 +00:00
implementation group: 'io.netty', name: 'netty-common', version: '4.1.101.Final'
implementation group: 'io.netty', name: 'netty-handler', version: '4.1.101.Final'
implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.101.Final'
implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.101.Final'
2023-12-04 03:43:41 +00:00
implementation group: 'dev.morphia.morphia', name: 'morphia-core', version: '2.3.9'
2023-09-25 13:03:09 +00:00
implementation group: 'de.bwaldvogel', name: 'mongo-java-server', version: '1.44.0'
implementation group: 'de.bwaldvogel', name: 'mongo-java-server-h2-backend', version: '1.44.0'
2023-12-04 03:43:41 +00:00
implementation group: 'org.jline', name: 'jline', version: '3.24.1'
implementation group: 'org.jline', name: 'jline-terminal-jansi', version: '3.24.1'
2023-09-25 13:03:09 +00:00
protobuf files('proto/')
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
}
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j'
}
clean {
if (shouldGenerateProto) {
delete protobuf.generatedFilesBaseDir
}
2023-09-25 13:03:09 +00:00
}
application {
// Define the main class for the application
2023-10-24 14:53:10 +00:00
mainClassName = 'emu.lunarcore.LunarCore'
2023-09-25 13:03:09 +00:00
}
jar {
2023-11-14 12:06:26 +00:00
dependsOn 'injectGitHash'
2023-09-25 13:03:09 +00:00
exclude '*.proto'
manifest {
2023-10-24 14:53:10 +00:00
attributes 'Main-Class': 'emu.lunarcore.LunarCore'
2023-09-25 13:03:09 +00:00
}
jar {
2023-10-24 14:53:10 +00:00
archiveBaseName = 'LunarCore'
2023-09-25 13:03:09 +00:00
archiveVersion = ''
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
2023-09-25 13:03:09 +00:00
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from('src/main/java') {
include '*.xml'
}
getDestinationDirectory().set(file("."))
}
sourceSets {
main {
proto {
srcDir 'src/generated'
}
java {
srcDir 'src/main/java'
}
}
}
idea {
module {
// proto files and generated Java files are automatically added as
// source dirs.
// If you have additional sources, add them here:
sourceDirs += file('/proto/')
}
}
2023-09-25 13:03:09 +00:00
eclipse {
classpath {
file.whenMerged { cp ->
cp.entries.add( new org.gradle.plugins.ide.eclipse.model.SourceFolder('src/generated/main/', null) )
}
}
}
2023-11-14 12:06:26 +00:00
tasks.register('injectGitHash') {
def gitCommitHash = {
try {
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
} catch (ignored) {
return ''
}
}
def gitCommitTime = {
try {
return 'git log -1 --format=%at --date=raw'.execute().text.trim()
} catch (ignored) {
return '0'
2023-11-14 12:06:26 +00:00
}
}
new File(project.projectDir.getAbsolutePath() + '/src/main/java/emu/lunarcore/BuildConfig.java').text = """
package emu.lunarcore;
public final class BuildConfig {
2023-11-26 11:12:07 +00:00
public static final String VERSION = \"${version}\";
2023-11-14 12:06:26 +00:00
public static final String GIT_HASH = \"${gitCommitHash()}\";
public static final String GIT_TIMESTAMP = \"${gitCommitTime()}\";
2023-11-14 12:06:26 +00:00
}
"""
}
task updateProto {
group 'Build'
description 'Cleans generated proto folder and regenerates protos'
if (shouldGenerateProto) {
dependsOn 'clean'
}
dependsOn 'generateProto'
}
2023-09-25 13:03:09 +00:00
processResources {
dependsOn 'generateProto'
}