This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
109 lines (101 loc) · 3.19 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
apply plugin: 'osgi'
apply plugin: 'eclipse'
apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'propdeps-eclipse'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
maven { url "http://repo.dotcms.com/artifactory/libs-release" }
}
dependencies {
compile('com.dotcms:dotcms:5.0.3')
compile('org.apache.httpcomponents:httpclient:4.5.3') {
exclude(module: 'commons-logging')
exclude(module: 'slf4j-api')
}
provided('javax.servlet:servlet-api:2.5')
}
buildscript {
repositories {
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
}
}
jar {
manifest {
name = 'Aquent PostTool'
symbolicName = 'com.aquent.plugins.posttool'
instruction 'Bundle-Vendor', 'Aquent, LLC ([email protected])'
instruction 'Bundle-Description', 'Aquent PostTool Plugin'
instruction 'Bundle-DocURL', 'http://www.aquent.com'
instruction 'Bundle-Activator', 'com.aquent.viewtools.PostToolActivator'
instruction 'Import-Package',
'!org.springframework.*',
'!org.apache.http.*',
'org.apache.commons.logging;version=0',
'javax.net.ssl',
'javax.net',
'*;version=0'
instruction 'Embed-Dependency', 'httpclient'
instruction 'Embed-Transitive', 'true'
}
}
/*
* reads the OSGI instruction "Embed-Dependency" and "Embed-Transitive"
* and sets the "Bundle-ClassPath" instruction as well as copy instruction for
* the related artifacts accordingly
*/
task processEmbedded {
doLast {
ext.embedInstruction = jar.manifest.instructions.get("Embed-Dependency")
ext.transitive = jar.manifest.instructions.get("Embed-Transitive");
if(embedInstruction != null){
def includedArtifacts = [] as Set
getDependencies(embedInstruction,transitive).each { dependency ->
dependency.moduleArtifacts.each { artifact ->
includedArtifacts.add(artifact.file)
}
}
jar.manifest.instruction("Bundle-ClassPath",'.') //add the default classpath
includedArtifacts.each { artifact ->
jar.from(artifact)
jar.manifest.instruction("Bundle-ClassPath",artifact.name)
}
}
}
}
/**
* Gets the list of ResolvedDependencies for the list of embeded dependency names
* @param embededList the list with the dependencies to embed
* @param recursive The embed transitive state
* @return the list of dependencies. An empty Set if none
*/
def getDependencies(embededList, recursive){
def dependencies = [] as Set //resolved Dependencies
def dependencyMap = [:];
// This only considers top level resolved dependencies, but other should
// not be embeded anyway.
project.configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies.each { dependency ->
dependencyMap.put(dependency.moduleName,dependency)
}
embededList.each { embeded ->
ext.dependency = dependencyMap.get(embeded)
if(dependency != null){
println "dependency "+dependency.name
dependencies.add(dependency)
if(recursive){
dependency.children.each { child ->
println " child "+child.name+" Parents: "+child.parents
dependencies.add(child)
}
}
} else {
println "WARNING: dependency "+embeded+" not found"
}
}
return dependencies
}
compileJava.dependsOn processEmbedded