forked from MinecraftFunctionPlusPlus/MCFPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
98 lines (83 loc) · 2.53 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import org.gradle.kotlin.dsl.cpp
plugins {
kotlin("jvm") version "1.8.0"
groovy
application
antlr
id("org.jetbrains.dokka") version "1.8.10"
java
cpp
}
group = "top.mcfpp"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
setUrl("https://jitpack.io")
}
maven {
setUrl("https://maven.aliyun.com/nexus/content/groups/public/")
}
maven {
setUrl("https://jitpack.io/")
}
maven {
setUrl("https://libraries.minecraft.net")
}
}
dependencies {
testImplementation(kotlin("test"))
implementation("org.apache.groovy:groovy-all:4.0.11")
implementation("com.alibaba.fastjson2:fastjson2:2.0.28")
implementation("org.apache.logging.log4j:log4j-api:2.20.0")
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
implementation("org.openjdk.nashorn:nashorn-core:15.4")
implementation("com.github.Querz:NBT:6.1")
implementation("com.mojang:brigadier:1.0.18")
antlr("org.antlr:antlr4:4.12.0")
implementation(kotlin("reflect"))
testImplementation(kotlin("script-runtime"))
}
tasks.test {
useJUnitPlatform()
}
tasks.generateGrammarSource {
mkdir("build")
arguments = arguments + listOf("-visitor", "-long-messages", "-package", "top.mcfpp.antlr")
outputDirectory = File("build/generated-src/antlr/main/top/mcfpp/antlr")
}
tasks.jar{
manifest{
attributes("Main-Class" to "MCFPPKt")
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) })
from("build/dll"){
into("native")
include("**/*.dll")
}
}
val jniSourceDir = file("src/main/java/top/mcfpp/jni")
val cppSourceDir = file("src/main/cpp")
tasks.register<JavaCompile>("generateJni") {
group = "build"
destinationDirectory.set(file("$buildDir/generated/jni"))
source = fileTree(jniSourceDir)
classpath = files()
options.compilerArgs = listOf("-h", "$buildDir/generated/jni")
}
tasks.register<Exec>("compileCpp") {
group = "build"
workingDir(cppSourceDir)
commandLine("g++", "-I", "${System.getProperty("java.home")}/include", "-I", "${System.getProperty("java.home")}/include/win32", "-I", "$buildDir/generated/jni", "-shared", "-o", "$buildDir/dll/native.dll", "*.cpp")
}
kotlin {
jvmToolchain(8)
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
dependsOn(tasks.generateGrammarSource)
}
application {
mainClass.set("MCFPPKt")
}