-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
117 lines (97 loc) · 3.92 KB
/
build.gradle
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import org.moddingx.modgradle.api.JavaEnvironment
import org.moddingx.modgradle.api.task.ClasspathExec
import java.nio.file.Files
import java.nio.file.StandardOpenOption
buildscript {
repositories {
maven { url = 'https://maven.moddingx.org' }
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org/' }
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.41'
classpath 'org.moddingx:ModGradle:3.0.0'
classpath 'org.apache.maven:maven-artifact:3.8.1'
classpath 'org.apache.maven:maven-repository-metadata:3.8.1'
classpath 'com.google.code.findbugs:jsr305:3.0.1'
classpath 'commons-io:commons-io:2.11.0'
classpath 'org.apache.logging.log4j:log4j-api:2.17.2'
classpath 'org.apache.logging.log4j:log4j-core:2.17.2'
}
}
apply plugin: 'java'
apply plugin: 'maven-publish'
group 'org.moddingx'
final SOURCE_TRANSFORM_VERSION = '2.1.3'
final List<String> PACKAGES = Files.readAllLines(project.file('packages.txt').toPath()).stream()
.map(String::strip).filter(str -> !str.isEmpty()).toList()
final List<String> CLASSES = Files.readAllLines(project.file('classes.txt').toPath()).stream()
.map(String::strip).filter(str -> !str.isEmpty()).toList()
repositories {
maven { url 'https://maven.moddingx.org' }
maven { url = 'https://maven.neoforged.net/releases' }
}
dependencies {
implementation 'net.neoforged:coremods:7.0.3'
implementation("org.ow2.asm:asm:9.3")
implementation("org.ow2.asm:asm-commons:9.3")
implementation("org.ow2.asm:asm-tree:9.3")
implementation("org.ow2.asm:asm-util:9.3")
}
task extractInheritance(type: ClasspathExec) {
tool = "org.moddingx:SourceTransform:${SOURCE_TRANSFORM_VERSION}"
args = provider {[
'inheritance',
'-n', String.join(";", CLASSES),
'-m', String.join(";", PACKAGES),
'-p', JavaEnvironment.getLibraryPath(project, compileJava).get().asPath,
'-o', project.file('build/inheritance.txt').toPath().toAbsolutePath().normalize().toString(),
]}
}
task generateBase(type: ClasspathExec) {
dependsOn extractInheritance
tool = "org.moddingx:SourceTransform:${SOURCE_TRANSFORM_VERSION}"
args = provider {[
'jstype',
'-i', project.file('build/inheritance.txt').toPath().toAbsolutePath().normalize().toString(),
'-c', String.join(";", CLASSES),
'-m', String.join(";", PACKAGES),
'-p', JavaEnvironment.getLibraryPath(project, compileJava).get().asPath,
'-j', project.file('build/js/coremods.js').toPath().toAbsolutePath().normalize().toString(),
'-t', project.file('build/jsgen/coremods-base.d.ts').toPath().toAbsolutePath().normalize().toString(),
'-n', project.file('nullability.txt').toPath().toAbsolutePath().normalize().toString()
]}
}
task mergeTS {
dependsOn generateBase
doLast {
BufferedWriter writer = Files.newBufferedWriter(project.file('build/js/coremods.d.ts').toPath(), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE)
writer.write(Files.readString(project.file('coremods.d.ts').toPath()) + "\n")
writer.write(Files.readString(project.file('build/jsgen/coremods-base.d.ts').toPath()) + "\n")
writer.close()
}
}
task targetZip(type: Zip) {
dependsOn mergeTS
from(project.file('build/js/coremods.js'))
from(project.file('build/js/coremods.d.ts'))
from(project.file('tsconfig.json'))
version project.version
}
build.dependsOn targetZip
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = project.name
version = project.version
artifact targetZip
}
}
repositories {
maven {
url '../moddingx/maven'
}
}
}