This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
150 lines (112 loc) · 4.13 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
plugins {
id 'java'
id 'application'
id "com.github.johnrengelman.shadow" version "4.0.4"
}
apply from: 'https://raw.githubusercontent.com/ExplorViz/gradle-script-plugins/master/microservice.gradle'
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
ext {
expSharedVersion = "v1.3.12"
}
dependencies {
implementation "com.github.explorviz.explorviz-backend-shared:security:${expSharedVersion}"
implementation "com.github.explorviz.explorviz-backend-shared:config-injection:${expSharedVersion}"
implementation "com.github.explorviz.explorviz-backend-shared:common-concerns:${expSharedVersion}"
implementation "com.github.explorviz.explorviz-backend-shared:exception-handling:${expSharedVersion}"
implementation "com.github.explorviz.explorviz-backend-shared:user:${expSharedVersion}"
implementation "com.github.explorviz.explorviz-backend-shared:landscape-model:${expSharedVersion}"
// Local linking of external project dependency instead of Jitpack
//implementation project(':common-concerns')
// ExplorViz landscape model
//implementation 'com.github.explorviz.explorviz-backend-shared:landscape-model:master-SNAPSHOT'
// ExplorViz security filters
//implementation 'com.github.explorviz.explorviz-backend-shared:security:master-SNAPSHOT'
// multipart/form-data type
implementation group: 'org.glassfish.jersey.media', name:'jersey-media-multipart', version:'2.26'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
// Disable standard Jar build and
// use fat-Jar instead with all dependencies
assemble.dependsOn shadowJar
jar.enabled = false
// Define the main class for the gradle jar task
jar {
manifest {
attributes(
'Main-Class': 'net.explorviz.extension.tutorial.main.Main'
)
}
}
// Define the main class for the gradle application tasks
application {
mainClassName = 'net.explorviz.extension.tutorial.main.Main'
}
shadowJar {
archiveName = "${project.name}.${extension}"
}
// Renaming Dummy task
// Run with ./gradlew renameProject -PextensionName="X"
task renameProject() {
if (project.hasProperty('extensionName')) {
// temporary dir for modification (needed for Win OS based on current gradle implementation)
def tmpDir = 'tmp'
// default src dir
def srcDir = 'src'
// default base dir
def baseDir = '.'
// Rename dummy package and replace dummy string import declarations
def newExtensionName = project.property('extensionName')
def javaSrcDir = srcDir + '/main/java/net/explorviz/extension/'
println("Trying to rename backend extension from dummy to: " + newExtensionName)
// initial setup
// copy src folder to tmp dir for modification
copy {
from srcDir
into tmpDir + '/' + srcDir
}
// delete old src folder
delete srcDir
// Rename dummy package and replace dummy string import declarations
copy {
from tmpDir + '/' + javaSrcDir + 'dummy'
filter{it.replaceAll("\\.dummy\\.", "\\." + newExtensionName + "\\.")}
into javaSrcDir + newExtensionName
}
// Replace dummy string in .project
String file = new File(".project").getText("UTF-8")
file = file.replaceAll("-dummy", "-" + newExtensionName)
new File(tmpDir + '/' + ".project").write(file, "UTF-8")
// Replace dummy string in settings.gradle
file = new File("settings.gradle").getText("UTF-8")
file = file.replaceAll("-dummy", "-" + newExtensionName)
new File(tmpDir + '/' + "settings.gradle").write(file, "UTF-8")
// Replace dummy string in build.gradle
file = new File("build.gradle").getText("UTF-8")
file = file.replaceAll("extension.tutorial", "extension." + newExtensionName)
new File(tmpDir + '/' + "build.gradle").write(file, "UTF-8")
// java src files
copy {
from tmpDir + '/' + srcDir
into srcDir
}
// .project + settings.gradle
copy {
from tmpDir
into baseDir
include '.project'
include 'settings.gradle'
include 'build.gradle'
}
//cleanup
delete javaSrcDir + '/dummy'
delete tmpDir
println("Backend extension renamed to: " + newExtensionName)
}
}