-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
196 lines (166 loc) · 7.31 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
plugins {
id 'biz.aQute.bnd.builder' version '3.3.0'
}
sourceCompatibility = '1.8'
version = '24.02.29'
repositories {
maven { url "https://repo.dotcms.com/artifactory/libs-release" }
}
configurations {
osgiLibs
}
dependencies {
compile ('io.vavr:vavr:0.9.3')
compile ('com.dotcms:dotcms:23.01.12') { transitive = false }
compile ('org.opensaml:opensaml-messaging-impl:3.3.1') { transitive = false }
compile ('commons-io:commons-io:2.8.0') { transitive = false }
compile ('org.apache.servicemix.bundles:org.apache.servicemix.bundles.opensaml:3.3.1_1'){
exclude(group: 'org.apache.velocity')
exclude(group: 'commons-logging')
exclude(group: 'org.slf4j')
}
osgiLibs ('org.opensaml:opensaml-core:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-saml-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-security-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-xmlsec-impl:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-xmlsec-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-security-impl:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-messaging-impl:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-messaging-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-storage-impl:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-storage-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-xacml-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-xacml-saml-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-xacml-saml-impl:3.3.1') { transitive = false }
osgiLibs ('org.glassfish.jersey.media:jersey-media-jaxb:2.22.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-saml-impl:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-soap-api:3.3.1') { transitive = false }
osgiLibs ('org.opensaml:opensaml-soap-impl:3.3.1') { transitive = false }
osgiLibs ('joda-time:joda-time:2.9') { transitive = false }
osgiLibs ('io.dropwizard.metrics:metrics-core:3.1.2') { transitive = false }
osgiLibs ('net.shibboleth.utilities:java-support:7.3.0') { transitive = false }
osgiLibs ('org.apache.santuario:xmlsec:2.0.5') { transitive = false }
osgiLibs ('org.codehaus.woodstox:woodstox-core-asl:4.4.1') { transitive = false }
osgiLibs ('javax.xml.stream:stax-api:1.0-2') { transitive = false }
osgiLibs ('org.codehaus.woodstox:stax2-api:3.1.4') { transitive = false }
osgiLibs ('org.codehaus.woodstox:woodstox-core-asl:4.4.1') { transitive = false }
osgiLibs ('org.cryptacular:cryptacular:1.1.1') { transitive = false }
osgiLibs ('org.bouncycastle:bcprov-jdk15on:1.54') { transitive = false }
osgiLibs ('com.google.code.findbugs:jsr305:3.0.1'){ transitive = false }
compileOnly ('org.apache.felix:org.apache.felix.main:5.6.10') { transitive = false }
compileOnly ('javax.servlet:javax.servlet-api:3.1.0'){ transitive = false }
compileOnly ('org.slf4j:slf4j-api:1.7.12'){ transitive = false }
testCompile 'junit:junit:4.12'
}
import java.util.jar.*
jar.baseName = 'com.dotcms.samlbundle'
/////////////////////////
//Plugin jar
/////////////////////////
jar {
manifest {
attributes (
'Bundle-Vendor': 'dotCMS',
'Bundle-Description': 'dotCMS - SAML Provider',
'Bundle-DocURL': 'https://dotcms.com/',
'Bundle-Activator': 'com.dotcms.saml.osgi.Activator',
'Bundle-ClassPath' : "${classPathLibraries()}",
'DynamicImport-Package': '*',
'Import-Package': '''
!org.opensaml.*,
javax.annotation;version=0.0.0,
*;version=0.1
'''
)
}
}
task cleanLibFiles(type: Delete) {
delete fileTree("src/main/resources/libs").matching {
include "**/*"
}
}
task copyToLib(type: Copy) {
into "src/main/resources/libs"
from configurations.osgiLibs
}
copyToLib.dependsOn cleanLibFiles
compileJava.dependsOn copyToLib
jar.finalizedBy 'fragmentJar'
/**
* Searches for jars inside the src/main/resources/libs folder, the returned list is used for the
* Bundle-ClassPath attribute.
* @return String with the list of jars inside the src/main/resources/libs folder or empty if the
* folder does not exist or it is empty.
*/
def classPathLibraries() {
def bundleClassPath = "";
fileTree("src/main/resources/libs").filter { it.isFile() }.each { bundleClassPath += "libs/" + it.name + "," }
if (bundleClassPath != "") {
bundleClassPath = '.,' + bundleClassPath
}
return bundleClassPath
}
/////////////////////////
//Fragment jar
/////////////////////////
ext {
bundleName = "OSGI 3rd Party library fragment"
bundleDescription = "dotCMS - OSGI 3rd Party library 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 = jar.baseName
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'
}