blob: 8dde3da1f158418ce46b109c2b2cc33cc3d2a95a [file] [log] [blame]
Stuart McCullochd00f9712009-07-13 10:06:47 +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 static Syntax[] syntaxes = new Syntax[] {
47 new Syntax(
48 BUNDLE_ACTIVATION_POLICY,
49 "The Bundle-ActivationPolicy specifies how the framework should activate the bundle once started. ",
50 "Bundle-ActivationPolicy: lazy", "lazy", Pattern
51 .compile("lazy")),
52
53 new Syntax(
54 BUNDLE_ACTIVATOR,
55 "The Bundle-Activator header specifies the name of the class used to start and stop the bundle. ",
56 "Bundle-Activator: com.acme.foo.Activator",
57 "${classes;implementing;org.osgi.framework.BundleActivator}",
58 Verifier.FQNPATTERN),
59 new Syntax(
60 BUNDLE_CATEGORY,
61 "The Bundle-Category header holds a comma-separated list of category names",
62 "Bundle-Category: test",
63 "osgi,test,game,util,eclipse,netbeans,jdk,specification",
64 null),
65 new Syntax(
66 BUNDLE_CLASSPATH,
67 "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.",
68 "Bundle-Classpath: /lib/libnewgen.so, .", null,
69 Verifier.PATHPATTERN),
70 new Syntax(
71 BUNDLE_CONTACTADDRESS,
72 "The Bundle-ContactAddress header provides the contact address of the vendor. ",
73 "Bundle-ContactAddress: 2400 Oswego Road, Austin, TX 74563",
74 null, null),
75 new Syntax(
76 BUNDLE_COPYRIGHT,
77 "The Bundle-Copyright header contains the copyright specification for this bundle. ",
78 "Bundle-Copyright: OSGi (c) 2002", null, null),
79 new Syntax(
80 BUNDLE_DESCRIPTION,
81 "The Bundle-Description header defines a short description of this bundle.",
82 "Bundle-Description: Ceci ce n'est pas une bundle", null,
83 null),
84
85 new Syntax(
86 BUNDLE_DOCURL,
87 "The Bundle-DocURL headers must contain a URL pointing to documentation about this bundle.",
88 "Bundle-DocURL: http://www.aQute.biz/Code/Bnd", null,
89 Verifier.URLPATTERN),
90
91 new Syntax(
92 BUNDLE_ICON,
93 "The optional Bundle-Icon header provides a list of (relative) URLs to icons representing this bundle in different sizes. ",
94 "Bundle-Icon: /icons/bnd.png;size=64", "/icons/bundle.png",
95 Verifier.URLPATTERN, new Syntax("size",
96 "Icons size in pixels, e.g. 64", "64",
97 "16,32,48,64,128", Verifier.NUMBERPATTERN)),
98
99 new Syntax(
100 BUNDLE_LICENSE,
101 "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",
102 "Bundle License: http://www.opensource.org/licenses/jabberpl.php",
103 "http://www.apache.org/licenses/LICENSE-2.0,<<EXTERNAL>>",
104 Pattern.compile("(" + Verifier.URLPATTERN
105 + "|<<EXTERNAL>>)"), new Syntax(
106 DESCRIPTION_ATTRIBUTE,
107 "Human readable description of the license",
108 "description=\"Described the license here\"", null,
109 Verifier.ANYPATTERN), new Syntax(LINK_ATTRIBUTE,
110 "", "", null, Verifier.URLPATTERN)),
111 new Syntax(
112 BUNDLE_LOCALIZATION,
113 "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.",
114 "Bundle-Localization: OSGI-INF/l10n/bundle",
115 "OSGI-INF/l10n/bundle", Verifier.URLPATTERN),
116 new Syntax(
117 BUNDLE_MANIFESTVERSION,
118 "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.",
119 "# Bundle-ManifestVersion: 2", "2", Verifier.NUMBERPATTERN),
120 new Syntax(
121 BUNDLE_NAME,
122 "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.",
123 "Bundle-Name: My Bundle", null, Verifier.ANYPATTERN),
124 new Syntax(
125 BUNDLE_NATIVECODE,
126 "The Bundle-NativeCode header contains a specification of native code libraries contained in this bundle. ",
127 "Bundle-NativeCode: /lib/http.DLL; osname = QNX; osversion = 3.1",
128 null,
129 Verifier.PATHPATTERN,
130 new Syntax(OSNAME_ATTRIBUTE,
131 "The name of the operating system", "osname=MacOS",
132 Processor.join(Verifier.OSNAMES, ","),
133 Verifier.ANYPATTERN),
134 new Syntax(OSVERSION_ATTRIBUTE, "Operating System Version",
135 "osversion=3.1", null, Verifier.ANYPATTERN),
136 new Syntax(LANGUAGE_ATTRIBUTE, "Language ISO 639 code",
137 "language=nl", null, Verifier.ISO639),
138 new Syntax(PROCESSOR_ATTRIBUTE, "Processor name",
139 "processor=x86", Processor.join(
140 Verifier.PROCESSORNAMES, ","),
141 Verifier.ANYPATTERN),
142 new Syntax(
143 SELECTION_FILTER_ATTRIBUTE,
144 "The value of this attribute must be a filter expression that indicates if the native code clause should be selected or not.",
145 "selection-filter=\"(com.acme.windowing=win32)\"",
146 null, Verifier.FILTERPATTERN)),
147 new Syntax(
148 BUNDLE_REQUIREDEXECUTIONENVIRONMENT,
149 "The Bundle-RequiredExecutionEnvironment contains a comma-separated list of execution environments that must be present on the Service Platform.",
150 "Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0",
151 Processor.join(Verifier.EES, ","), Verifier.ANYPATTERN),
152
153 new Syntax(
154 BUNDLE_SYMBOLICNAME,
155 "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",
156 "Bundle-SymbolicName: com.acme.foo.daffy;singleton:=true",
157 "${p}",
158 Verifier.SYMBOLICNAME,
159 new Syntax(
160 SINGLETON_DIRECTIVE,
161 " 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.",
162 "false", "true,false", Verifier.TRUEORFALSEPATTERN),
163 new Syntax(
164 FRAGMENT_ATTACHMENT_DIRECTIVE,
165 "Defines how fragments are allowed to be attached, see the fragments in Fragment Bundles on page73. The following values are valid for this directive:",
166 "", "always|never|resolve-time", Pattern
167 .compile("always|never|resolve-time")),
168 new Syntax(BLUEPRINT_WAIT_FOR_DEPENDENCIES_ATTRIBUTE, "",
169 "", "true,false", Verifier.TRUEORFALSEPATTERN),
170 new Syntax(BLUEPRINT_TIMEOUT_ATTRIBUTE, "", "",
171 "30000,60000,300000", Verifier.NUMBERPATTERN)),
172
173 new Syntax(
174 BUNDLE_UPDATELOCATION,
175 "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.",
176 "Bundle-UpdateLocation: http://www.acme.com/Firewall/bundle.jar",
177 null, Verifier.URLPATTERN),
178
179 new Syntax(
180 BUNDLE_VENDOR,
181 "The Bundle-Vendor header contains a human-readable description of the bundle vendor. ",
182 "Bundle-Vendor: OSGi Alliance ", null, null),
183
184 new Syntax(
185 BUNDLE_VERSION,
186 "The Bundle-Version header specifies the version of this bundle",
187 "Bundle-Version: 1.23.4.build200903221000", null,
188 Verifier.VERSION),
189
190 new Syntax(
191 DYNAMICIMPORT_PACKAGE,
192 "The DynamicImport-Package header contains a comma-separated list of package names that should be dynamically imported when needed.",
193 "DynamicImport-Package: com.acme.plugin.*", "",
194 Verifier.WILDCARDNAMEPATTERN, version,
195 bundle_symbolic_name, bundle_version),
196
197 new Syntax(
198 EXPORT_PACKAGE,
199 "The Export-Package header contains a declaration of exported packages.",
200 "Export-Package: org.osgi.util.tracker;version=1.3",
201 "${packages}",
202 null,
203 new Syntax(
204 NO_IMPORT_DIRECTIVE,
205 "By default, bnd makes all exports also imports. Adding a -noimport to an exported package will make it export only",
206 "-noimport:=true", "true,false",
207 Verifier.TRUEORFALSEPATTERN),
208 new Syntax(
209 USES_DIRECTIVE,
210 "Calculated by bnd: It is a comma-separated list of package names that are used by the exported package",
211 "Is calculated by bnd", null, null),
212 new Syntax(
213 MANDATORY_DIRECTIVE,
214 "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",
215 "mandatory=\"bar,foo\"", null, null),
216 new Syntax(
217 INCLUDE_DIRECTIVE,
218 "A comma-separated list of class names that must be visible to an importer",
219 "include:=\"Qux*\"", null, null),
220 new Syntax(
221 EXCLUDE_DIRECTIVE,
222 "A comma-separated list of class names that must not be visible to an importer",
223 "exclude:=\"QuxImpl*,BarImpl\"", null,
224 Verifier.WILDCARDNAMEPATTERN), new Syntax(
225 IMPORT_DIRECTIVE, "Experimental", "", null, null)
226
227 ),
228 new Syntax(EXPORT_SERVICE, "Deprecated",
229 "Export-Service: org.osgi.service.log.LogService ",
230 "${classes;implementing;*}", null),
231 new Syntax(
232 FRAGMENT_HOST,
233 "The Fragment-Host header defines the host bundle for this fragment.",
234 "Fragment-Host: org.eclipse.swt; bundle-version=\"[3.0.0,4.0.0)\"",
235 null,
236 null,
237 new Syntax(
238 EXTENSION_DIRECTIVE,
239 " Indicates this extension is a system or boot class path extension. It is only applicable when the Fragment-Host is the System Bundle",
240 "extension:=framework", "framework,bootclasspath",
241 Pattern.compile("framework|bootclasspath")),
242 bundle_version),
243 new Syntax(
244 IMPORT_PACKAGE,
245 "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",
246 "Import-Package: !com.exotic.*, com.acme.foo;vendor=ACME, *",
247 "${exported_packages}",
248 Verifier.WILDCARDNAMEPATTERN,
249 new Syntax(
250 REMOVE_ATTRIBUTE_DIRECTIVE,
251 "Remove the given attributes from matching imported packages",
252 "-remove-attribute:=foo.*", null,
253 Verifier.WILDCARDNAMEPATTERN),
254 new Syntax(
255 RESOLUTION_DIRECTIVE,
256 "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",
257 "resolution:=optional", "mandatory,optional",
258 Pattern.compile("mandatory|optional")
259
260 ), version, bundle_symbolic_name, bundle_version),
261
262 new Syntax(
263 REQUIRE_BUNDLE,
264 "The Require-Bundle header specifies the required exports from another bundle.",
265 "Require-Bundle: com.acme.chess",
266 null,
267 Verifier.WILDCARDNAMEPATTERN,
268
269 new Syntax(
270 VISIBILITY_DIRECTIVE,
271 " 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.",
272 "visibility:=private", "private,reexport", Pattern
273 .compile("private|reexport")),
274
275 new Syntax(
276 RESOLUTION_DIRECTIVE,
277 "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.",
278 "resolution:=optional", "mandatory,optional",
279 Pattern.compile("mandatory|optional")),
280
281 new Syntax(
282 SPLIT_PACKAGE_DIRECTIVE,
283 "Indicates how an imported package should be merged when it is split between different exporters. The default is merge-first with warning",
284 "-split-package:=merge-first",
285 "merge-first,merge-last,error,first",
286 Pattern
287 .compile("merge-first|merge-last|error|first")),
288 bundle_version
289
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 "Dont do anything, return without building any jars",
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(
380 SERVICE_COMPONENT,
381 "The header for Declarative Services",
382 "Service-Component=com.acme.Foo?;activate='start'",
383 null, null),
384
385 new Syntax(POM, "Generate a maven pom", "-pom=true", "true,false",
386 Verifier.TRUEORFALSEPATTERN),
387
388 new Syntax(RELEASEREPO,
389 "Specifies to which repo the project should be released.",
390 "-releaserepo=cnf", "${repos}", null),
391
392 new Syntax(REMOVE_HEADERS,
393 "Remove all headers that match the regular expressions",
394 "-removeheaders=FOO_.*,Proprietary", null, null),
395 new Syntax(
396 RESOURCEONLY,
397 "Normally bnd warns when the JAR does not contain any classes, this option suppresses this warning",
398 "-resourceonly=true", "true,false",
399 Verifier.TRUEORFALSEPATTERN),
400 new Syntax(SOURCES, "Include sources in the jar", "-sources=true",
401 "true,false", Verifier.TRUEORFALSEPATTERN),
402 new Syntax(
403 SOURCEPATH,
404 "List of directory names that used to source sources for -sources",
405 "-sourcepath:= src, test", null, null),
406 new Syntax(
407 SUB,
408 "Build a set of bnd files that use this bnd file as a basis. The list of bnd file can be specified with wildcards",
409 "-sub=com.acme.*.bnd", null, null),
410 new Syntax(
411 RUNPROPERTIES,
412 "Properties that are set as system properties before the framework is started",
413 "-runproperties= foo=3, bar=4", null, null),
414 new Syntax(RUNSYSTEMPACKAGES,
415 "Add additional system packages to a framework run",
416 "-runsystempackages=com.acme.foo,javax.management", null,
417 null),
418 new Syntax(
419 RUNBUNDLES,
420 "Add additional bundles, specified with their bsn and version like in -buildpath, that are started before the project is run",
421 "-runbundles=osgi;version=\"[4.1,4.2)\", junit.junit, com.acme.foo;version=project",
422 null, Verifier.SYMBOLICNAME, path_version),
423 new Syntax(
424 RUNPATH,
425 "Additional JARs for the VM path, should include the framework",
426 "-runpath=org.eclipse.osgi;version=3.5", null, null,
427 path_version),
428 new Syntax(
429 RUNVM,
430 "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",
431 "-runvm=-Xmax=30", null, null),
432 new Syntax(
433 VERSIONPOLICY,
434 "Provides a version policy to imports that are calculated from exports",
435 "-versionpolicy = \"[${version;==;${@}},${version;+;${@}})\"",
436 null, null)
437
438 };
439
440 public final static Map<String, Syntax> HELP = new HashMap<String, Syntax>();
441
442 static {
443 for (Syntax s : syntaxes) {
444 HELP.put(s.header, s);
445 }
446 }
447
448 public Syntax(String header, String lead, String example, String values,
449 Pattern pattern, Syntax... children) {
450 this.header = header;
451 this.children = children;
452 this.lead = lead;
453 this.example = example;
454 this.values = values;
455 this.pattern = pattern;
456 }
457
458 public String getLead() {
459 return lead;
460 }
461
462 public String getExample() {
463 return example;
464 }
465
466 public String getValues() {
467 return values;
468 }
469
470 public String getPattern() {
471 return lead;
472 }
473
474 public Syntax[] getChildren() {
475 return children;
476 }
477
478 public String getHeader() {
479 return header;
480 }
481
482}