Skip to content

Manifest expression injection

Andrey Hihlovskiy edited this page Apr 25, 2014 · 24 revisions

We already programmed manifest attributes in MANIFEST.MF. Now we will learn how to do manifest expression injection.

  1. The easiest way to do manifest expression injection is to use gradle/groovy capabilities. Edit file "tutorials/MyOsgiPlugin/build.gradle", insert code to jar/manifest:
instruction 'Project-Info', "${project.name} compiled on ${new Date()}"
  1. Invoke on command line:
gradle build
  1. Open file "tutorials/MyOsgiPlugin/build/libs/MyOsgiPlugin-1.0.0.0.jar", open "META-INF/MANIFEST.MF", it should contain:
Project-Info: MyOsgiPlugin compiled on Fri Apr 25 12:46:22 CEST 2014
  1. We can also program expression injection in MANIFEST.MF. Edit the file "tutorials/MyOsgiPlugin/src/main/resources/META-INF/MANIFEST.MF", insert code:
Project-Description: ${project.description}
  1. Edit file "tutorials/MyOsgiPlugin/build.gradle", insert code:
description = 'this is example project'
wuff {
  filterManifest = true
}
  1. Invoke on command line:
gradle build
  1. Open file "tutorials/MyOsgiPlugin/build/libs/MyOsgiPlugin-1.0.0.0.jar", open "META-INF/MANIFEST.MF", it should contain:
Project-Description: this is example project

Now we are done with programming manifests. Other tutorials are available here.

Clone this wiki locally