# OSGi PLugin Example Help

**URL:** <https://discuss.gradle.org/t/osgi-plugin-example-help/5674>\
**Category:** Old Forum Archive\
**Created:** [November 14, 2013, 10:05pm UTC](https://discuss.gradle.org/t/osgi-plugin-example-help/5674 "2013-11-14T22:05:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Tesser](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jason_tesser/32/241_2.png) [@Jason\_Tesser](https://discuss.gradle.org/u/Jason_Tesser)\
**Post date:** [November 14, 2013, 10:05pm UTC](https://discuss.gradle.org/t/osgi-plugin-example-help/5674/1 "2013-11-14T22:05:00Z")

</div>

how can I generate the manifest here WITHOUT building the JAR [http://www.gradle.org/docs/current/userguide/osgi\_plugin.html](http://www.gradle.org/docs/current/userguide/osgi_plugin.html)

I want to do this so I can alter the generated MANIFEST and THEN JAR

How can I manipulate the file. I need to replace some text

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [November 19, 2013, 2:31pm UTC](https://discuss.gradle.org/t/osgi-plugin-example-help/5674/2 "2013-11-19T14:31:00Z")

</div>

There’s no simple way to do this. Exactly what do you need to change?

---

<div class="post-metadata">

**Author:** ![Jason\_Tesser](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jason_tesser/32/241_2.png) [@Jason\_Tesser](https://discuss.gradle.org/u/Jason_Tesser)\
**Post date:** [November 19, 2013, 2:34pm UTC](https://discuss.gradle.org/t/osgi-plugin-example-help/5674/3 "2013-11-19T14:34:00Z")

</div>

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](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’)

}

}

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [November 19, 2013, 2:37pm UTC](https://discuss.gradle.org/t/osgi-plugin-example-help/5674/4 "2013-11-19T14:37:00Z")

</div>

That’s about the best I’d be able to come up with. Nice work.
