Guest User

Untitled

a guest
Sep 9th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.08 KB | None | 0 0
  1. def ant = new AntBuilder();   // create an antbuilder
  2. def contentJar = "target/site/content.jar"
  3. def contentDir = "target/content.jar/"
  4. println 'unzipping content.jar'
  5. ant.unzip(  src: contentJar, dest:contentDir,  overwrite:"true")
  6. println ' Doing some black magic'
  7. def contentJar2 = "target/site/content2.jar"
  8.  
  9. File contentXml =  new File(contentDir, "content.xml")
  10. def root = new XmlParser().parseText(contentXml.text)
  11.  
  12. def feature = root.units.unit.find{ it.@id=="org.eclipse.m2e.wtp.feature.feature.group"}
  13. def version = feature.@version
  14. println "found " + feature.@id + '-' + version
  15.  
  16. def matchDefinition = "providedCapabilities.exists(pc | pc.namespace == 'org.eclipse.equinox.p2.iu' && (pc.name == 'org.maven.ide.wtp' || pc.name == 'org.eclipse.m2e.wtp' && pc.version > '${version}'))"
  17. println matchDefinition
  18.  
  19. feature.update.@match = matchDefinition
  20.  
  21. def writer = new StringWriter()
  22. new XmlNodePrinter(new PrintWriter(writer)).print(root)
  23. contentXml.write(writer.toString())
  24.  
  25. println 'zipping customized content.jar'
  26. ant.zip(  destFile: contentJar2, baseDir:contentDir)
Add Comment
Please, Sign In to add comment