blob: 20a7440be2fc3b9d84ff91704e3a03faa904081b [file] [log] [blame]
Stuart McCulloch26e7a5a2011-10-17 10:31:43 +00001package aQute.bnd.help;
2
3import java.util.*;
4import java.util.regex.*;
5
6import aQute.lib.osgi.*;
7
8public class Syntax implements Constants {
9 final String header;
10 final String lead;
11 final String example;
12 final Pattern pattern;
13 final String values;
14 final Syntax[] children;
15
16 static Syntax version = new Syntax(
17 VERSION_ATTRIBUTE,
18 "A version range to select the version of an export definition. The default value is 0.0.0 .",
19 "version=\"[1.2,3.0)\"",
20 null,
21 Verifier.VERSIONRANGE);
22 static Syntax bundle_symbolic_name = new Syntax(
23 BUNDLE_SYMBOLIC_NAME_ATTRIBUTE,
24 "The bundle symbolic name of the exporting bundle.",
25 "bundle-symbolic-name=com.acme.foo.daffy",
26 null,
27 Verifier.SYMBOLICNAME);
28
29 static Syntax bundle_version = new Syntax(
30 BUNDLE_VERSION_ATTRIBUTE,
31 "a version range to select the bundle version of the exporting bundle. The default value is 0.0.0.",
32 "bundle-version=1.3",
33 null,
34 Verifier.VERSIONRANGE);
35
36 static Syntax path_version = new Syntax(
37 VERSION_ATTRIBUTE,
38 "Specifies the range in the repository, project, or file",
39 "version=project",
40 "project,type",
41 Pattern
42 .compile("project|type|"
43 + Verifier.VERSIONRANGE
44 .toString()));
45
46 @SuppressWarnings("deprecation")
47 static Syntax[] syntaxes = new Syntax[] {
48 new Syntax(
49 BUNDLE_ACTIVATIONPOLICY,
50 "The Bundle-ActivationPolicy specifies how the framework should activate the bundle once started. ",
51 "Bundle-ActivationPolicy: lazy", "lazy", Pattern
52 .compile("lazy")),
53
54 new Syntax(
55 BUNDLE_ACTIVATOR,
56 "The Bundle-Activator header specifies the name of the class used to start and stop the bundle. ",
57 "Bundle-Activator: com.acme.foo.Activator",
58 "${classes;implementing;org.osgi.framework.BundleActivator}",
59 Verifier.FQNPATTERN),
60 new Syntax(
61 BUNDLE_CATEGORY,
62 "The Bundle-Category header holds a comma-separated list of category names",
63 "Bundle-Category: test",
64 "osgi,test,game,util,eclipse,netbeans,jdk,specification",
65 null),
66 new Syntax(
67 BUNDLE_CLASSPATH,
68 "The Bundle-ClassPath header defines a comma-separated list of JAR file path names or directories (inside the bundle) containing classes and resources. The period (’.’) specifies the root directory of the bundle’s JAR. The period is also the default.",
69 "Bundle-Classpath: /lib/libnewgen.so, .", null,
70 Verifier.PATHPATTERN),
71 new Syntax(
72 BUNDLE_CONTACTADDRESS,
73 "The Bundle-ContactAddress header provides the contact address of the vendor. ",
74 "Bundle-ContactAddress: 2400 Oswego Road, Austin, TX 74563",
75 null, null),
76 new Syntax(
77 BUNDLE_COPYRIGHT,
78 "The Bundle-Copyright header contains the copyright specification for this bundle. ",
79 "Bundle-Copyright: OSGi (c) 2002", null, null),
80 new Syntax(
81 BUNDLE_DESCRIPTION,
82 "The Bundle-Description header defines a short description of this bundle.",
83 "Bundle-Description: Ceci ce n'est pas une bundle", null,
84 null),
85
86 new Syntax(
87 BUNDLE_DOCURL,
88 "The Bundle-DocURL headers must contain a URL pointing to documentation about this bundle.",
89 "Bundle-DocURL: http://www.aQute.biz/Code/Bnd", null,
90 Verifier.URLPATTERN),
91
92 new Syntax(
93 BUNDLE_ICON,
94 "The optional Bundle-Icon header provides a list of (relative) URLs to icons representing this bundle in different sizes. ",
95 "Bundle-Icon: /icons/bnd.png;size=64", "/icons/bundle.png",
96 Verifier.URLPATTERN, new Syntax("size",
97 "Icons size in pixels, e.g. 64", "64",
98 "16,32,48,64,128", Verifier.NUMBERPATTERN)),
99
100 new Syntax(
101 BUNDLE_LICENSE,
102 "The Bundle-License header provides an optional machine readable form of license information. The purpose of this header is to automate some of the license processing required by many organizations",
103 "Bundle License: http://www.opensource.org/licenses/jabberpl.php",
104 "http://www.apache.org/licenses/LICENSE-2.0,<<EXTERNAL>>",
105 Pattern.compile("(" + Verifier.URLPATTERN
106 + "|<<EXTERNAL>>)"), new Syntax(
107 DESCRIPTION_ATTRIBUTE,
108 "Human readable description of the license",
109 "description=\"Described the license here\"", null,
110 Verifier.ANYPATTERN), new Syntax(LINK_ATTRIBUTE,
111 "", "", null, Verifier.URLPATTERN)),
112 new Syntax(
113 BUNDLE_LOCALIZATION,
114 "The Bundle-Localization header contains the location in the bundle where localization files can be found. The default value is OSGI-INF/l10n/bundle. Translations are by default therefore OSGI-INF/l10n/bundle_de.properties, OSGI-INF/l10n/bundle_nl.properties, etc.",
115 "Bundle-Localization: OSGI-INF/l10n/bundle",
116 "OSGI-INF/l10n/bundle", Verifier.URLPATTERN),
117 new Syntax(
118 BUNDLE_MANIFESTVERSION,
119 "This header is set by bnd automatically to 2. The Bundle-ManifestVersion header defines that the bundle follows the rules of this specification. The Bundle-ManifestVersion header determines whether the bundle follows the rules of this specification.",
120 "# Bundle-ManifestVersion: 2", "2", Verifier.NUMBERPATTERN),
121 new Syntax(
122 BUNDLE_NAME,
123 "This header will be derived from the Bundle-SymbolicName if not set. The Bundle-Name header defines a readable name for this bundle. This should be a short, human-readable name that can contain spaces.",
124 "Bundle-Name: My Bundle", null, Verifier.ANYPATTERN),
125 new Syntax(
126 BUNDLE_NATIVECODE,
127 "The Bundle-NativeCode header contains a specification of native code libraries contained in this bundle. ",
128 "Bundle-NativeCode: /lib/http.DLL; osname = QNX; osversion = 3.1",
129 null,
130 Verifier.PATHPATTERN,
131 new Syntax(OSNAME_ATTRIBUTE,
132 "The name of the operating system", "osname=MacOS",
133 Processor.join(Verifier.OSNAMES, ","),
134 Verifier.ANYPATTERN),
135 new Syntax(OSVERSION_ATTRIBUTE, "Operating System Version",
136 "osversion=3.1", null, Verifier.ANYPATTERN),
137 new Syntax(LANGUAGE_ATTRIBUTE, "Language ISO 639 code",
138 "language=nl", null, Verifier.ISO639),
139 new Syntax(PROCESSOR_ATTRIBUTE, "Processor name",
140 "processor=x86", Processor.join(
141 Verifier.PROCESSORNAMES, ","),
142 Verifier.ANYPATTERN),
143 new Syntax(
144 SELECTION_FILTER_ATTRIBUTE,
145 "The value of this attribute must be a filter expression that indicates if the native code clause should be selected or not.",
146 "selection-filter=\"(com.acme.windowing=win32)\"",
147 null, Verifier.FILTERPATTERN)),
148 new Syntax(
149 BUNDLE_REQUIREDEXECUTIONENVIRONMENT,
150 "The Bundle-RequiredExecutionEnvironment contains a comma-separated list of execution environments that must be present on the Service Platform.",
151 "Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0",
152 Processor.join(Verifier.EES, ","), Verifier.ANYPATTERN),
153
154 new Syntax(
155 BUNDLE_SYMBOLICNAME,
156 "The Bundle-SymbolicName header specifies a non-localizable name for this bundle. The bundle symbolic name together with a version must identify a unique bundle. The bundle symbolic name should be based on the reverse domain name convention",
157 "Bundle-SymbolicName: com.acme.foo.daffy;singleton:=true",
158 "${p}",
159 Verifier.SYMBOLICNAME,
160 new Syntax(
161 SINGLETON_DIRECTIVE,
162 " Indicates that the bundle can only have a single version resolved. A value of true indicates that the bundle is a singleton bundle. The default value is false. The Framework must resolve at most one bundle when multiple versions of a singleton bundle with the same symbolic name are installed. Singleton bundles do not affect the resolution of non-singleton bundles with the same symbolic name.",
163 "false", "true,false", Verifier.TRUEORFALSEPATTERN),
164 new Syntax(
165 FRAGMENT_ATTACHMENT_DIRECTIVE,
166 "Defines how fragments are allowed to be attached, see the fragments in Fragment Bundles on page73. The following values are valid for this directive:",
167 "", "always|never|resolve-time", Pattern
168 .compile("always|never|resolve-time")),
169 new Syntax(BLUEPRINT_WAIT_FOR_DEPENDENCIES_ATTRIBUTE, "",
170 "", "true,false", Verifier.TRUEORFALSEPATTERN),
171 new Syntax(BLUEPRINT_TIMEOUT_ATTRIBUTE, "", "",
172 "30000,60000,300000", Verifier.NUMBERPATTERN)),
173
174 new Syntax(
175 BUNDLE_UPDATELOCATION,
176 "The Bundle-UpdateLocation header specifies a URL where an update for this bundle should come from. If the bundle is updated, this location should be used, if present, to retrieve the updated JAR file.",
177 "Bundle-UpdateLocation: http://www.acme.com/Firewall/bundle.jar",
178 null, Verifier.URLPATTERN),
179
180 new Syntax(
181 BUNDLE_VENDOR,
182 "The Bundle-Vendor header contains a human-readable description of the bundle vendor. ",
183 "Bundle-Vendor: OSGi Alliance ", null, null),
184
185 new Syntax(
186 BUNDLE_VERSION,
187 "The Bundle-Version header specifies the version of this bundle",
188 "Bundle-Version: 1.23.4.build200903221000", null,
189 Verifier.VERSION),
190
191 new Syntax(
192 DYNAMICIMPORT_PACKAGE,
193 "The DynamicImport-Package header contains a comma-separated list of package names that should be dynamically imported when needed.",
194 "DynamicImport-Package: com.acme.plugin.*", "",
195 Verifier.WILDCARDNAMEPATTERN, version,
196 bundle_symbolic_name, bundle_version),
197
198 new Syntax(
199 EXPORT_PACKAGE,
200 "The Export-Package header contains a declaration of exported packages.",
201 "Export-Package: org.osgi.util.tracker;version=1.3",
202 "${packages}",
203 null,
204 new Syntax(
205 NO_IMPORT_DIRECTIVE,
206 "By default, bnd makes all exports also imports. Adding a -noimport to an exported package will make it export only",
207 "-noimport:=true", "true,false",
208 Verifier.TRUEORFALSEPATTERN),
209 new Syntax(
210 USES_DIRECTIVE,
211 "Calculated by bnd: It is a comma-separated list of package names that are used by the exported package",
212 "Is calculated by bnd", null, null),
213 new Syntax(
214 MANDATORY_DIRECTIVE,
215 "A comma-separated list of attribute names. Note that the use of a comma in the value requires it to be enclosed in double quotes. A bundle importing the package must specify the mandatory attributes, with a value that matches, to resolve to the exported package",
216 "mandatory=\"bar,foo\"", null, null),
217 new Syntax(
218 INCLUDE_DIRECTIVE,
219 "A comma-separated list of class names that must be visible to an importer",
220 "include:=\"Qux*\"", null, null),
221 new Syntax(
222 EXCLUDE_DIRECTIVE,
223 "A comma-separated list of class names that must not be visible to an importer",
224 "exclude:=\"QuxImpl*,BarImpl\"", null,
225 Verifier.WILDCARDNAMEPATTERN), new Syntax(
226 IMPORT_DIRECTIVE, "Experimental", "", null, null)
227
228 ),
229 new Syntax(EXPORT_SERVICE, "Deprecated",
230 "Export-Service: org.osgi.service.log.LogService ",
231 "${classes;implementing;*}", null),
232 new Syntax(
233 FRAGMENT_HOST,
234 "The Fragment-Host header defines the host bundle for this fragment.",
235 "Fragment-Host: org.eclipse.swt; bundle-version=\"[3.0.0,4.0.0)\"",
236 null,
237 null,
238 new Syntax(
239 EXTENSION_DIRECTIVE,
240 " Indicates this extension is a system or boot class path extension. It is only applicable when the Fragment-Host is the System Bundle",
241 "extension:=framework", "framework,bootclasspath",
242 Pattern.compile("framework|bootclasspath")),
243 bundle_version),
244 new Syntax(
245 IMPORT_PACKAGE,
246 "This header is normally calculated by bnd, however, you can decorate packages or skip packages. The Import-Package header declares the imported packages for this bundle",
247 "Import-Package: !com.exotic.*, com.acme.foo;vendor=ACME, *",
248 "${exported_packages}",
249 Verifier.WILDCARDNAMEPATTERN,
250 new Syntax(
251 REMOVE_ATTRIBUTE_DIRECTIVE,
252 "Remove the given attributes from matching imported packages",
253 "-remove-attribute:=foo.*", null,
254 Verifier.WILDCARDNAMEPATTERN),
255 new Syntax(
256 RESOLUTION_DIRECTIVE,
257 "Indicates that the packages must be resolved if the value is mandatory, which is the default. If mandatory packages cannot be resolved, then the bundle must fail to resolve. A value of optional indicates that the packages are optional",
258 "resolution:=optional", "mandatory,optional",
259 Pattern.compile("mandatory|optional")
260
261 ), version, bundle_symbolic_name, bundle_version),
262
263 new Syntax(
264 REQUIRE_BUNDLE,
265 "The Require-Bundle header specifies the required exports from another bundle.",
266 "Require-Bundle: com.acme.chess",
267 null,
268 Verifier.WILDCARDNAMEPATTERN,
269
270 new Syntax(
271 VISIBILITY_DIRECTIVE,
272 " If the value is private (Default), then all visible packages from the required bundles are not re-exported. If the value is reexport then bundles that require this bundle will transitively have access to these required bundle’s exported packages.",
273 "visibility:=private", "private,reexport", Pattern
274 .compile("private|reexport")),
275
276 new Syntax(
277 RESOLUTION_DIRECTIVE,
278 "If the value is mandatory (default) then the required bundle must exist for this bundle to resolve. If the value is optional, the bundle will resolve even if the required bundle does not exist.",
279 "resolution:=optional", "mandatory,optional",
280 Pattern.compile("mandatory|optional")),
281
282 new Syntax(
283 SPLIT_PACKAGE_DIRECTIVE,
284 "Indicates how an imported package should be merged when it is split between different exporters. The default is merge-first with warning",
285 "-split-package:=merge-first",
286 "merge-first,merge-last,error,first",
287 Pattern
288 .compile("merge-first|merge-last|error|first")),
289 bundle_version
290
291 ),
292 new Syntax(
293 BUILDPATH,
294 "Provides the class path for building the jar. The entries are references to the repository",
295 "-buildpath=osgi;version=4.1", "${repo;bsns}",
296 Verifier.SYMBOLICNAME, path_version),
297 new Syntax(
298 BUMPPOLICY,
299 "Sets the version bump policy. This is a parameter to the ${version} macro.",
300 "-bumppolicy==+0", "==+,=+0,+00", Pattern
301 .compile("[=+-0][=+-0][=+-0]")),
302
303 new Syntax(
304 CONDUIT,
305 "Allows a bnd file to point to files which will be returned when the bnd file is build",
306 "-conduit= jar/osgi.jar", null, null),
307
308 new Syntax(
309 DEPENDSON,
310 "List of project names that this project directly depends on. These projects are always build ahead of this project",
311 "-dependson=org.acme.cm", "${projects}", null),
312
313 new Syntax(DEPLOYREPO,
314 "Specifies to which repo the project should be deployed.",
315 "-deployrepo=cnf", "${repos}", null),
316
317 new Syntax(
318 DONOTCOPY,
319 "Regular expression for names of files and directories that should not be copied when discovered",
320 "-donotcopy=(CVS|\\.svn)", null, null),
321
322 new Syntax(
323 EXPORT_CONTENTS,
324 "Build the JAR in the normal way but use this header for the Export-Package header manifest generation, same format",
325 "-exportcontents=!*impl*,*;version=3.0", null, null),
326
327 new Syntax(
328 FAIL_OK,
329 "Return with an ok status (0) even if the build generates errors",
330 "-failok=true", "true,false", Verifier.TRUEORFALSEPATTERN),
331
332 new Syntax(
333 INCLUDE,
334 "Include files. If an entry starts with '-', it does not have to exist. If it starts with '~', it must not overwrite any existing properties",
335 "-include: -${java.user}/.bnd", null, null),
336
337 new Syntax(
338 INCLUDERESOURCE,
339 "Include resources from the file system. You can specify a directory, or file. All files are copied to the root, unless a destination directory is indicated",
340 "-includeresource: lib=jar", null, null),
341
342 new Syntax(
343 MAKE,
344 "Set patterns for make plugins. These patterns are used to find a plugin that can make a resource that can not be found.",
345 "-make: (*).jar;type=bnd; recipe=\"bnd/$1.bnd\"", null,
346 null, new Syntax("type", "Type name for plugin",
347 "type=bnd", "bnd", null), new Syntax("recipe",
348 "Recipe for the plugin, can use back references",
349 "recipe=\"bnd/$1.bnd\"", "bnd", null)),
350
351 new Syntax(
352 MANIFEST,
353 "Directly include a manifest, do not use the calculated manifest",
354 "-manifest = META-INF/MANIFEST.MF", null, null),
355
356 new Syntax(NOEXTRAHEADERS, "Do not generate housekeeping headers",
357 "-noextraheaders", "true,false",
358 Verifier.TRUEORFALSEPATTERN),
359
360 new Syntax(NOUSES,
361 "Do not calculate the uses: directive on exports",
362 "-nouses=true", "true,false", Verifier.TRUEORFALSEPATTERN),
363
364 new Syntax(NOPE,
365 "Deprecated, use -nobundles. ",
366 "-nope=true", "true,false", Verifier.TRUEORFALSEPATTERN),
367
368 new Syntax(
369 PEDANTIC,
370 "Warn about things that are not really wrong but still not right",
371 "-nope=true", "true,false", Verifier.TRUEORFALSEPATTERN),
372
373 new Syntax(
374 PLUGIN,
375 "Define the plugins",
376 "-plugin=aQute.lib.spring.SpringComponent,aQute.lib.deployer.FileRepo;location=${repo}",
377 null, null),
378
379 new Syntax(SERVICE_COMPONENT,
380 "The header for Declarative Services",
381 "Service-Component=com.acme.Foo?;activate='start'", null,
382 null),
383
384 new Syntax(POM, "Generate a maven pom", "-pom=true", "true,false",
385 Verifier.TRUEORFALSEPATTERN),
386
387 new Syntax(RELEASEREPO,
388 "Specifies to which repo the project should be released.",
389 "-releaserepo=cnf", "${repos}", null),
390
391 new Syntax(REMOVEHEADERS,
392 "Remove all headers that match the regular expressions",
393 "-removeheaders=FOO_.*,Proprietary", null, null),
394 new Syntax(
395 RESOURCEONLY,
396 "Normally bnd warns when the JAR does not contain any classes, this option suppresses this warning",
397 "-resourceonly=true", "true,false",
398 Verifier.TRUEORFALSEPATTERN),
399 new Syntax(SOURCES, "Include sources in the jar", "-sources=true",
400 "true,false", Verifier.TRUEORFALSEPATTERN),
401 new Syntax(
402 SOURCEPATH,
403 "List of directory names that used to source sources for -sources",
404 "-sourcepath:= src, test", null, null),
405 new Syntax(
406 SUB,
407 "Build a set of bnd files that use this bnd file as a basis. The list of bnd file can be specified with wildcards",
408 "-sub=com.acme.*.bnd", null, null),
409 new Syntax(
410 RUNPROPERTIES,
411 "Properties that are set as system properties before the framework is started",
412 "-runproperties= foo=3, bar=4", null, null),
413 new Syntax(RUNSYSTEMPACKAGES,
414 "Add additional system packages to a framework run",
415 "-runsystempackages=com.acme.foo,javax.management", null,
416 null),
417 new Syntax(
418 RUNBUNDLES,
419 "Add additional bundles, specified with their bsn and version like in -buildpath, that are started before the project is run",
420 "-runbundles=osgi;version=\"[4.1,4.2)\", junit.junit, com.acme.foo;version=project",
421 null, Verifier.SYMBOLICNAME, path_version),
422 new Syntax(
423 RUNPATH,
424 "Additional JARs for the VM path, should include the framework",
425 "-runpath=org.eclipse.osgi;version=3.5", null, null,
426 path_version),
427 new Syntax(
428 RUNVM,
429 "Additional arguments for the VM invokation. Keys that start with a - are added as options, otherwise they are treated as -D properties for the VM",
430 "-runvm=-Xmax=30", null, null),
431 new Syntax(
432 VERSIONPOLICY,
433 "Provides a version policy to imports that are calculated from exports",
434 "-versionpolicy = \"[${version;==;${@}},${version;+;${@}})\"",
435 null, null)
436
437 };
438
439 public final static Map<String, Syntax> HELP = new HashMap<String, Syntax>();
440
441 static {
442 for (Syntax s : syntaxes) {
443 HELP.put(s.header, s);
444 }
445 }
446
447 public Syntax(String header, String lead, String example, String values,
448 Pattern pattern, Syntax... children) {
449 this.header = header;
450 this.children = children;
451 this.lead = lead;
452 this.example = example;
453 this.values = values;
454 this.pattern = pattern;
455 }
456
457 public String getLead() {
458 return lead;
459 }
460
461 public String getExample() {
462 return example;
463 }
464
465 public String getValues() {
466 return values;
467 }
468
469 public String getPattern() {
470 return lead;
471 }
472
473 public Syntax[] getChildren() {
474 return children;
475 }
476
477 public String getHeader() {
478 return header;
479 }
480
481}