blob: de8ac77d6e6e12aa6baad9787c94e8e9784daded [file] [log] [blame]
David Morgan Spenser Savage97599032009-09-18 15:47:02 +00001import java.util.jar.JarFile
2
3def 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
21def findJars(dir,closure) {
22 dir.eachFileRecurse() { f ->
23 if (f ==~ /.*jar$/) closure( f )
24 }
25}
26
27
28def 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
44args.each{ ant.echo(message:it) }
45
46def dir = new File( args[0] )
47def site = new File( args[1] )
48
49generateUpdateSite(dir, site)