-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
127 lines (106 loc) · 4.34 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
118
119
120
121
122
123
124
125
126
127
plugins {
id 'java'
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'top.hendrixshen.replace-token' version '1.1.2'
}
group = 'org.example'
version = '1.0.0'
ext {
// The version of Recaf we're building against.
//
// For Recaf versions:
// - Releases: https://mvnrepository.com/artifact/software.coley/recaf-core
// - Snapshots: https://jitpack.io/#Col-E/Recaf (see commits tab)
recafVersion = '102fa4df1e'
recafSnapshots = true
// This should point to the full name of the class that 'implements Plugin'
pluginMainClass = 'org.example.plugin.ExamplePlugin'
// These variables will change what plugin information is declared
pluginName = 'Example plugin'
pluginDesc = 'This example plugin does nothing special, but you can add to it'
pluginId = group + '.' + project.name
}
// Recaf requires JDK 22 or higher.
// We'll use this toolchain declaration to force the version of Java this project builds with.
// If your main JDK is 22+ you won't need any additional setup.
//
// See: https://docs.gradle.org/current/userguide/toolchains.html
// gradlew -q javaToolchains - see the list of detected toolchains.
//
// If you wish to keep your main JDK as something else I suggest you create a "toolchains.xml"
// in your '${user.home}/.m2/' directory. You can see an example over at:
// https://maven.apache.org/guides/mini/guide-using-toolchains.html
java {
toolchain {
languageVersion = JavaLanguageVersion.of(22)
}
}
repositories {
mavenLocal()
mavenCentral()
// For Recaf snapshot builds a few transitive dependencies
maven { url 'https://jitpack.io' }
}
configurations.configureEach {
// Annoying annotations that replace desired tab completions.
exclude group: 'org.checkerframework'
// Other annotations we don't use which are transitive deps of deps
exclude group: 'com.google.code.findbugs'
exclude group: 'com.google.errorprone'
exclude group: 'com.google.j2objc'
exclude group: 'org.jetbrains', module: 'annotations'
// Transitive dependencies that we want to ignore (less to download, less repositories to connect to)
exclude group: 'com.android.tools'
// Used by ANTLR runtime, has a lot of IL8N related files which we don't use.
// Removing this dependency doesn't inhibit the behavior of libraries using the
// runtime in practice though.
exclude group: 'com.ibm.icu'
}
dependencies {
if (recafSnapshots) {
implementation "com.github.Col-E.Recaf:recaf-core:${recafVersion}"
implementation "com.github.Col-E.Recaf:recaf-ui:${recafVersion}"
} else {
implementation "software.coley:recaf-core:${recafVersion}"
implementation "software.coley:recaf-ui:${recafVersion}"
}
testImplementation platform('org.junit:junit-bom:5.11.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
test {
useJUnitPlatform()
}
// We include the JavaFX plugin to allow you to quickly run Recaf from this project.
javafx {
version = '22.0.1'
modules = [ 'javafx.base', 'javafx.graphics', 'javafx.controls', 'javafx.media' ]
}
// The replace-token plugin synchronizes our @PluginInformation(version) with our project.version
replaceToken {
targetSourceSets.set([sourceSets.main])
replace("##ID##", project.ext.pluginId)
replace("##NAME##", project.ext.pluginName)
replace("##DESC##", project.ext.pluginDesc)
replace("##VERSION##", project.version)
}
// This dirty hack of a task creates the service entry in the output jar.
// Recaf expects the service entry to be the full name of the class that implements the 'Plugin' interface
tasks.register('setupServiceEntry') {
outputs.dir(temporaryDir)
doFirst {
new File(temporaryDir, "META-INF/services").mkdirs()
new File(temporaryDir, "META-INF/services/software.coley.recaf.plugin.Plugin").text = project.ext.pluginMainClass
}
}
jar.from(setupServiceEntry)
// Because all of the necessary dependencies to run Recaf are on the classpath we can make
// a simple task to run Recaf. We'll have it build our plugin and load it up on startup.
tasks.register('runRecaf', JavaExec) {
// Need to build the plugin jar first
dependsOn 'build'
// Setup the classpath for the task
classpath sourceSets.main.runtimeClasspath
mainClass = "software.coley.recaf.Main"
// Add our plugin
args("-r", "build/libs")
}