Lines 1-11
Link Here
|
1 |
/* |
1 |
/* |
2 |
* Sun Public License Notice |
2 |
* Sun Public License Notice |
3 |
* |
3 |
* |
4 |
* The contents of this file are subject to the Sun Public License |
4 |
* The contents of this file are subject to the Sun Public License |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
6 |
* compliance with the License. A copy of the License is available at |
6 |
* compliance with the License. A copy of the License is available at |
7 |
* http://www.sun.com/ |
7 |
* http://www.sun.com/ |
8 |
* |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
Lines 22-39
Link Here
|
22 |
import org.apache.tools.ant.BuildException; |
22 |
import org.apache.tools.ant.BuildException; |
23 |
import org.apache.tools.ant.Location; |
23 |
import org.apache.tools.ant.Location; |
24 |
import org.apache.tools.ant.Project; |
24 |
import org.apache.tools.ant.Project; |
25 |
import org.apache.tools.ant.taskdefs.MatchingTask; |
25 |
import org.apache.tools.ant.Task; |
26 |
import org.apache.tools.ant.taskdefs.Jar; |
26 |
import org.apache.tools.ant.taskdefs.Jar; |
27 |
import org.apache.tools.ant.taskdefs.Zip; |
27 |
import org.apache.tools.ant.taskdefs.Zip; |
28 |
import org.apache.tools.ant.taskdefs.SignJar; |
28 |
import org.apache.tools.ant.taskdefs.SignJar; |
29 |
import org.apache.tools.ant.types.FileSet; |
29 |
import org.apache.tools.ant.types.FileSet; |
|
|
30 |
import org.apache.tools.ant.types.ZipFileSet; |
31 |
|
30 |
|
32 |
|
31 |
/** Makes a <code>.nbm</code> (<b>N</b>et<b>B</b>eans <b>M</b>odule) file. |
33 |
/** Makes a <code>.nbm</code> (<b>N</b>et<b>B</b>eans <b>M</b>odule) file. |
32 |
* |
34 |
* |
33 |
* @author Jesse Glick |
35 |
* @author Jesse Glick |
34 |
*/ |
36 |
*/ |
35 |
public class MakeNBM extends MatchingTask { |
37 |
public class MakeNBM extends Task { |
36 |
|
38 |
|
37 |
/** The same syntax may be used for either <samp><license></samp> or |
39 |
/** The same syntax may be used for either <samp><license></samp> or |
38 |
* <samp><description></samp> subelements. |
40 |
* <samp><description></samp> subelements. |
39 |
* <p>By setting the property <code>makenbm.nocdata</code> to <code>true</code>, |
41 |
* <p>By setting the property <code>makenbm.nocdata</code> to <code>true</code>, |
Lines 215-282
Link Here
|
215 |
} |
217 |
} |
216 |
return s2.toString(); |
218 |
return s2.toString(); |
217 |
} |
219 |
} |
218 |
|
220 |
|
219 |
/** <samp><signature></samp> subelement for signing the NBM. */ |
221 |
/** <samp><signature></samp> subelement for signing the NBM. */ |
220 |
public /*static*/ class Signature { |
222 |
public /*static*/ class Signature { |
221 |
public File keystore; |
223 |
public File keystore; |
222 |
public String storepass, alias; |
224 |
public String storepass, alias; |
223 |
/** Path to the keystore (private key). */ |
225 |
/** Path to the keystore (private key). */ |
224 |
public void setKeystore (File f) { |
226 |
public void setKeystore(File f) { |
225 |
keystore = f; |
227 |
keystore = f; |
226 |
} |
228 |
} |
227 |
/** Password for the keystore. |
229 |
/** Password for the keystore. |
228 |
* If a question mark (<samp>?</samp>), the NBM will not be signed |
230 |
* If a question mark (<samp>?</samp>), the NBM will not be signed |
229 |
* and a warning will be printed. |
231 |
* and a warning will be printed. |
230 |
*/ |
232 |
*/ |
231 |
public void setStorepass (String s) { |
233 |
public void setStorepass(String s) { |
232 |
storepass = s; |
234 |
storepass = s; |
233 |
} |
235 |
} |
234 |
/** Alias for the private key. */ |
236 |
/** Alias for the private key. */ |
235 |
public void setAlias (String s) { |
237 |
public void setAlias(String s) { |
236 |
alias = s; |
238 |
alias = s; |
237 |
} |
239 |
} |
238 |
} |
240 |
} |
239 |
|
241 |
|
|
|
242 |
private File productDir = null; |
240 |
private File file = null; |
243 |
private File file = null; |
241 |
private File topdir = null; |
|
|
242 |
private File manifest = null; |
244 |
private File manifest = null; |
243 |
/** see #13850 for explanation */ |
245 |
/** see #13850 for explanation */ |
244 |
private File module = null; |
246 |
private String moduleName = null; |
245 |
private String homepage = null; |
247 |
private String homepage = null; |
246 |
private String distribution = null; |
248 |
private String distribution = null; |
247 |
private String needsrestart = null; |
249 |
private String needsrestart = null; |
248 |
private Blurb license = null; |
250 |
private Blurb license = null; |
249 |
private Blurb description = null; |
251 |
private Blurb description = null; |
250 |
private Blurb notification = null; |
252 |
private Blurb notification = null; |
251 |
private Signature signature = null; |
253 |
private Signature signature = null; |
252 |
private long mostRecentInput = 0L; |
254 |
private long mostRecentInput = 0L; |
253 |
private boolean isStandardInclude = true; |
255 |
private boolean isStandardInclude = true; |
254 |
private Vector externalPackages = null; |
256 |
private Vector externalPackages = null; |
255 |
|
257 |
|
256 |
/** Include netbeans directory - default is true */ |
258 |
/** Include netbeans directory - default is true */ |
257 |
public void setIsStandardInclude(boolean isStandardInclude) { |
259 |
public void setIsStandardInclude(boolean isStandardInclude) { |
258 |
this.isStandardInclude = isStandardInclude; |
260 |
this.isStandardInclude = isStandardInclude; |
259 |
} |
261 |
} |
260 |
|
262 |
|
261 |
/** Name of resulting NBM file. */ |
263 |
/** Directory of the product's files */ |
262 |
public void setFile (File file) { |
264 |
public void setProductDir( File dir ) { |
263 |
this.file = file; |
265 |
productDir = dir; |
264 |
} |
266 |
} |
265 |
/** Top directory. |
267 |
|
266 |
* Expected to contain a subdirectory <samp>netbeans/</samp> with the |
268 |
/** Name of resulting NBM file. */ |
267 |
* desired contents of the NBM. |
269 |
public void setFile(File file) { |
268 |
* Will create <samp>Info/info.xml</samp> with metadata. |
270 |
this.file = file; |
269 |
*/ |
|
|
270 |
public void setTopdir (File topdir) { |
271 |
this.topdir = topdir; |
272 |
} |
271 |
} |
|
|
272 |
|
273 |
/** Module manifest needed for versioning. |
273 |
/** Module manifest needed for versioning. |
274 |
* @deprecated Use {@link #setModule} instead. |
274 |
* @deprecated Use {@link #setModule} instead. |
275 |
*/ |
275 |
*/ |
276 |
public void setManifest (File manifest) { |
276 |
public void setManifest(File manifest) { |
277 |
this.manifest = manifest; |
277 |
this.manifest = manifest; |
278 |
long lmod = manifest.lastModified (); |
278 |
long lmod = manifest.lastModified(); |
279 |
if (lmod > mostRecentInput) mostRecentInput = lmod; |
279 |
if (lmod > mostRecentInput) mostRecentInput = lmod; |
280 |
log(getLocation() + "The 'manifest' attr on <makenbm> is deprecated, please use 'module' instead", Project.MSG_WARN); |
280 |
log(getLocation() + "The 'manifest' attr on <makenbm> is deprecated, please use 'module' instead", Project.MSG_WARN); |
281 |
} |
281 |
} |
282 |
/** Module JAR needed for generating the info file. |
282 |
/** Module JAR needed for generating the info file. |
Lines 290-297
Link Here
|
290 |
* of what the resulting variant NBMs (or variant information within |
290 |
* of what the resulting variant NBMs (or variant information within |
291 |
* the NBM) should look like. |
291 |
* the NBM) should look like. |
292 |
*/ |
292 |
*/ |
293 |
public void setModule(File module) { |
293 |
public void setModule(String module) { |
294 |
this.module = module; |
294 |
this.moduleName = module; |
295 |
// mostRecentInput updated below... |
295 |
// mostRecentInput updated below... |
296 |
} |
296 |
} |
297 |
/** URL to a home page describing the module. */ |
297 |
/** URL to a home page describing the module. */ |
Lines 342-352
Link Here
|
342 |
} |
342 |
} |
343 |
|
343 |
|
344 |
public void execute () throws BuildException { |
344 |
public void execute () throws BuildException { |
|
|
345 |
if (productDir == null) |
346 |
throw new BuildException("must set directory of compiled product", location); |
345 |
if (file == null) |
347 |
if (file == null) |
346 |
throw new BuildException ("must set file for makenbm", location); |
348 |
throw new BuildException ("must set file for makenbm", location); |
347 |
if (manifest == null && module == null) |
349 |
if (manifest == null && moduleName == null) |
348 |
throw new BuildException ("must set module for makenbm", location); |
350 |
throw new BuildException ("must set module for makenbm", location); |
349 |
if (manifest != null && module != null) |
351 |
if (manifest != null && moduleName != null) |
350 |
throw new BuildException("cannot set both manifest and module for makenbm", location); |
352 |
throw new BuildException("cannot set both manifest and module for makenbm", location); |
351 |
|
353 |
|
352 |
File file; |
354 |
File file; |
Lines 361-373
Link Here
|
361 |
overrideURLIfNeeded() ; |
363 |
overrideURLIfNeeded() ; |
362 |
overrideLicenseIfNeeded() ; |
364 |
overrideLicenseIfNeeded() ; |
363 |
|
365 |
|
364 |
// Will create a file Info/info.xml to be stored alongside netbeans/ contents. |
366 |
File module = new File( productDir, moduleName ); |
365 |
File infodir = new File (topdir, "Info"); //NOI18N |
367 |
// Will create a file Info/info.xml to be stored in tmp |
366 |
infodir.mkdirs (); |
368 |
File infofile = null; |
367 |
File infofile = new File (infodir, "info.xml"); //NOI18N |
|
|
368 |
if (infofile.exists ()) { |
369 |
infofile.delete(); |
370 |
} |
371 |
Attributes attr = null; |
369 |
Attributes attr = null; |
372 |
if (module != null) { |
370 |
if (module != null) { |
373 |
// The normal case; read attributes from its manifest and maybe bundle. |
371 |
// The normal case; read attributes from its manifest and maybe bundle. |
Lines 423-564
Link Here
|
423 |
} catch (IOException ioe) { |
421 |
} catch (IOException ioe) { |
424 |
throw new BuildException("exception while reading " + module, ioe, location); |
422 |
throw new BuildException("exception while reading " + module, ioe, location); |
425 |
} |
423 |
} |
426 |
} // else we will read attr later if info file is out of date |
424 |
} |
427 |
boolean skipInfo = false; |
425 |
try { |
428 |
if (infofile.exists ()) { |
426 |
infofile = File.createTempFile("info",".xml"); |
429 |
// Check for up-to-date w.r.t. manifest and maybe license file. |
427 |
OutputStream infoStream = new FileOutputStream (infofile); |
430 |
long iMod = infofile.lastModified (); |
428 |
try { |
431 |
if (mostRecentInput < iMod) |
429 |
PrintWriter ps = new PrintWriter(new OutputStreamWriter(infoStream, "UTF-8")); //NOI18N |
432 |
skipInfo = true; |
430 |
// Begin writing XML. |
433 |
} |
431 |
ps.println ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //NOI18N |
434 |
if (! skipInfo) { |
432 |
ps.println("<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Autoupdate Module Info 2.0//EN\" \"http://www.netbeans.org/dtds/autoupdate-info-2_0.dtd\">"); //NOI18N |
435 |
log ("Creating NBM info file " + infofile); |
433 |
String codenamebase = attr.getValue ("OpenIDE-Module"); //NOI18N |
436 |
if (manifest != null) { |
434 |
if (codenamebase == null) |
437 |
// Read module manifest for main attributes. |
435 |
throw new BuildException ("invalid manifest, does not contain OpenIDE-Module", location); |
438 |
try { |
436 |
// Strip major release number if any. |
439 |
InputStream manifestStream = new FileInputStream (manifest); |
437 |
int idx = codenamebase.lastIndexOf ('/'); //NOI18N |
440 |
try { |
438 |
if (idx != -1) codenamebase = codenamebase.substring (0, idx); |
441 |
attr = new Manifest (manifestStream).getMainAttributes (); |
439 |
ps.println ("<module codenamebase=\"" + xmlEscape(codenamebase) + "\""); //NOI18N |
442 |
} finally { |
440 |
if (homepage != null) |
443 |
manifestStream.close (); |
441 |
ps.println (" homepage=\"" + xmlEscape(homepage) + "\""); //NOI18N |
444 |
} |
442 |
if (distribution != null) { |
445 |
} catch (IOException e) { |
443 |
ps.println (" distribution=\"" + xmlEscape(distribution) + "\""); //NOI18N |
446 |
throw new BuildException ("exception when reading manifest " + manifest, e, location); |
444 |
} else { |
|
|
445 |
throw new BuildException ("NBM distribution URL is not set", location); |
447 |
} |
446 |
} |
448 |
} // else we read attr before |
447 |
// Here we only write a name for the license. |
449 |
try { |
448 |
if (license != null) { |
450 |
OutputStream infoStream = new FileOutputStream (infofile); |
449 |
String name = license.getName (); |
451 |
try { |
450 |
if (name == null) |
452 |
PrintWriter ps = new PrintWriter(new OutputStreamWriter(infoStream, "UTF-8")); //NOI18N |
451 |
throw new BuildException ("Every license must have a name or file attribute", location); |
453 |
// Begin writing XML. |
452 |
ps.println (" license=\"" + xmlEscape(name) + "\""); //NOI18N |
454 |
ps.println ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //NOI18N |
453 |
} |
455 |
ps.println("<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Autoupdate Module Info 2.0//EN\" \"http://www.netbeans.org/dtds/autoupdate-info-2_0.dtd\">"); //NOI18N |
454 |
ps.println (" downloadsize=\"0\""); //NOI18N |
456 |
String codenamebase = attr.getValue ("OpenIDE-Module"); //NOI18N |
455 |
if (needsrestart != null) |
457 |
if (codenamebase == null) |
456 |
ps.println (" needsrestart=\"" + xmlEscape(needsrestart) + "\""); //NOI18N |
458 |
throw new BuildException ("invalid manifest, does not contain OpenIDE-Module", location); |
457 |
ps.println (">"); //NOI18N |
459 |
// Strip major release number if any. |
458 |
if (description != null) { |
460 |
int idx = codenamebase.lastIndexOf ('/'); //NOI18N |
459 |
ps.print (" <description>"); //NOI18N |
461 |
if (idx != -1) codenamebase = codenamebase.substring (0, idx); |
460 |
ps.print (description.getText ()); |
462 |
ps.println ("<module codenamebase=\"" + xmlEscape(codenamebase) + "\""); //NOI18N |
461 |
ps.println ("</description>"); //NOI18N |
463 |
if (homepage != null) |
462 |
} |
464 |
ps.println (" homepage=\"" + xmlEscape(homepage) + "\""); //NOI18N |
463 |
if (notification != null) { |
465 |
if (distribution != null) { |
464 |
ps.print(" <module_notification>"); //NOI18N |
466 |
ps.println (" distribution=\"" + xmlEscape(distribution) + "\""); //NOI18N |
465 |
ps.print(notification.getText()); |
467 |
} else { |
466 |
ps.println("</module_notification>"); //NOI18N |
468 |
throw new BuildException ("NBM distribution URL is not set", location); |
467 |
} |
469 |
} |
468 |
if (externalPackages != null) { |
470 |
// Here we only write a name for the license. |
469 |
Enumeration exp = externalPackages.elements(); |
471 |
if (license != null) { |
470 |
while (exp.hasMoreElements()) { |
472 |
String name = license.getName (); |
471 |
ExternalPackage externalPackage = (ExternalPackage) exp.nextElement(); |
473 |
if (name == null) |
472 |
if (externalPackage.name == null || |
474 |
throw new BuildException ("Every license must have a name or file attribute", location); |
473 |
externalPackage.targetName == null || |
475 |
ps.println (" license=\"" + xmlEscape(name) + "\""); //NOI18N |
474 |
externalPackage.startUrl == null) |
476 |
} |
475 |
throw new BuildException("Must define name, targetname, starturl for external package"); |
477 |
ps.println (" downloadsize=\"0\""); //NOI18N |
476 |
ps.print(" <external_package "); //NOI18N |
478 |
if (needsrestart != null) |
477 |
ps.print("name=\""+xmlEscape(externalPackage.name)+"\" "); //NOI18N |
479 |
ps.println (" needsrestart=\"" + xmlEscape(needsrestart) + "\""); //NOI18N |
478 |
ps.print("target_name=\""+xmlEscape(externalPackage.targetName)+"\" "); //NOI18N |
480 |
ps.println (">"); //NOI18N |
479 |
ps.print("start_url=\""+xmlEscape(externalPackage.startUrl)+"\""); //NOI18N |
481 |
if (description != null) { |
480 |
if (externalPackage.description != null) |
482 |
ps.print (" <description>"); //NOI18N |
481 |
ps.print(" description=\""+xmlEscape(externalPackage.description)+"\""); //NOI18N |
483 |
ps.print (description.getText ()); |
482 |
ps.println("/>"); //NOI18N |
484 |
ps.println ("</description>"); //NOI18N |
|
|
485 |
} |
486 |
if (notification != null) { |
487 |
ps.print(" <module_notification>"); //NOI18N |
488 |
ps.print(notification.getText()); |
489 |
ps.println("</module_notification>"); //NOI18N |
490 |
} |
491 |
if (externalPackages != null) { |
492 |
Enumeration exp = externalPackages.elements(); |
493 |
while (exp.hasMoreElements()) { |
494 |
ExternalPackage externalPackage = (ExternalPackage) exp.nextElement(); |
495 |
if (externalPackage.name == null || |
496 |
externalPackage.targetName == null || |
497 |
externalPackage.startUrl == null) |
498 |
throw new BuildException("Must define name, targetname, starturl for external package"); |
499 |
ps.print(" <external_package "); //NOI18N |
500 |
ps.print("name=\""+xmlEscape(externalPackage.name)+"\" "); //NOI18N |
501 |
ps.print("target_name=\""+xmlEscape(externalPackage.targetName)+"\" "); //NOI18N |
502 |
ps.print("start_url=\""+xmlEscape(externalPackage.startUrl)+"\""); //NOI18N |
503 |
if (externalPackage.description != null) |
504 |
ps.print(" description=\""+xmlEscape(externalPackage.description)+"\""); //NOI18N |
505 |
ps.println("/>"); //NOI18N |
506 |
} |
507 |
} |
508 |
// Write manifest attributes. |
509 |
ps.print (" <manifest "); //NOI18N |
510 |
boolean firstline = true; |
511 |
List attrNames = new ArrayList(attr.size()); // List<String> |
512 |
Iterator it = attr.keySet().iterator(); |
513 |
while (it.hasNext()) { |
514 |
attrNames.add(((Attributes.Name)it.next()).toString()); |
515 |
} |
483 |
} |
516 |
Collections.sort(attrNames); |
484 |
} |
517 |
it = attrNames.iterator(); |
485 |
// Write manifest attributes. |
518 |
while (it.hasNext()) { |
486 |
ps.print (" <manifest "); //NOI18N |
519 |
String name = (String)it.next(); |
487 |
boolean firstline = true; |
520 |
// Ignore irrelevant attributes (cf. www/www/dtds/autoupdate-catalog-2_0.dtd |
488 |
List attrNames = new ArrayList(attr.size()); // List<String> |
521 |
// and www/www/dtds/autoupdate-info-2_0.dtd): |
489 |
Iterator it = attr.keySet().iterator(); |
522 |
if (! name.startsWith("OpenIDE-Module")) continue; //NOI18N |
490 |
while (it.hasNext()) { |
523 |
if (name.equals("OpenIDE-Module-Localizing-Bundle")) continue; //NOI18N |
491 |
attrNames.add(((Attributes.Name)it.next()).toString()); |
524 |
if (name.equals("OpenIDE-Module-Install")) continue; //NOI18N |
492 |
} |
525 |
if (name.equals("OpenIDE-Module-Layer")) continue; //NOI18N |
493 |
Collections.sort(attrNames); |
526 |
if (name.equals("OpenIDE-Module-Description")) continue; //NOI18N |
494 |
it = attrNames.iterator(); |
527 |
if (name.equals("OpenIDE-Module-Package-Dependency-Message")) continue; //NOI18N |
495 |
while (it.hasNext()) { |
528 |
if (name.equals("OpenIDE-Module-Public-Packages")) continue; //NOI18N |
496 |
String name = (String)it.next(); |
529 |
if (firstline) |
497 |
// Ignore irrelevant attributes (cf. www/www/dtds/autoupdate-catalog-2_0.dtd |
530 |
firstline = false; |
498 |
// and www/www/dtds/autoupdate-info-2_0.dtd): |
531 |
else |
499 |
if (! name.startsWith("OpenIDE-Module")) continue; //NOI18N |
532 |
ps.print (" "); |
500 |
if (name.equals("OpenIDE-Module-Localizing-Bundle")) continue; //NOI18N |
533 |
ps.println(name + "=\"" + xmlEscape(attr.getValue(name)) + "\""); //NOI18N |
501 |
if (name.equals("OpenIDE-Module-Install")) continue; //NOI18N |
534 |
} |
502 |
if (name.equals("OpenIDE-Module-Layer")) continue; //NOI18N |
535 |
ps.println (" />"); //NOI18N |
503 |
if (name.equals("OpenIDE-Module-Description")) continue; //NOI18N |
536 |
// Maybe write out license text. |
504 |
if (name.equals("OpenIDE-Module-Package-Dependency-Message")) continue; //NOI18N |
537 |
if (license != null) { |
505 |
if (name.equals("OpenIDE-Module-Public-Packages")) continue; //NOI18N |
538 |
ps.print (" <license name=\"" + xmlEscape(license.getName ()) + "\">"); //NOI18N |
506 |
if (firstline) |
539 |
ps.print (license.getText ()); |
507 |
firstline = false; |
540 |
ps.println ("</license>"); //NOI18N |
508 |
else |
541 |
} |
509 |
ps.print (" "); |
542 |
ps.println ("</module>"); //NOI18N |
510 |
ps.println(name + "=\"" + xmlEscape(attr.getValue(name)) + "\""); //NOI18N |
543 |
ps.flush(); |
511 |
} |
544 |
} finally { |
512 |
ps.println (" />"); //NOI18N |
545 |
infoStream.close (); |
513 |
// Maybe write out license text. |
546 |
} |
514 |
if (license != null) { |
547 |
} catch (IOException e) { |
515 |
ps.print (" <license name=\"" + xmlEscape(license.getName ()) + "\">"); //NOI18N |
548 |
throw new BuildException ("exception when creating Info/info.xml", e, location); |
516 |
ps.print (license.getText ()); |
549 |
} |
517 |
ps.println ("</license>"); //NOI18N |
550 |
} |
518 |
} |
|
|
519 |
ps.println ("</module>"); //NOI18N |
520 |
ps.flush(); |
521 |
} finally { |
522 |
infoStream.close (); |
523 |
} |
524 |
} catch (IOException e) { |
525 |
throw new BuildException ("exception when creating Info/info.xml", e, location); |
526 |
} |
527 |
infofile.deleteOnExit(); |
528 |
ZipFileSet infoXML = new ZipFileSet(); |
529 |
infoXML.setDir( new File("/") ); |
530 |
infoXML.setIncludes( infofile.getAbsolutePath().substring(1) ); |
531 |
infoXML.setFullpath("Info/info.xml"); |
532 |
|
533 |
String codename = attr.getValue("OpenIDE-Module"); |
534 |
if (codename == null) |
535 |
new BuildException( "Can't get codenamebase" ); |
536 |
|
537 |
UpdateTracking tracking = new UpdateTracking(productDir.getAbsolutePath()); |
538 |
String files[] = tracking.getListOfNBM( codename ); |
539 |
ZipFileSet fs = new ZipFileSet(); |
540 |
fs.setDir( productDir ); |
541 |
for (int i=0; i < files.length; i++) |
542 |
fs.createInclude().setName( files[i] ); |
543 |
fs.setPrefix("netbeans/"); |
544 |
|
551 |
// JAR it all up together. |
545 |
// JAR it all up together. |
552 |
long jarModified = file.lastModified (); // may be 0 |
546 |
long jarModified = file.lastModified (); // may be 0 |
553 |
//log ("Ensuring existence of NBM file " + file); |
547 |
//log ("Ensuring existence of NBM file " + file); |
554 |
Jar jar = (Jar) project.createTask ("jar"); //NOI18N |
548 |
Jar jar = (Jar) project.createTask ("jar"); //NOI18N |
555 |
|
549 |
|
556 |
jar.setJarfile (file); |
550 |
jar.setJarfile (file); |
557 |
//jar.setBasedir (topdir.getAbsolutePath ()); |
551 |
jar.addZipfileset(fs); |
|
|
552 |
jar.addFileset (infoXML); |
558 |
jar.setCompress(true); |
553 |
jar.setCompress(true); |
559 |
//jar.createInclude ().setName ("netbeans/"); //NOI18N |
|
|
560 |
//jar.createInclude ().setName ("Info/info.xml"); //NOI18N |
561 |
jar.addFileset (getFileSet()); |
562 |
jar.setLocation (location); |
554 |
jar.setLocation (location); |
563 |
jar.init (); |
555 |
jar.init (); |
564 |
jar.execute (); |
556 |
jar.execute (); |
Lines 634-673
Link Here
|
634 |
} |
626 |
} |
635 |
} |
627 |
} |
636 |
|
628 |
|
637 |
// Reflection access from MakeListOfNBM: |
|
|
638 |
|
639 |
FileSet getFileSet() { |
640 |
FileSet fs = fileset; //makes in apperance to excludes and includes files defined in XML |
641 |
fs.setDir (topdir); |
642 |
|
643 |
if (isStandardInclude) { |
644 |
fs.createInclude ().setName ("netbeans/"); //NOI18N |
645 |
fs.createExclude ().setName ("netbeans/update_tracking/*.xml"); //NOI18N |
646 |
} |
647 |
|
648 |
fs.createInclude ().setName ("Info/info.xml"); //NOI18N |
649 |
return fs; |
650 |
} |
651 |
|
652 |
Attributes getAttributes() throws IOException { |
653 |
if (manifest != null) { |
654 |
InputStream is = new FileInputStream(manifest); |
655 |
try { |
656 |
return new Manifest(is).getMainAttributes(); |
657 |
} finally { |
658 |
is.close(); |
659 |
} |
660 |
} else if (module != null) { |
661 |
JarFile jar = new JarFile(module); |
662 |
try { |
663 |
return jar.getManifest().getMainAttributes(); |
664 |
} finally { |
665 |
jar.close(); |
666 |
} |
667 |
} else { |
668 |
throw new IOException(location + "must give either 'manifest' or 'module' on <makenbm>"); |
669 |
} |
670 |
} |
671 |
|
629 |
|
672 |
/** This returns true if the license should be overridden. */ |
630 |
/** This returns true if the license should be overridden. */ |
673 |
protected boolean overrideLicense() { |
631 |
protected boolean overrideLicense() { |