Skip to content

Instantly share code, notes, and snippets.

@rodolfodpk
Forked from dsdstudio/ipojo.gradle
Created January 28, 2014 04:15
Show Gist options
  • Save rodolfodpk/8662174 to your computer and use it in GitHub Desktop.
Save rodolfodpk/8662174 to your computer and use it in GitHub Desktop.
apply plugin: "osgi"
apply plugin: "java"
apply plugin: "maven"
version = "0.0.1"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.apache.felix:org.apache.felix.ipojo.manipulator:1.6.0"
}
}
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
repositories {
mavenCentral()
}
dependencies {
compile "org.apache.felix:org.apache.felix.main:4.2.0", "org.apache.felix:org.apache.felix.ipojo.annotations:1.6.0"
}
jar {
manifest {
instruction 'Export-Package','*'
}
}
jar.doLast {
org.apache.felix.ipojo.manipulator.Pojoization pojo = new org.apache.felix.ipojo.manipulator.Pojoization()
File jarfile = file(jar.archivePath)
File targetJarFile = file(jar.destinationDir.absolutePath +"/" + jar.baseName + "_out.jar")
if (!jarfile.exists()) throw new InvalidUserDataException("The specified bundle file does not exist: " + jarfile.absolutePath)
pojo.pojoization(jarfile, targetJarFile, (File) null)
pojo.getWarnings().each { s ->
println s
}
if (jarfile.delete()) {
if ( !targetJarFile.renameTo(jarfile) ) {
throw new InvalidUserDataException("Cannot rename the manipulated jar file");
}
}else {
throw new InvalidUserDataException("Cannot delete the input jar file")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment