forked from freeplane/freeplane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
271 lines (225 loc) · 7.85 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.0.0'
}
}
plugins {
id 'nebula.ospackage' version '8.3.0'
id 'com.github.ben-manes.versions' version '0.28.0'
id 'org.owasp.dependencycheck' version '5.3.0' apply false
}
Properties props = new Properties()
props.load(new FileInputStream(rootDir.path + '/freeplane/src/viewer/resources/version.properties'))
allprojects {
apply plugin: 'org.owasp.dependencycheck'
// in a multi-project setup, all projects must have the same version number!
// the real (specific) version number is in freeplane/viewer-resources/version.properties!
ext.majorVersion = props['freeplane_version']
ext.versionStatus = props['freeplane_version_status']
ext.minorVersion = System.getProperty('minor', '')
ext.distVersion = "$majorVersion${versionStatus.empty?'':'-'+versionStatus}${minorVersion.empty?'':'-pre' + minorVersion}"
version = ext.majorVersion
// WARNING: this is removed with "gradle clean"!!
ext.globalBin = rootDir.path + '/BIN'
repositories {
mavenCentral()
maven { url 'https://resources.knopflerfish.org/repo/maven2/release/' }
maven { url "${project.gradle.gradleUserHomeDir}/local-artifacts" }
maven { url 'https://dl.bintray.com/freeplane/freeplane' }
maven { url 'https://repo.spring.io/plugins-release/' }
// this is necessary to grab both binary and source jars
// for local (git) dependencies
flatDir name: 'localGitDepsRepository',
dirs: [rootDir.path + "/freeplane/lib",
rootDir.path + "/freeplane_plugin_jsyntaxpane/lib"]
}
}
/* this is used for (linux) packages, where the dependencies
live on the file system (/usr/share/java/*.jar on Debian): */
def externalizeJar(File jar) {
// do not externalize, jars are copied over to /BUILD
// in development workflow!
return "lib/${jar.name}"
}
// this is overridden in linux packages where this might be named
// knopflerfish-framework.jar
def isKnopflerfishJar(fileName) {
return fileName.startsWith('framework-') &&
fileName.endsWith('.jar');
}
def filterAndExternalizePluginDependencies(runtime_files) {
return runtime_files.findAll {
File file -> !isKnopflerfishJar(file.name)
}.findAll {
File file ->
file.name != "freeplane-${project.version}.jar" &&
!(file.name.startsWith('freeplane_plugin_') &&
file.name.endsWith('-' + project.version + '.jar'))
}.collect {
File file -> externalizeJar(file)
}
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
targetCompatibility='1.8'
sourceCompatibility='1.8'
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
javadoc {
options.encoding = "UTF-8"
options.docEncoding = "UTF-8"
options.charSet = "UTF-8"
enabled = false
failOnError = false
}
repositories {
maven {
url "https://repo1.maven.org/maven2"
}
}
configurations {
lib
api.extendsFrom(lib)
}
dependencies {
testImplementation 'junit:junit:4.13',
'org.hamcrest:hamcrest-all:1.3',
'org.mockito:mockito-core:3.3.1',
'org.assertj:assertj-core:3.15.0'
}
task copyEclipseSettings(type: Copy) {
from(rootDir.path + "/freeplane_framework/eclipse/settings-templates/") {
include("*.prefs")
}
into(project.file(".settings/"))
}
eclipseJdt.dependsOn copyEclipseSettings
task cleanEclipseSettings(type: Delete) {
delete(project.file(".settings"))
}
cleanEclipseJdt.dependsOn cleanEclipseSettings
if (project.hasProperty('TestLoggingFull')) {
test {
testLogging {
events "failed"
exceptionFormat "full"
}
}
}
}
// OSGi projects (/plugin/, freeplane) need this for compilation (e.g. resolve Bundle),
// and freeplane_framework needs to copy it to BUILD/framework.jar
configure(subprojects.findAll {it.name =~ /plugin/ || it.name =~ /^freeplane$/ || it.name =~ /^freeplane_framework$/}){
dependencies {
implementation group: 'org.knopflerfish.kf6', name:'framework', version: '8.0.9'
}
task cleanBUILD(type: Delete) {
delete "$buildDir/libs"
}
jar.dependsOn cleanBUILD
}
// common configuration for all OSGi projects...
configure(subprojects.findAll {it.name =~ /plugin/ || it.name =~ /^freeplane$/ }) {
apply plugin: 'biz.aQute.bnd.builder'
ext.bundleImports = 'nothing.*'
ext.bundleExports = ''
if (project.name.equals("freeplane"))
ext.pluginid = 'org.freeplane.core'
afterEvaluate {
if (it.name =~ /plugin/) {
ext.bundleDeps = filterAndExternalizePluginDependencies(configurations.lib.files)
bundleDeps.add(0, "lib/plugin-" + project.version + '.jar')
}
jar {
def bndConfiguration = [
'-savemanifest': 'build/manifest/MANIFEST.MF',
'Bundle-SymbolicName': pluginid,
'Export-Package': bundleExports.replaceAll("\\s+", ""),
'Bundle-Vendor': 'Freeplane Project',
'Import-Package': bundleImports.replaceAll("\\s+", ""),
'Bundle-Activator': bundleActivator,
'Bundle-RequiredExecutionEnvironment': 'JavaSE-1.8',
'Bundle-ClassPath': '., ' + bundleDeps.join(', ')
]
if (project.name =~ /plugin/) {
bndConfiguration << ['Require-Bundle':'org.freeplane.core']
}
bnd(bndConfiguration)
}
}
}
// common configuration for all plugins...
configure(subprojects.findAll {it.name =~ /plugin/}) {
ext.pluginid = project.name.replace("freeplane_plugin_", "org.freeplane.plugin.")
ext.bundleActivator = pluginid + ".Activator"
task copyOSGiJars(type: Copy) {
from ("$buildDir/libs") {
include("*.jar")
exclude('freeplane-' + project.version + '.jar')
exclude('freeplane_plugin_*-' + project.version + '.jar')
}
from (configurations.lib) {
include("*.jar")
}
from ('lib') {
include("*.jar")
exclude('*-sources.jar')
}
into(globalBin + '/plugins/' + pluginid + '/lib/')
}
task copyOSGiManifest(type: Copy) {
from ("$buildDir/manifest/") {
include("MANIFEST.MF")
}
into(globalBin + '/plugins/' + pluginid + '/META-INF/')
}
task copyOSGiConfig(type: Copy) {
from ("OSGI-INF")
into(globalBin + '/plugins/' + pluginid + '/OSGI-INF/')
}
build.dependsOn copyOSGiJars
build.dependsOn copyOSGiManifest
build.dependsOn copyOSGiConfig
// create a separate non-OSGi(!) jar for each plugin!
task pluginJar(type: Jar) {
archiveBaseName = 'plugin'
dependsOn classes
from (sourceSets.main.output) {
include("**")
}
// unfortunately some resource (xml,properties) files (e.g. preferences.xml in latex plugin)
// are in src/main/java...
from (sourceSets.main.allSource) {
include("**/*.xml")
include("**/*.properties")
}
includeEmptyDirs = false
// use a non-OSGi manifest (this jar is referenced from an OSGi bundle)!
manifest { }
}
// jar must execute after pluginJar so that the OSGi manifest can still be
// picked up from build/manifest
jar.dependsOn pluginJar
}
apply plugin: 'base' // necessary to get the global 'clean' task
task cleanBUILD(type: Delete) {
delete globalBin
}
clean.dependsOn(cleanBUILD)
build.dependsOn(cleanBUILD)
task check_translation {
dependsOn ':JOrtho_0.4_freeplane:check_translation'
dependsOn ':freeplane:check_translation'
}
task format_translation {
dependsOn ':JOrtho_0.4_freeplane:format_translation'
dependsOn ':freeplane:format_translation'
}
apply from: './dist.gradle'
apply from: './jdt-config.gradle'