-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
714 lines (643 loc) · 23.3 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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
import org.gradle.api.tasks.testing.logging.TestLogEvent
import io.vproxy.base.util.OS
buildscript {
dependencies {
classpath group: 'io.vproxy', name: 'commons', version: '1.2.1'
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'me.champeau.jmh' version "0.7.1" apply false
id 'org.jetbrains.kotlin.jvm' version '2.0.0' apply false
}
def JDK_VERSION = loadMajorVersion()
println("using java $JDK_VERSION to compile")
group = 'io.vproxy'
version = loadVersion()
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation project(":pni")
}
java {
sourceCompatibility = JDK_VERSION
targetCompatibility = JDK_VERSION
}
jar {
archiveFileName = 'pni.jar'
manifest {
attributes 'Main-Class': 'io.vproxy.pni.exec.Main'
}
}
shadowJar {
archiveBaseName = 'pni'
archiveClassifier = ''
archiveVersion = ''
}
task nativeImage(type: Exec) {
if (OS.isWindows()) {
executable 'native-image.cmd'
} else {
executable 'native-image'
}
def output = 'pni'
if (!OS.isWindows()) {
output += '.run'
}
args '-jar', './build/libs/pni.jar', '--no-fallback', '-o', output
dependsOn shadowJar
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
group 'io.vproxy'
version rootProject.version
if (project.name == 'pni') {
java {
sourceCompatibility = '11'
targetCompatibility = '11'
}
} else {
java {
sourceCompatibility = JDK_VERSION
targetCompatibility = JDK_VERSION
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
if (project.name != 'pni') {
if (JDK_VERSION == 21) {
options.compilerArgs += '--enable-preview'
}
}
}
tasks.withType(JavaExec) {
if (project.name != 'pni') {
if (JDK_VERSION == 21) {
jvmArgs += '--enable-preview'
}
jvmArgs += '--enable-native-access=ALL-UNNAMED'
}
}
tasks.withType(Test) {
if (project.name != 'pni') {
if (JDK_VERSION == 21) {
jvmArgs += '--enable-preview'
}
jvmArgs += '--enable-native-access=ALL-UNNAMED'
}
testLogging {
events TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.STARTED
maxGranularity 100
exceptionFormat "full"
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
}
}
repositories {
mavenLocal()
mavenCentral()
}
task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from "$buildDir/docs/javadoc"
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
java {
withSourcesJar()
}
def projects = ['api', 'graal', 'pni']
if (JDK_VERSION != 21) {
projects.remove('pni')
}
if (['api', 'graal', 'pni'].contains(project.name)) {
def releaseName = ""
def pomName = ""
if (project.name == 'api') {
releaseName = 'pni-api-jdk'+JDK_VERSION
pomName = "pni"
} else if (project.name == 'graal') {
releaseName = 'pni-api-graal' + (JDK_VERSION == 21 ? '' : ('-jdk' + JDK_VERSION))
pomName = 'pni.graal'
} else {
releaseName = 'pni-exec'
pomName = "pni.exec"
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifactId releaseName
artifact(javadocJar)
pom {
name = 'io.vproxy.' + pomName
description = 'panama native interface ' + releaseName
url = 'https://vproxy.io'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/vproxy-tools/panama-native-interface/blob/master/LICENSE'
}
}
developers {
developer {
id = 'wkgcass'
name = 'K.G. Wang'
email = 'wkgcass@hotmail.com'
}
}
scm {
connection = 'scm:git:git://github.com/vproxy-tools/panama-native-interface.git'
developerConnection = 'scm:git:git://github.com/vproxy-tools/panama-native-interface.git'
url = 'https://github.com/vproxy-tools/panama-native-interface'
}
}
}
}
repositories {
maven {
credentials {
username 'XthxH9RF'
password System.getProperty("MavenPublishPassword")
}
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
url = version.contains('-DEV') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
if (!System.getProperty("MavenLocalInstall", "false").equals("true")) {
signing {
sign publishing.publications.maven
}
}
}
}
static def bashPath() {
def bashPath = System.getenv("MINGW_BASH")
if (bashPath == null)
return "/bin/bash"
return bashPath
}
project(":api") {
def jdk21 = 'src/main/jdk21'
def jdk22 = 'src/main/jdk22'
sourceSets {
main {
java {
if (JDK_VERSION == 21) {
srcDirs = ['src/main/java', jdk21]
} else {
srcDirs = ['src/main/java', jdk22]
}
}
}
}
task compileLib(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
executable bashPath()
args './make.sh'
}
}
static def graalVersion() {
return '1.2.1'
}
project(":graal") {
dependencies {
api project(':api')
compileOnly group: 'io.vproxy', name: 'graal-sdk-mock-nativeimage', version: graalVersion()
}
}
project(":pni") {
dependencies {
implementation 'io.vproxy:commons:1.2.1'
implementation 'org.ow2.asm:asm:9.7'
implementation 'org.ow2.asm:asm-tree:9.7'
}
}
project(":unittest") {
dependencies {
implementation project(":api")
implementation project(":pni")
testImplementation 'io.vproxy:commons:1.2.1'
testImplementation 'junit:junit:4.13.2'
}
task runUnitTest(type: Test) {
jvmArgs += '-Djava.library.path=' +
project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
include '**/Suite.class'
dependsOn project(':api').tasks.compileLib
}
}
project(":acceptance-testing-template") {
apply plugin: 'org.jetbrains.kotlin.jvm'
compileJava {
options.compilerArgs += '-parameters'
}
compileKotlin {
kotlinOptions {
jvmTarget = JDK_VERSION
javaParameters = true
}
}
dependencies {
implementation project(":api")
}
task cleanAcceptanceTesting1(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/acceptance-testing/src/test/'
commandLine bashPath(), '-c', 'rm -f c/libpnitest.dylib && rm -f c/libpnitest.so && rm -f c/pnitest.dll && rm -rf c-generated/* && rm -rf generated/*'
}
task cleanAcceptanceTesting2(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/graal-test/src/main/'
commandLine bashPath(), '-c', 'rm -rf c-generated-2/* && rm -rf generated-2/* && rm -rf java-2/*'
}
task cleanAcceptanceTesting {
dependsOn cleanAcceptanceTesting1
dependsOn cleanAcceptanceTesting2
}
task generateAcceptanceTesting1(type: JavaExec) {
classpath = project(":pni").sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.exec.Main'
systemProperty("io.vproxy.pni.Testing", "true")
workingDir project.rootProject.rootDir.getAbsolutePath()
args '-d', 'acceptance-testing/src/test/generated', '-h', 'acceptance-testing/src/test/c-generated',
'-cp', 'acceptance-testing-template/build/classes/java/main',
'-cp', 'acceptance-testing-template/build/classes/kotlin/main',
'-ftype-name-prefix=PNI',
'-frelease-pni-h-file',
'-frelease-pni-c-file',
'-frelease-jni-h-mock-file'
dependsOn cleanAcceptanceTesting1
dependsOn compileJava
dependsOn compileKotlin
}
task generateAcceptanceTesting2(type: JavaExec) {
classpath = project(":pni").sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.exec.Main'
systemProperty("io.vproxy.pni.Testing", "true")
workingDir project.rootProject.rootDir.getAbsolutePath()
args '-d', 'graal-test/src/main/generated-2', '-h', 'graal-test/src/main/c-generated-2',
'-cp', 'acceptance-testing-template/build/classes/java/main',
'-cp', 'acceptance-testing-template/build/classes/kotlin/main',
'-fgraal-native-image-feature=io.vproxy.pni.test.Feature',
'-fgraal-c-entrypoint-literal-upcall',
'-ftype-name-prefix=PNI',
'-frelease-pni-h-file=graal-test/src/main/c-generated',
'-frelease-pni-c-file=graal-test/src/main/c-generated',
'-frelease-jni-h-mock-file=graal-test/src/main/c-generated',
'-fdisable-allow-heap-access' // TODO currently graal native-image does not support this feature
dependsOn cleanAcceptanceTesting2
dependsOn compileJava
dependsOn compileKotlin
}
task generateAcceptanceTesting {
dependsOn generateAcceptanceTesting1
dependsOn generateAcceptanceTesting2
}
}
project(":acceptance-testing") {
sourceSets {
test {
java {
srcDirs = ['src/test/java', 'src/test/generated']
}
}
}
dependencies {
implementation project(":api")
implementation project(":graal")
testImplementation 'io.vproxy:commons:1.2.1'
testImplementation 'junit:junit:4.13.2'
testImplementation group: 'io.vproxy', name: 'graal-sdk-mock-runtime', version: graalVersion()
}
task compilePNITestLib(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/acceptance-testing/src/test/c'
executable bashPath()
args './make-test.sh'
dependsOn project(':acceptance-testing-template').tasks.generateAcceptanceTesting
}
task runAcceptanceTest(type: Test) {
jvmArgs += '-Djava.library.path=' +
project.rootProject.rootDir.getAbsolutePath() + '/acceptance-testing/src/test/c' +
File.pathSeparator +
project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
jvmArgs += '--add-opens'
jvmArgs += 'java.base/java.io=ALL-UNNAMED'
include '**/Suite.class'
dependsOn compilePNITestLib
dependsOn compileTestJava
}
}
project(":graal-test-template") {
compileJava {
options.compilerArgs += '-parameters'
}
dependencies {
implementation project(":api")
}
task cleanGraalTesting(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/graal-test/src/main/'
commandLine bashPath(), '-c', 'rm -f c/libgraaltest.dylib && rm -f c/libgraaltest.so && rm -f c/graaltest.dll && rm -rf c-generated/* && rm -rf generated/*'
}
task generateGraalTesting(type: JavaExec) {
classpath = project(":pni").sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.exec.Main'
systemProperty("io.vproxy.pni.Testing", "true")
workingDir project.rootProject.rootDir.getAbsolutePath()
args '-cp', 'graal-test-template/build/classes/java/main', '-d', 'graal-test/src/main/generated', '-h', 'graal-test/src/main/c-generated',
'-fgraal-native-image-feature=io.vproxy.pni.graal.test.Feature',
'-fgraal-c-entrypoint-literal-upcall',
'-ftype-name-prefix=PNI',
'-frelease-pni-h-file',
'-frelease-pni-c-file',
'-frelease-jni-h-mock-file'
dependsOn cleanGraalTesting
dependsOn compileJava
}
}
project(":graal-test") {
apply plugin: 'com.github.johnrengelman.shadow'
sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src/main/generated', 'src/main/java-2', 'src/main/generated-2']
}
}
}
dependencies {
implementation project(":api")
implementation project(":graal")
implementation 'io.vproxy:commons:1.2.1'
implementation 'junit:junit:4.13.2'
compileOnly group: 'io.vproxy', name: 'graal-sdk-mock-nativeimage', version: graalVersion()
runtimeOnly group: 'io.vproxy', name: 'graal-sdk-mock-runtime', version: graalVersion()
}
shadowJar {
archiveFileName.set('graal-test.jar')
}
jar {
manifest {
attributes 'Main-Class': 'io.vproxy.pni.graal.test.Main'
}
}
task copyAcceptanceTestingToGraal(type: Copy) {
from project.rootProject.rootDir.getAbsolutePath() + '/acceptance-testing/src/test/java'
into project.rootProject.rootDir.getAbsolutePath() + '/graal-test/src/main/java-2'
compileJava.mustRunAfter(copyAcceptanceTestingToGraal)
}
task compileGraalTestLib(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/graal-test/src/main/c'
executable bashPath()
args './make-graal-test.sh'
dependsOn project(':acceptance-testing-template').tasks.generateAcceptanceTesting
dependsOn project(':graal-test-template').tasks.generateGraalTesting
compileGraalTestLib.mustRunAfter(project(':acceptance-testing-template').tasks.cleanAcceptanceTesting)
}
task compileGraalTest(type: Exec) {
if (OS.isWindows()) {
executable 'native-image.cmd'
} else {
executable 'native-image'
}
def output = 'graal-test'
if (!OS.isWindows()) {
output += '.run'
}
def argList = ['-jar', './build/libs/graal-test.jar',
'--features=io.vproxy.pni.graal.test.Feature2,io.vproxy.pni.test.Feature,io.vproxy.pni.graal.test.Feature',
'--add-opens', 'java.base/java.io=ALL-UNNAMED',
'--enable-native-access=ALL-UNNAMED', '-ea',
'-Ob', '--no-fallback']
if (JDK_VERSION == 21) {
argList << '--enable-preview'
} else {
argList << '-H:+UnlockExperimentalVMOptions' << '-H:+ForeignAPISupport'
}
argList << '-o' << output
args = argList
dependsOn copyAcceptanceTestingToGraal
dependsOn compileGraalTestLib
dependsOn project(':graal-test-template').tasks.generateGraalTesting
dependsOn shadowJar
shadowJar.mustRunAfter(project(':graal-test-template').tasks.generateGraalTesting)
}
task runGraalTest(type: Exec) {
if (OS.isWindows()) {
executable project.rootProject.projectDir.getAbsolutePath() + '/graal-test/graal-test.exe'
} else {
executable project.rootProject.projectDir.getAbsolutePath() + '/graal-test/graal-test.run'
}
workingDir project.rootProject.projectDir.getAbsolutePath() + '/acceptance-testing'
args '-Djava.library.path=' + project.rootProject.projectDir.getAbsolutePath() + '/graal-test/src/main/c' +
File.pathSeparator +
project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
dependsOn compileGraalTest
dependsOn compileGraalTestLib
}
}
project(":sample") {
apply plugin: 'com.github.johnrengelman.shadow'
jar {
manifest {
attributes 'Main-Class': 'io.vproxy.pni.sample.Main'
}
}
shadowJar {
archiveFileName.set('sample.jar')
}
compileJava {
options.compilerArgs += '-parameters'
}
dependencies {
implementation project(":api")
implementation project(":graal")
compileOnly group: 'io.vproxy', name: 'graal-sdk-mock-nativeimage', version: graalVersion()
runtimeOnly group: 'io.vproxy', name: 'graal-sdk-mock-runtime', version: graalVersion()
}
task generateSample(type: JavaExec) {
classpath = project(":pni").sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.exec.Main'
systemProperty("io.vproxy.pni.Testing", "true")
workingDir project.rootProject.rootDir.getAbsolutePath()
args '-cp', 'sample/build/classes/java/main', '-d', 'sample/src/main/java', '-h', 'sample/src/main/c',
'-fgraal-native-image-feature=io.vproxy.pni.sample.Feature',
'-ftype-name-prefix=PNI',
'-frelease-pni-h-file',
'-frelease-pni-c-file',
'-frelease-jni-h-mock-file'
dependsOn compileJava
}
task compilePNISampleLib(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/sample/src/main/c'
executable bashPath()
args './make-sample.sh'
dependsOn generateSample
}
task runSample(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.sample.Main'
jvmArgs += '-Djava.library.path=' +
project.rootProject.rootDir.getAbsolutePath() + '/sample/src/main/c' +
File.pathSeparator +
project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
dependsOn compileJava
dependsOn compilePNISampleLib
}
task sampleNativeImage(type: Exec) {
if (OS.isWindows()) {
executable 'native-image.cmd'
} else {
executable 'native-image'
}
def output = 'sample'
if (!OS.isWindows()) {
output += '.run'
}
def argList = ['-jar', './build/libs/sample.jar', '--features=io.vproxy.pni.sample.Feature',
'--enable-native-access=ALL-UNNAMED',
'-Ob', '--no-fallback']
if (JDK_VERSION == 21) {
argList << '--enable-preview'
} else {
argList << '-H:+UnlockExperimentalVMOptions' << '-H:+ForeignAPISupport'
}
argList << '-o' << output
args = argList
dependsOn compilePNISampleLib
dependsOn shadowJar
shadowJar.mustRunAfter(compilePNISampleLib)
}
task runSampleNativeImage(type: Exec) {
if (OS.isWindows()) {
executable project.projectDir.getAbsolutePath() + '/sample.exe'
} else {
executable './sample.run'
}
args '-Djava.library.path=./src/main/c' +
File.pathSeparator +
project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
dependsOn sampleNativeImage
}
}
project(":playground") {
sourceSets {
main {
java {
srcDirs = ['src/main/template', 'src/main/java', 'src/main/generated']
}
}
}
compileJava {
options.compilerArgs += '-parameters'
}
dependencies {
implementation project(":api")
}
task generatePlayground(type: JavaExec) {
classpath = project(":pni").sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.exec.Main'
workingDir project.rootProject.rootDir.getAbsolutePath()
args '-cp', 'playground/build/classes/java/main', '-d', 'playground/src/main/generated', '-h', 'playground/src/main/c-generated',
'-ftype-name-prefix=PNI',
'-frelease-pni-h-file',
'-frelease-pni-c-file',
'-frelease-jni-h-mock-file'
dependsOn compileJava
}
task compilePNIPlaygroundLib(type: Exec) {
workingDir project.rootProject.rootDir.getAbsolutePath() + '/playground/src/main/c'
executable bashPath()
args './make-playground.sh'
dependsOn generatePlayground
}
task runPlayground(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = 'io.vproxy.pni.playground.Main'
jvmArgs += '-Djava.library.path=' +
project.rootProject.rootDir.getAbsolutePath() + '/playground/src/main/c' +
File.pathSeparator +
project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c'
dependsOn compileJava
dependsOn compilePNIPlaygroundLib
}
}
project(':performance') {
apply plugin: 'me.champeau.jmh'
sourceSets {
main {
java {
srcDirs = ['src/main/java']
destinationDirectory.set(file('build/classes/java/jmh'))
}
}
}
jmhRunBytecodeGenerator {
if (JDK_VERSION == 21) {
getJvmArgs().addAll(["--enable-preview"])
}
getJvmArgs().addAll(["--enable-native-access=ALL-UNNAMED"])
dependsOn project(":api").compileLib
}
jmh {
jvmArgsAppend = ['-Djava.library.path=' + project.rootProject.rootDir.getAbsolutePath() + '/api/src/main/c']
}
dependencies {
implementation 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
implementation project(':api')
}
}
def loadMajorVersion() {
def lines = "java --version".execute().text.trim().split("\n")
if (lines.length == 0) {
return 21
}
def line = lines[0].trim()
def split = line.split(" ")
if (split.length < 2) {
return 21
}
def version = split[1]
split = version.split("\\.")
if (split.length > 0) {
version = split[0]
}
def nver = Integer.parseInt(version)
if (nver <= 21) {
nver = 21
} else {
nver = 22
}
return nver
}
def loadVersion() {
def PREFIX = "final String _VERSION_SUFFIX = \""
def SUFFIX = "\"; // _THE_VERSION_SUFFIX_"
def ver = file(projectDir.getAbsolutePath() + "/pni/src/main/java/io/vproxy/pni/exec/Main.java")
def lines = ver.getText().split("\n")
def isMavenLocalInstall = System.getProperty("MavenLocalInstall", "false").equals("true")
for (def line : lines) {
line = line.trim()
if (line.startsWith(PREFIX) && line.endsWith(SUFFIX)) {
def verstr = line.substring(PREFIX.length(), line.length() - SUFFIX.length())
if (verstr.endsWith('-DEV')) {
if (isMavenLocalInstall) {
return "MAVEN-LOCAL"
} else {
verstr = verstr + '-SNAPSHOT'
}
}
return loadMajorVersion() + "." + verstr
}
}
return "unknown"
}