-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.gradle
772 lines (677 loc) · 31.5 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
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
import groovy.json.JsonSlurper
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.stream.Collectors
buildscript {
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath "io.github.gradle-nexus:publish-plugin:1.0.0"
classpath group: "com.jfrog.artifactory", name: 'com.jfrog.artifactory.gradle.plugin', version: '5.1.9'
classpath group: 'org.openjfx', name: 'javafx-plugin', version: '0.0.14'
}
}
plugins {
id 'idea'
id 'eclipse'
id 'java'
id 'distribution'
id 'org.openjfx.javafxplugin' version '0.0.14'
id 'com.jfrog.artifactory' version '5.1.9'
}
String buildProfile = project.getProperties().getOrDefault('buildProfile', 'opensource')
String buildTag = project.getProperties().get('buildTag')
if (buildTag != null && !buildTag.isEmpty() && buildTag != version) {
throw new GradleException('Version mismatch: ' + buildTag + ' vs ' + version)
}
if ((buildTag == null || buildTag.isEmpty()) && !version.endsWith('-SNAPSHOT')) {
version += '-SNAPSHOT'
}
def profiles = new Properties()
def parser = new JsonSlurper()
def defaults = new Properties()
file("buildProfiles/opensource.properties").withInputStream { defaults.load(it) }
if (buildProfile != 'opensource') {
file("buildProfiles/" + buildProfile + ".properties").withInputStream { profiles.load(it) }
}
else {
profiles = defaults
}
if (profiles['group'] != null) {
group = group.replace('org.openmbee', profiles['group'])
}
String buildNumber = project.hasProperty('buildNumber') ? project.getProperty('buildNumber') : System.currentTimeSeconds()
String timestamp = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm").format(LocalDateTime.now())
String[] classpathLibraries = null
if (profiles['classpathLibraries'] != null) {
classpathLibraries = profiles["classpathLibraries"].toString().split(',')
}
else {
classpathLibraries = defaults["classpathLibraries"].toString().split(',')
}
String docbookNameVersion = 'docbook-xsl-1.79.1'
String fopNameVersion = 'fop-2.9'
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
flatDir { dirs "libz" } //Put Cameo no-install and plugin zips here
ivy {
url "https://sourceforge.net/projects/docbook/files/docbook-xsl/"
patternLayout {
artifact "[revision]/[classifier].[ext]"
}
metadataSources {
artifact()
}
}
ivy { //downloading apache fop (version is defined in preimplementation)
url "https://archive.apache.org/dist/xmlgraphics/fop/binaries/"
patternLayout {
artifact "[classifier].[ext]"
}
metadataSources {
artifact()
}
//url 'https://mirror.nodesdirect.com/apache/xmlgraphics/fop/binaries/' for newer version
}
maven {
url 'https://repo.gradle.org/gradle/libs-releases-local/'
}
}
if (profiles['repositories'] != null) {
def repos = parser.parseText(profiles['repositories'].toString())
repos.each {
if (it.type == 'maven') {
def mavenRepo = it
repositories.maven {
url "${mavenRepo.url}"
if (mavenRepo.credentials == true) {
credentials {
username project.getProperties().get('artifactoryUsername').toString()
password project.getProperties().get('artifactoryPassword').toString()
}
}
}
}
if (it["type"] == 'ivy') {
def ivyRepo = it
repositories.ivy {
url "${ivyRepo.url}"
if (ivyRepo.credentials == true) {
credentials {
username project.getProperties().get('artifactoryUsername').toString()
password project.getProperties().get('artifactoryPassword').toString()
}
}
patternLayout {
artifact "${ivyRepo.layoutPattern}"
}
metadataSources {
artifact()
}
}
}
}
}
configurations {
preImplementation
distribution
testPublish
}
// In this section you declare the dependencies for your production and test code
dependencies {
// SLF4J API
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.2'
// implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21+'
// SLF4J-Log4j12
implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.2'
// implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.21+'
// JSoup
implementation group: 'org.jsoup', name: 'jsoup', version: '1.6.1'
// implementation group: 'org.jsoup', name: 'jsoup', version: '1.9.1+'
// JGraphT
implementation group: 'net.sf.jgrapht', name: 'jgrapht', version: '0.8.3'
// implementation group: 'org.jgrapht', name: 'jgrapht', version: '1.0.0+'
// JSON Simple
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
// implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1+'
// SwingX-All
implementation group: 'org.swinglabs.swingx', name: 'swingx-all', version: '1.6.4'
// implementation group: 'org.swinglabs.swingx', name: 'swingx-all', version: '1.6.5+'
// OpenCSV
implementation group: 'net.sf.opencsv', name: 'opencsv', version: '2.3'
// implementation group: 'com.opencsv', name: 'opencsv', version: '3.8+'
// Jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.3'
// JSON Patch
implementation group: "com.box", name: "json-patch", version: "1.13"
// Apache Commons-IO
implementation group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0'
//implementation group: 'commons-io', name: 'commons-io', version: '2.4'
// Apache HTTP
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.2'
// Apache Commons CLI
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
implementation group: 'com.beust', name: 'jcommander', version: '1.72'
// Test Dependencies
//testImplementation 'junit:junit:4.11'
testImplementation group: 'org.gradle', name: 'gradle-core', version: '6.1.1'
testImplementation group: 'org.gradle', name: 'gradle-base-services', version: '6.1.1'
testImplementation group: 'org.gradle', name: 'gradle-messaging', version: '6.1.1'
testImplementation group: 'org.gradle', name: 'gradle-logging', version: '6.1.1'
testImplementation group: 'org.gradle', name: 'gradle-process-services', version: '6.1.1'
testImplementation group: 'org.gradle', name: 'gradle-worker-processes', version: '6.1.1'
testImplementation group: 'org.gradle', name: 'gradle-tooling-api', version: '6.1.1'
testPublish group: 'org.openmbee.testrail', name: 'testrail-cli', version: '1.1.1'
// Other dependencies we're unable to resolve via standard repositories
// Handle build all-in-one profile workflow
if (profiles['nomagicDeps'] != null) {
def mdDeps = parser.parseText(profiles['nomagicDeps'].toString())
mdDeps.each {
def dep = it
preImplementation group: "${dep.group}", name: "${dep.name}", version: "${dep.version}", classifier: "${dep.classifier != null ? dep.classifier : ''}", ext: "${dep.ext}"
}
}
// Default Dev Workflow, this will only correctly pull from the local ./libz flatDir
else {
preImplementation group: 'com.nomagic', name: 'democsm', version: '2022xRefresh2', classifier: 'Cameo_Systems_Modeler_2022x_Refresh2_HF1_no_install', ext: 'zip'
}
preImplementation group: 'org.apache.fop', name: 'fop', version: '2.9', classifier: fopNameVersion + '-bin', ext: 'zip'
preImplementation group: 'net.sourceforge.docbook', name: 'docbook-xsl', version: '1.79.1', classifier: docbookNameVersion, ext: 'zip'
// JavaFX
distribution group: 'org.openjfx', name: 'javafx-fxml', version: '11.0.2', classifier: 'win'
distribution group: 'org.openjfx', name: 'javafx-controls', version: '11.0.2', classifier: 'win'
distribution group: 'org.openjfx', name: 'javafx-swing', version: '11.0.2', classifier: 'win'
distribution group: 'org.openjfx', name: 'javafx-fxml', version: '11.0.2', classifier: 'mac'
distribution group: 'org.openjfx', name: 'javafx-controls', version: '11.0.2', classifier: 'mac'
distribution group: 'org.openjfx', name: 'javafx-swing', version: '11.0.2', classifier: 'mac'
// This ensures classpath load order to match the MagicDraw provided order and then includes extras needed for non-OpenAPI stuff.
// This was necessary because of the Application class stubbing that was done in the chromium libraries.
implementation files(classpathLibraries.collect { 'build/dependency-cache/extracted/magicdraw/' + it })
implementation fileTree(dir: 'build/dependency-cache/extracted/magicdraw', include: ['lib/**/*.jar', 'plugins/**/*.jar'], exclude: ([classpathLibraries, ['plugins/com.nomagic.conceptmodeler/**/*jar', 'plugins/com.nomagic.magicdraw.xmiexporter/**/*jar', 'plugins/com.nomagic.collaborator.publisher/**/*.jar', 'plugins/com.nomagic.magicdraw.emfuml2xmi*/**/*.jar', 'plugins/com.nomagic.magicdraw.automaton/lib/engines/**/*.jar', 'plugins/tomsawyer/**/*.jar', 'plugins/com.intercax.syndeia.md/**/*.jar']]).flatten())
implementation fileTree(dir: 'lib', include: ['**/*.jar'])
implementation files("build/dependency-cache/extracted/fop/jars/fop-core-2.9.jar", "build/dependency-cache/extracted/fop/jars/fop-events-2.9.jar", "build/dependency-cache/extracted/fop/jars/fop-util-2.9.jar", 'build/dependency-cache/extracted/fop/jars/xmlgraphics-commons-2.9.jar')
}
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.swing' ]
platform = 'linux'
}
task extractDependencies {
configurations.preImplementation.resolvedConfiguration.resolvedArtifacts.each { artifact ->
inputs.file artifact.file
}
outputs.dir 'build/dependency-cache'
doLast {
inputs.files.each { archive ->
if (archive.getName().endsWith(fopNameVersion + '-' + fopNameVersion + '-bin.zip')) {
//extract fop zip
copy {
from zipTree(archive)
into archive.getParentFile().getAbsolutePath()
}
copy {
from fileTree(dir: archive.getParentFile().getAbsolutePath() + '/' + fopNameVersion + '/fop/build', include: '*.jar')
into 'build/dependency-cache/extracted/fop/jars'
}
copy {
from fileTree(dir: archive.getParentFile().getAbsolutePath() + '/' + fopNameVersion + '/fop/lib', include: '*.jar', exclude: 'commons*.jar')
into 'build/dependency-cache/extracted/fop/jars'
}
copy { //license3rdparty
from archive.getParentFile().getAbsolutePath() + '/' + fopNameVersion + '/LICENSE'
into 'build/dependency-cache/extracted/fop/license'
rename { String fileName -> 'apache_fop_license.txt' }
}
copy { //license3rdparty
from fileTree(dir: archive.getParentFile().getAbsolutePath() + '/' + fopNameVersion + '/fop/lib', include: '*.LICENSE.txt', exclude: 'commons*LICENSE.txt')
into 'build/dependency-cache/extracted/fop/license'
rename { String fileName -> fileName.replace(".LICENSE.txt", "_license.txt") }
}
}
else if (archive.getName().endsWith(docbookNameVersion + '-' + docbookNameVersion + '.zip')) {
copy {
from zipTree(archive)
into 'build/dependency-cache/extracted/docbook'
}
}
else {
copy {
from zipTree(archive)
into 'build/dependency-cache/extracted/magicdraw'
}
copy {
from 'build/dependency-cache/extracted/magicdraw/plugins/com.nomagic.conceptmodeler'
into 'build/tmp/com.nomagic.conceptmodeler'
}
}
}
fileTree(dir: 'build/dependency-cache/extracted/magicdraw', include: '*.zip').each { archive ->
copy {
from zipTree(archive)
into 'build/dependency-cache/extracted/magicdraw'
}
}
delete 'build/dependency-cache/extracted/magicdraw/plugins/com.nomagic.conceptmodeler'
}
}
compileJava.dependsOn extractDependencies
javadoc {
options.addStringOption("sourcepath", "")
}
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
// disable the crazy super-strict doclint tool in Java 8
//noinspection SpellCheckingInspection
options.addStringOption('Xdoclint:none', '-quiet')
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task testsJar(type: Jar, dependsOn: testClasses) {
archiveClassifier = 'tests'
from sourceSets.test.output
exclude 'org/openmbee/mdk/test/framework/**'
exclude 'org/**'
exclude 'worker/**'
}
task testsHackJar(type: Jar, dependsOn: testClasses) {
archiveClassifier = 'tests-hack'
from sourceSets.test.output
include 'org/openmbee/mdk/test/framework/**'
include 'org/**'
include 'worker/**'
manifest {
attributes(
'Main-Class': 'org.openmbee.mdk.test.framework.GradleMagicDrawLauncher'
)
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
task javadocZip(type: Zip, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
abstract class PreDist extends DefaultTask {
String humanVersion
String internalVersion
String groupName
String buildTimestamp
String descriptor
String docbookVersion
@InputDirectory
String sourceDist = 'src/main/dist'
@InputDirectory
String sourceDistTemplate = sourceDist + '/template'
@InputDirectory
String extractedCache = 'build/dependency-cache/extracted'
@OutputDirectory
String outputDir = 'build/generated-dist'
@TaskAction
void executeTask() {
project.copy {
from sourceDist
exclude sourceDistTemplate
from sourceDistTemplate
into outputDir
}
project.copy {
from project.configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.file
from project.configurations.distribution.resolvedConfiguration.resolvedArtifacts.file
from 'lib'
from project.jar
into "${outputDir}/plugins/${groupName}"
}
project.copy {
from project.getTasks().getByName('javadocZip')
into "${outputDir}/plugins/${groupName}/javadoc"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/fo"
into "${outputDir}/plugins/${groupName}/docbook-xsl/fo"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/common"
into "${outputDir}/plugins/${groupName}/docbook-xsl/common"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/COPYING"
from "${extractedCache}/docbook/" + docbookVersion + "/README"
from "${extractedCache}/docbook/" + docbookVersion + "/RELEASE-NOTES.txt"
from "${extractedCache}/docbook/" + docbookVersion + "/VERSION.xsl"
into "${outputDir}/plugins/${groupName}/docbook-xsl"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/highlighting/common.xsl"
into "${outputDir}/plugins/${groupName}/docbook-xsl/highlighting"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/html/chunker.xsl"
into "${outputDir}/plugins/${groupName}/docbook-xsl/html"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/lib/build.xml"
from "${extractedCache}/docbook/" + docbookVersion + "/lib/lib.xsl"
into "${outputDir}/plugins/${groupName}/docbook-xsl/lib"
}
project.copy {
from "${extractedCache}/docbook/" + docbookVersion + "/profiling/profile-mode.xsl"
into "${outputDir}/plugins/${groupName}/docbook-xsl/profiling"
}
//including docbook license files in the plugin directory
project.copy {
from "${extractedCache}/fop/license"
into "${outputDir}/plugins/${groupName}/license"
}
//including fop jar files in the plugin directory
project.copy {
from "${extractedCache}/fop/jars"
into "${outputDir}/plugins/${groupName}"
}
project.fileTree(dir: "${outputDir}", include: '**/*${group}*/**').each { file ->
file.renameTo(project.file(file.getAbsolutePath().replace('${group}', "${groupName}")))
}
String pluginLibraries = ''
project.fileTree(dir: "${outputDir}/plugins/${groupName}", include: '**/*.jar').each { file ->
pluginLibraries += '\t\t<library name=\"' + file.absolutePath.replace(File.separator, '/').replaceAll(~/.*build\/generated-dist\/plugins\/${groupName}\//, '') + '\"/>' + System.lineSeparator()
}
project.copy {
from "${sourceDistTemplate}/plugins/\${group}/plugin.xml"
filter { String line -> line.replace('<!-- START AUTO-GENERATED -->', '<!-- START AUTO-GENERATED -->' + System.lineSeparator() + System.lineSeparator() + pluginLibraries) }
filter { String line -> line.replace('${human.version}', humanVersion) }
filter { String line -> line.replace('${internal.version}', internalVersion) }
into "${outputDir}/plugins/${groupName}"
}
String descriptorFiles = ''
project.fileTree(dir: "${outputDir}").each { file ->
String relativePath = file.absolutePath.replace(File.separator, '/').replaceAll(/.*build\/generated-dist\//, '')
descriptorFiles += '\t\t<file from=\"' + relativePath + '\" to=\"' + relativePath + '\"/>' + System.lineSeparator()
}
project.copy {
from "${sourceDistTemplate}/data/resourcemanager/${descriptor}"
filter { String line -> line.replace('<!-- START AUTO-GENERATED -->', '<!-- START AUTO-GENERATED -->' + System.lineSeparator() + System.lineSeparator() + descriptorFiles) }
filter { String line -> line.replace('${human.version}', humanVersion) }
filter { String line -> line.replace('${internal.version}', internalVersion) }
filter { String line -> line.replace('${build.timestamp}', buildTimestamp) }
into "${outputDir}/data/resourcemanager"
}
}
}
task preDist(type: PreDist) {
humanVersion = version.endsWith('-SNAPSHOT') && buildTag != null && !buildTag.isEmpty() ? version.replace('-SNAPSHOT', '') : version
internalVersion = buildNumber
groupName = magicdDrawGroupName
buildTimestamp = timestamp
descriptor = descriptorFile
docbookVersion = docbookNameVersion
}
preDist.dependsOn jar
preDist.dependsOn javadocZip
distributions {
main {
contents {
exclude 'template'
from 'build/generated-dist'
}
}
}
tasks.withType(Tar) {
enabled = false
}
distZip {
includeEmptyDirs false
duplicatesStrategy DuplicatesStrategy.EXCLUDE
eachFile { file ->
file.setPath(path.substring(path.indexOf("/") + 1, path.length()))
}
}
distZip.dependsOn preDist
distZip.doLast {
copy {
String publishVersion = version.endsWith('-SNAPSHOT') && buildTag != null && !buildTag.isEmpty() ? version.replace('-SNAPSHOT', '') : version
from "build/distributions/mdk-${publishVersion}-*.zip"
into 'local-distributions/'
}
}
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "io.github.gradle-nexus.publish-plugin"
publishing {
// Reference to Gradle publications defined in the build script.
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact testsJar {
classifier "tests"
}
artifact javadocJar {
classifier "javadoc"
}
artifact distZip {
classifier "plugin"
}
pom {
name = project.name
description = "Cameo / Magic plugin for MMS sync and DocGen"
url = "https://www.openmbee.org/"
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'openmbee'
name = 'OpenMBEE'
}
}
scm {
connection = 'scm:git:https://github.com/Open-MBEE/mdk.git'
developerConnection = 'scm:git:https://github.com/Open-MBEE/mdk.git'
url = 'https://github.com/Open-MBEE/mdk.git'
}
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publishToSonatype") }
sign publishing.publications.mavenJava
if (project.hasProperty("signingKey") && project.hasProperty("signingPassword")) {
String signingKey = new String((project.findProperty("signingKey") as String).decodeBase64())
String signingPassword = project.findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
}
}
nexusPublishing {
repositories {
sonatype()
}
}
artifactoryPublish {
publications('mavenJava')
}
artifactoryPublish.dependsOn distZip
artifactory {
publish {
contextUrl = project.property('artifactoryUrl') as String
repository {
repoKey = project.property('artifactoryRepository')
username = project.getProperties().get('artifactoryUsername').toString()
password = project.getProperties().get('artifactoryPassword').toString()
}
}
if (buildNumber != null && !buildNumber.isEmpty()) {
clientConfig.info.setBuildNumber(buildNumber)
}
}
installDist {
destinationDir = file('build/plugin')
doLast {
copy {
fileMode 0755
from 'build/dependency-cache/extracted/magicdraw'
from 'build/plugin'
into 'build/install'
}
copy {
from 'build/tmp/com.nomagic.conceptmodeler'
into 'build/install/plugins/com.nomagic.conceptmodeler'
}
delete 'build/tmp/com.nomagic.conceptmodeler'
}
}
installDist.dependsOn distZip
task runJava(type: JavaExec) {
doFirst {
classpath files(classpathLibraries.collect { 'build/install/' + it })
}
workingDir 'build/install'
ignoreExitValue true
standardOutput = System.out
errorOutput = System.err
if (profiles["executablePath"] != null) {
executable = profiles["executablePath"]
}
debugOptions {
enabled = true
port = 31001
server = true
suspend = false
}
main = 'com.nomagic.magicdraw.Main'
jvmArgs = ['-Xmx8192M', '-Xss512M', '-DLOCALCONFIG=true', '-DWINCONFIG=true', '-Djsse.enableSNIExtension=true', '-Djava.net.preferIPv4Stack=true', '-Dcom.sun.media.imageio.disableCodecLib=true', '-noverify', '-Dlocal.config.dir.ext=-dev', '-splash:data/splash.png', '-Dmd.class.path=$java.class.path', '-Desi.system.config=data/application.conf', '-Dlogback.configurationFile=data/logback.xml', '-Dsun.locale.formatasdefault=true']
// arguments to pass to the application
args 'DEVELOPER'
}
runJava.dependsOn installDist
task testAVG(type: JavaExec) {
doFirst {
classpath files(classpathLibraries.collect { 'build/install/' + it })
}
workingDir 'build/install'
ignoreExitValue true
standardOutput = System.out
errorOutput = System.err
main = 'com.nomagic.magicdraw.Main'
jvmArgs = ['-Xmx8192M', '-Xss512M', '-DLOCALCONFIG=true', '-DWINCONFIG=true', '-Djsse.enableSNIExtension=true', '-Djava.net.preferIPv4Stack=true', '-Dcom.sun.media.imageio.disableCodecLib=true', '-noverify', '-Dlocal.config.dir.ext=-dev', '-splash:data/splash.png', '-Dmd.class.path=$java.class.path', '-Desi.system.config=data/application.conf', '-Dlogback.configurationFile=data/logback.xml', '-Dsun.locale.formatasdefault=true', '-Dcom.nomagic.magicdraw.launcher=com.nomagic.magicdraw.commandline.CommandLineActionLauncher', '-Dcom.nomagic.magicdraw.commandline.action=org.openmbee.pma.cli.AutomatedViewGenerator']
}
testAVG.dependsOn installDist
task runScript(type: Exec) {
workingDir "build/install"
ignoreExitValue = true
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'bin\\magicdraw.exe'
}
else {
commandLine 'sh', 'bin/magicdraw'
}
}
runScript.dependsOn installDist
test {
ignoreFailures = true
testLogging.showStandardStreams = true
forkEvery 1
if (profiles["executablePath"] != null) {
executable = profiles["executablePath"]
}
workingDir 'build/install'
/**
* The short version of the rationale is that with 18.4, MagicDraw introduced the OSGi framework as part of its
* implementation.
* Gradle and JUnit work very well together out of the box (generated reports in XML and HTML, tight IDE/Jenkins
* integration, etc.), and Gradle and OSGi was made to work with the runJava task.
* However, Gradle had to implement a number of hacks to overcome OS limitations and achieve features that can be
* applied to a broad range of software.
* Those hacks work well with most applications but not OSGi (commentary: OSGi doesn't play well with anyone), so
* we implemented a number of hacks ourselves.
* They involve classloading order, classpath redirection using the jar argument, reflection, and dynamic
* classloading.
* Ultimately, this enabled the use of the well-supported and feature-rich Gradle test task, but at the cost of
* an implementation that could break in the unlikely, albeit possible, case of either Gradle or MagicDraw
* significantly changing their implementations of the test and OSGi frameworks, respectively.
*
* Clears the default classpath since all the necessary libraries are being passed as arguments to
* GradleMagicDrawLauncher to be added to the OSGi classpath.
* Then it utilizes the -jar JVM argument to override the default Gradle command and pass the original command
* as arguments to the main class of the jar, GradleMagicDrawLauncher,
* including the classpath arguments (one of our own and one of Gradle's). It additionally parses and sets the
* system properties that are passed.
*
* Example command: .../java -Dcom.nomagic.osgi.config.dir=configuration -Desi.system.config=data/application.conf -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dlogback.configurationFile=data/logback.xml -Dmd.class.path=$java.class.path -jar /Users/igomes/mdk/build/libs/mdk-*-tests-hack.jar -cp ... -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp .../.gradle/caches/.../workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1'
*
* @author igomes
* TODO 2021x refresh 1 removed osgi
*/
classpath = files()
doFirst {
def arguments = ['-jar', testsHackJar.outputs.files.singleFile, '-cp',
fileTree(dir: 'build/generated-dist', include: '**/*.jar').getFiles().stream().map { i -> i.getAbsolutePath() }.collect(Collectors.joining(File.pathSeparator)) + File.pathSeparator +
/*fileTree(dir: 'build/install', include: ['plugins/** /*.jar']).asPath + */
files(classpathLibraries.collect { 'build/install/' + it }).getFiles().stream().map { i -> i.getAbsolutePath() }.collect(Collectors.joining(File.pathSeparator)) + File.pathSeparator +
configurations.testRuntimeClasspath.resolvedConfiguration.resolvedArtifacts.stream().map { i -> i.getFile().getAbsolutePath() }.collect(Collectors.joining(File.pathSeparator)) + File.pathSeparator +
testsJar.outputs.files.singleFile, '-DLOCALCONFIG=true', '-DWINCONFIG=true', '-Djsse.enableSNIExtension=true', '-Djava.net.preferIPv4Stack=true', '-Dcom.sun.media.imageio.disableCodecLib=true', '-noverify', '-Dlocal.config.dir.ext=-test', '-splash:data/splash.png', '-Dmd.class.path=$java.class.path', '-Dcom.nomagic.osgi.config.dir=configuration', '-Desi.system.config=data/application.conf', '-Dlogback.configurationFile=data/logback.xml', '-Dsun.locale.formatasdefault=true', '-Dorg.osgi.framework.bundle.parent=ext']
String magicDrawLicense = project.getProperties().get('magicDrawLicense')
if (magicDrawLicense != null && !magicDrawLicense.isEmpty()) {
new File('build/install/mdlicense.tmp').write(new String(magicDrawLicense.decodeBase64()))
}
String additionalTestArguments = project.getProperties().get('additionalTestArguments')
if (additionalTestArguments != null && !additionalTestArguments.isEmpty()) {
arguments.addAll(additionalTestArguments.split(','))
}
jvmArgs = arguments
}
}
test.dependsOn testsJar
test.dependsOn testsHackJar
test.dependsOn installDist
task testrailPublish(type: JavaExec) {
classpath configurations.testPublish
main = 'org.openmbee.testrail.cli.JUnitPublisher'
def arguments = ['--directory', 'build/test-results/test', '--milestone', version.replace('-SNAPSHOT', '')]
def s
if ((s = project.getProperties().get('testrailHost')) != null) {
arguments.addAll('--host', s)
}
if ((s = project.getProperties().get('testrailUser')) != null || (s = project.getProperties().get('testrailUsername')) != null) {
arguments.addAll('--user', s)
}
if ((s = project.getProperties().get('testrailPassword')) != null) {
arguments.addAll('--password', s)
}
if ((s = project.getProperties().get('testrailSuiteId')) != null) {
arguments.addAll('--suite-id', s)
}
if ((s = project.getProperties().get('testrailPlanId')) != null) {
arguments.addAll('--plan-id', s)
}
if ((s = project.getProperties().get('testrailRunName')) != null) {
arguments.addAll('--run-name', s)
}
if (project.getProperties().hasProperty('testrailSkipCloseRun')) {
arguments.add('--skip-close-run')
}
args arguments
standardOutput = System.out
errorOutput = System.err
}
configure(testrailPublish) {
group = 'Publishing'
description = 'Publish test results to TestRail'
}
testrailPublish.dependsOn test