-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
97 lines (78 loc) · 2.45 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
plugins {
id 'java-library'
id "com.github.node-gradle.node" version "2.2.4"
id 'maven-publish'
}
group = 'com.coolspy3'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven {
url 'https://jitpack.io/'
}
}
configurations {
libraries
}
configurations.compileClasspath.extendsFrom(configurations.libraries)
dependencies {
compileOnly 'com.github.coolspy3:csmodloader:1.3.1'
implementation 'com.github.Querz:NBT:6.1'
testImplementation 'junit:junit:4.13'
}
jar {
from(configurations.libraries) {
into 'META-INF/libraries'
}
from {
exclude "META-INF/*"
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
// Template generation code for gradle Credit: DeepBlueRobotics
def templateDir = "${projectDir}/asyncapi-template"
task archiveTemplate(type: Tar) {
archiveFileName = "asyncapi-template.tar"
destinationDirectory = file("$buildDir/tmp")
from(templateDir) {
exclude "node_modules"
into "asyncapi-template" // npm requires that everything be in a top-level folder
}
}
// Add a task to generate java source code for the packets using npx to run
// the asyncapi generator.
task generatePacketFiles(type: NpxTask) {
def outputDir = "${buildDir}/generated/sources/asyncapi"
// Define the command line that npx should use
workingDir = buildDir // Because templateDir can't be under it
command = '@asyncapi/generator'
args = ['--force-write',
'-o', "${outputDir}/com/coolspy3/cspackets/packets",
"${projectDir}/generator_specification.yaml",
file(archiveTemplate.archiveFile).toURI()]
// Define the inputs and outputs of this task so that gradle only runs it
// when necessary.
inputs.files(archiveTemplate.outputs)
inputs.files("${projectDir}/generator_specification.yaml")
inputs.files("${projectDir}/generator_types.json")
outputs.dir(outputDir).withPropertyName("outputDir")
}
// Include the generated files in the source to compile.
sourceSets.main.java.srcDirs generatePacketFiles.outputs
// Use a version of node and npm that is known to work.
node {
download = true
version = '14.15.1'
npmVersion = '6.14.8'
}
publishing {
publications {
gpr(MavenPublication) {
groupId = 'com.coolspy3'
artifactId = 'cspackets'
version = '1.2.1'
from components.java
}
}
}