Last active
October 1, 2018 16:39
-
-
Save dsdstudio/5054347 to your computer and use it in GitHub Desktop.
gradle -> felix-ipojo bytecode manipulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
} |
Author
dsdstudio
commented
Feb 28, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment