-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
228 lines (205 loc) · 9.17 KB
/
build.gradle
File metadata and controls
228 lines (205 loc) · 9.17 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*********************************************************************************
* Copyright 2021-2024 (C) by Saverio Giallorenzo <saverio.giallorenzo@gmail.com>*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* For details about the authors of this software, see the AUTHORS file. *
*********************************************************************************/
import org.graalvm.buildtools.gradle.dsl.NativeImageCompileOptions
import org.graalvm.buildtools.gradle.dsl.NativeImageOptions
import org.graalvm.buildtools.gradle.tasks.BuildNativeImageTask
plugins {
id 'java'
id 'org.graalvm.buildtools.native' version '0.10.3'
}
group 'org.ranflood'
def version = '0.7-BETA'
repositories {
mavenCentral()
}
configurations {
common
client.extendsFrom common
daemon.extendsFrom common
}
dependencies {
common 'com.republicate:essential-json:2.7'
common 'org.slf4j:slf4j-api:2.0.7'
common 'org.slf4j:slf4j-simple:2.0.13'
common 'org.zeromq:jeromq:0.6.0'
client 'info.picocli:picocli:4.7.6'
client 'info.picocli:picocli-codegen:4.7.6'
daemon 'org.eclipse.jetty:jetty-server:11.0.15'
daemon 'org.eclipse.jetty:jetty-servlet:11.0.15'
daemon 'org.eclipse.jetty.websocket:websocket-jakarta-server:11.0.15'
daemon 'jakarta.websocket:jakarta.websocket-api:2.0.0'
daemon 'io.reactivex.rxjava3:rxjava:3.1.8'
daemon 'com.oblac:nomen-est-omen:2.2.1'
daemon 'org.jetbrains.xodus:xodus-openAPI:2.0.1'
daemon 'org.jetbrains.xodus:xodus-environment:2.0.1'
daemon 'org.apache.commons:commons-compress:1.26.1'
daemon 'commons-io:commons-io:2.16.1'
}
//tasks.withType(JavaCompile) {
// doFirst {
// println "AnnotationProcessorPath for $name is ${options.getAnnotationProcessorPath().getFiles()}"
// }
//}
sourceSets {
common {
java.srcDir 'src/common/java'
compileClasspath += configurations.common
}
client {
java.srcDir 'src/client/java/'
runtimeClasspath += compileClasspath += configurations.client + sourceSets.common.output
}
daemon {
java.srcDir 'src/daemon/java'
runtimeClasspath += compileClasspath += configurations.daemon + sourceSets.common.output
}
tests {
java.srcDir 'src/tests/java'
runtimeClasspath += compileClasspath += configurations.client + configurations.daemon + sourceSets.common.output + sourceSets.client.output + sourceSets.daemon.output
}
filechecker {
java.srcDir 'src/filechecker/java'
runtimeClasspath += compileClasspath += configurations.client + sourceSets.common.output
}
}
build {
dependsOn compileCommonJava
dependsOn compileClientJava
dependsOn compileDaemonJava
dependsOn compileFilecheckerJava
}
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS
tasks.withType( JavaCompile ) {
// To enable argument names in reporting and debugging
options.compilerArgs += "-parameters"
}
build {
doFirst {
def propertiesFile = sourceSets.client.allSource.filter(f -> f.path.contains(".properties")).getSingleFile()
propertiesFile.text = propertiesFile.text.replaceAll("version=.+", "version=" + version)
propertiesFile = sourceSets.daemon.allSource.filter( f -> f.path.contains(".properties") ).getSingleFile()
propertiesFile.text = propertiesFile.text.replaceAll( "version=.+", "version=" + version )
}
}
task clientJar ( type: Jar ) {
doFirst {
def propertiesFile = sourceSets.client.allSource.filter( f -> f.path.contains(".properties") ).getSingleFile()
propertiesFile.text = propertiesFile.text.replaceAll( "version=.+", "version=" + version )
}
manifest {
attributes "Implementation-Title": "Ranflood Client Jar Package",
"Implementation-Version": version,
'Main-Class': 'org.ranflood.client.Ranflood'
}
archiveBaseName.set( "ranflood" )
from sourceSets.client.output
from {
sourceSets.client.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
task daemonJar ( type: Jar ) {
doFirst {
def propertiesFile = sourceSets.daemon.allSource.filter( f -> f.path.contains(".properties") ).getSingleFile()
propertiesFile.text = propertiesFile.text.replaceAll( "version=.+", "version=" + version )
}
manifest {
attributes "Implementation-Title": "Ranflood Daemon Jar Package",
"Implementation-Version": version,
'Main-Class': 'org.ranflood.daemon.Ranflood'
}
archiveBaseName.set( "ranfloodd" )
from sourceSets.daemon.output
from {
sourceSets.daemon.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
task filecheckerJar ( type: Jar ) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes "Implementation-Title": "Filechecker",
"Implementation-Version": "0.3",
'Main-Class': 'org.ranflood.filechecker.FileChecker'
}
archiveBaseName.set( "filechecker" )
from sourceSets.filechecker.output
from {
sourceSets.filechecker.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
jar {
enabled = false // this avoids creating an empty "project" jar file
finalizedBy clientJar
finalizedBy daemonJar
}
def genCompileOptions( String imageName, String mainClass, FileCollection classPath, Set<String> buildArgs ){
def defaultTask = tasks.withType( BuildNativeImageTask ).findByName( 'nativeCompile' )
def options = defaultTask.options.get() as NativeImageCompileOptions
options.setImageName( imageName )
options.setMainClass( mainClass )
// options.setClasspath( classPath )
options.setUseFatJar( true )
buildArgs.forEach { a -> options.buildArgs.add( a ) }
return options
}
tasks.register('generatePicocliAnnotations', Exec) {
group = "build"
description = "Generate picocli configuration file for native image"
commandLine 'java', '-cp', sourceSets.client.runtimeClasspath.toList().join( File.pathSeparator ), 'picocli.codegen.aot.graalvm.ReflectionConfigGenerator', 'org.ranflood.client.Ranflood'
standardOutput = new ByteArrayOutputStream()
doLast {
def outputFile = new File( "build/config/reflection.json" )
outputFile.parentFile.mkdirs()
outputFile.text = standardOutput.toString()
}
}
tasks.register( "daemonNativeImage", BuildNativeImageTask ){
dependsOn daemonJar
outputDirectory.set( new File( rootProject.layout.buildDirectory.asFile.get(), 'graal' ) )
classpathJar = new File( "build/libs/ranfloodd.jar" )
options.set( genCompileOptions(
"ranfloodd",
"org.ranflood.daemon.Ranflood",
sourceSets.daemon.runtimeClasspath,
Set.of( "-H:IncludeResources=.*/*.properties",
"-march=compatibility",
"-H:ReflectionConfigurationFiles=" +
[ "jni-config", "reflect-config" ]
.collect{ e -> rootProject.layout.projectDirectory.file( "native-config/" + e + ".json" ) }
.join( "," )
)
) as NativeImageOptions )
}
tasks.register( "clientNativeImage", BuildNativeImageTask ){
dependsOn clientJar
dependsOn tasks.named( "generatePicocliAnnotations" )
outputDirectory.set( new File( rootProject.layout.buildDirectory.asFile.get(), 'graal' ) )
classpathJar = new File( "build/libs/ranflood.jar" )
options.set( genCompileOptions(
"ranflood",
"org.ranflood.client.Ranflood",
sourceSets.client.runtimeClasspath,
Set.of( "-H:IncludeResources=.*/*.properties",
"-march=compatibility",
"-H:ReflectionConfigurationFiles=" + rootProject.layout.buildDirectory.file( "config/reflection.json" ).get() )
) as NativeImageOptions )
}