-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
103 lines (91 loc) · 3.37 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
plugins {
id 'biz.aQute.bnd.builder' version '3.3.0'
}
sourceCompatibility = '1.8'
version = '0.2'
repositories {
maven { url "http://repo.dotcms.com/artifactory/libs-release" }
}
dependencies {
compile('com.dotcms:dotcms:22.10') { transitive = true }
}
import java.util.jar.*
/////////////////////////
//Plugin jar
/////////////////////////
jar {
manifest {
attributes (
'Bundle-Vendor': 'dotCMS',
'Bundle-Description': 'dotCMS - Salesforce Web to Leads Actionlet',
'Bundle-DocURL': 'https://dotcms.com/',
'Bundle-Activator': 'com.dotcms.plugin.salesforce.webtoleads.osgi.Activator',
'Import-Package': '*;version=0'
)
}
}
jar.finalizedBy 'fragmentJar'
/////////////////////////
//Fragment jar
/////////////////////////
ext {
bundleName = "dotCMS Salesforce Web to Leads Actionlet fragment"
bundleDescription = "dotCMS - OSGI Salesforce Web to Leads Actionlet example fragment"
fragmentHost = "system.bundle; extension:=framework"
bundleSymbolicName = "" //Auto generated based on the plugin jar
bundleVersion = "" //Auto generated based on the plugin jar
importPackage = "" //Auto generated based on the plugin jar
bundleManifestVersion = "" //Auto generated based on the plugin jar
bundleDocURL = "" //Auto generated based on the plugin jar
bundleVendor = "" //Auto generated based on the plugin jar
}
/**
* The import generates versions like this: version="[1.8,2)"
* That format does not work for the export, so we need to replace it
* to: version=0
*/
ext.fixVersionNumber = {importValue ->
return importValue.replaceAll("\"\\[[0-9.,]+\\)\"", "0")
}
/**
* Reads the Manifest file of the just created plugin jar in order to get the required info
* to automatically create the fragment jar.
*/
task readManifesttAttributes {
doFirst {
File file = configurations.baseline.singleFile
JarFile jar = new JarFile(file)
Attributes manifest = jar.getManifest().getMainAttributes()
bundleSymbolicName = "${manifest.getValue('Bundle-SymbolicName')}"
bundleVersion = "${manifest.getValue('Bundle-Version')}"
importPackage = "${manifest.getValue('Import-Package')}"
bundleManifestVersion = "${manifest.getValue('Bundle-ManifestVersion')}"
bundleDocURL = "${manifest.getValue('Bundle-DocURL')}"
bundleVendor = "${manifest.getValue('Bundle-Vendor')}"
}
}
task fragmentJar(type: Jar) {
doFirst {
//Setting the fragment jar name
baseName = project.name
archiveName = "${baseName}.fragment-${version}.jar"
importPackage = fixVersionNumber(importPackage)
manifest {
attributes (
'Bundle-Name': "${bundleName}",
'Bundle-Description': "${bundleDescription}",
'Bundle-Vendor': "${bundleVendor}",
'Bundle-Version': "${version}",
'Bundle-SymbolicName': "${baseName}.fragment",
'Bundle-ManifestVersion': "${bundleManifestVersion}",
'Bundle-DocURL': "${bundleDocURL}",
'Fragment-Host': "${fragmentHost}",
'Export-Package': "${importPackage}"
)
}
}
}
fragmentJar.dependsOn 'readManifesttAttributes'
task wrapper(type: Wrapper) {
gradleVersion = '4.10.2'
}