David Morgan Spenser Savage | 9759903 | 2009-09-18 15:47:02 +0000 | [diff] [blame^] | 1 | import java.util.jar.JarFile |
| 2 | |
| 3 | def processFeature(file,writer) { |
| 4 | def jar = new JarFile(file) |
| 5 | |
| 6 | if (jar.getEntry( "feature.xml" ) != null) { |
| 7 | def path = 'features/' + file.getName() |
| 8 | def attrs = jar.getManifest().getMainAttributes() |
| 9 | |
| 10 | def id = attrs.getValue('Bundle-SymbolicName') |
| 11 | def version = attrs.getValue('Bundle-Version') |
| 12 | |
| 13 | writer.println( ' <feature url="' + path + '" id="' + id + '" version="' + version + '">' ) |
| 14 | writer.println( ' <category name="Sigil"/>') |
| 15 | writer.println( ' </feature>' ) |
| 16 | } |
| 17 | |
| 18 | jar.close() |
| 19 | } |
| 20 | |
| 21 | def findJars(dir,closure) { |
| 22 | dir.eachFileRecurse() { f -> |
| 23 | if (f ==~ /.*jar$/) closure( f ) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | |
| 28 | def generateUpdateSite(dir,site) { |
| 29 | def writer = new PrintWriter( site ) |
| 30 | writer.println('<site>') |
| 31 | |
| 32 | findJars( dir, { f -> processFeature( f, writer ) } ) |
| 33 | |
| 34 | writer.println(' <category-def name="Sigil" label="Sigil-Core"> ') |
| 35 | writer.println(' <description>') |
| 36 | writer.println(' Sigil is an SDK for developing OSGi applications') |
| 37 | writer.println(' </description>') |
| 38 | writer.println(' </category-def>') |
| 39 | writer.println('</site>') |
| 40 | |
| 41 | writer.close() |
| 42 | } |
| 43 | |
| 44 | args.each{ ant.echo(message:it) } |
| 45 | |
| 46 | def dir = new File( args[0] ) |
| 47 | def site = new File( args[1] ) |
| 48 | |
| 49 | generateUpdateSite(dir, site) |