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
|
apply plugin: 'osgi'
project.ext {
bundleClasspath = []
bundleName = rootProject.group
bundleVersion = buildVersion.getFullOSGIVersion()
bundleVendor = 'TMate Software'
}
def inlinedArtifacts = []
def allArtifacts = []
artifacts {
maven jar
osgi jar
}
classes << {
configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.moduleArtifacts.each { jar ->
jar.file.each {
inlinedArtifacts.add it
copy {
from zipTree(jar.file[0])
into sourceSets.main.output.classesDir
exclude 'META-INF/**'
}
}
}
configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.allModuleArtifacts.each { jar ->
jar.file.each { allArtifacts.add it }
}
allArtifacts -= inlinedArtifacts
jar.ext.bundleClasspath = []
allArtifacts.each {
jar.ext.bundleClasspath += it.name
}
}
jar {
baseName = bundleName
from allArtifacts
exclude {
return inlinedArtifacts.contains(it.file)
}
eachFile fullJarNameExpander
metaInf {
from rootProject.file('LICENSE-ANTLR.txt')
}
manifest {
attributes 'Bundle-SymbolicName': bundleName,
'Bundle-Version': bundleVersion,
'Bundle-Vendor': bundleVendor,
'Bundle-RequiredExecutionEnvironment' : 'J2SE-' + targetCompatibility
instruction 'Export-Package', '*;version=' + bundleVersion
instruction 'Import-Package', '!*'
}
} << {
def classpathValue = '.'
jar.ext.bundleClasspath.each { classpathValue += ", $it" }
ant.jar(destfile: jar.archivePath, update:true) {
delegate.manifest {
attribute(name: 'Bundle-ClassPath', value: classpathValue)
}
}
}
|