Well I solved it this way :-p
jar {
manifest {
name = ‘Example Custom Spring controller’
instruction ‘Private-Package’, ‘com.dotmarketing.osgi.custom.spring’
instruction ‘-includeresource’, ‘spring=spring, libs’
instruction ‘Bundle-Vendor’, ‘dotcms’
instruction ‘Bundle-Description’, 'Spring OSGi Example providing its own Spring for dotcms ’
instruction ‘Bundle-DocURL’, ‘http://www.dotcms.com’
instruction ‘Bundle-Activator’, ‘com.dotmarketing.osgi.custom.spring.Activator’
instruction ‘Bundle-ClassPath’, ‘.,libs/com.springsource.org.aopalliance-1.0.0.jar,libs/com.springsource.org.apache.commons.logging-1.1.1.jar,libs/com.springsource.org.apache.log4j-1.2.15.jar,libs/org.springframework.aop-3.1.1.RELEASE.jar,libs/org.springframework.asm-3.1.1.RELEASE.jar,libs/org.springframework.beans-3.1.1.RELEASE.jar,libs/org.springframework.context-3.1.1.RELEASE.jar,libs/org.springframework.context.support-3.1.1.RELEASE.jar,libs/org.springframework.core-3.1.1.RELEASE.jar,libs/org.springframework.expression-3.1.1.RELEASE.jar,libs/org.springframework.web-3.1.1.RELEASE.jar,libs/org.springframework.web.servlet-3.1.1.RELEASE.jar,libs/com.springsource.net.sf.cglib-2.2.0.jar,libs/com.springsource.org.codehaus.jackson-1.4.3.jar,libs/dotcms_log4j.jar’
instruction ‘DynamicImport-Package’, ‘*’
instruction ‘Import-Package’, ‘*;version=0’
} }
task removeVersionsOnManifest (dependsOn: [‘jar’]) << {
def manifest1=new java.util.jar.Manifest(new FileInputStream(‘build/tmp/jar/MANIFEST.MF’))
def imports = manifest1.getMainAttributes().find { it.key.toString()==“Import-Package” }
imports.value=imports.value.toString().replaceAll(~/;version="[([][0-9.]+,[0-9.]+[)]]"/,’’)
manifest1.write(new FileOutputStream(“build/tmp/jar/MANIFEST_NOVERSIONS.MF”)) }
task osgijar(type: Jar, dependsOn: [‘removeVersionsOnManifest’] ) {
appendix = “generatedjar”
from zipTree(jar.archivePath) // add original content
manifest {
from(‘build/tmp/jar/MANIFEST_NOVERSIONS.MF’)
}
}