|
| 1 | +--- |
| 2 | +title: Manifest Tool |
| 3 | +tagline: Manifest Tool is a tool for creating and managing manifest files for Jars |
| 4 | +category : learn |
| 5 | +tags : [jbang] |
| 6 | +author : Max Rydahl Andersen |
| 7 | +bgcolor: ff5a71 |
| 8 | +--- |
| 9 | +ifdef::env-github,env-browser,env-vscode[:imagesdir: ../images] |
| 10 | + |
| 11 | +Say hello to `mf@jbangdev` — the new, delightfully simple way to peek inside any JAR’s manifest! |
| 12 | + |
| 13 | +Ever wondered what secrets lurk in `META-INF/MANIFEST.MF`? Tired of squinting at cryptic key-value pairs or wrangling with unzip just to see what’s inside? Now you can summon manifest magic with a single command: |
| 14 | + |
| 15 | +[source,bash] |
| 16 | +---- |
| 17 | +mf `jbang info jar com.h2database:h2:2.2.224` |
| 18 | +---- |
| 19 | + |
| 20 | +This will use `jbang` to fetch the jar for h2 and then use `mf` to print the manifest. |
| 21 | + |
| 22 | +[source,txt] |
| 23 | +``` |
| 24 | +Manifest-Version: 1.0 |
| 25 | +Implementation-Title: H2 Database Engine |
| 26 | +Implementation-URL: https://h2database.com |
| 27 | +Implementation-Version: 2.2.224 |
| 28 | +Build-Jdk: 1.8 |
| 29 | +Created-By: 1.8.0_281-b09 (Oracle Corporation) |
| 30 | +Main-Class: org.h2.tools.Console |
| 31 | +Automatic-Module-Name: com.h2database |
| 32 | +Bundle-Activator: org.h2.util.DbDriverActivator |
| 33 | +Bundle-ManifestVersion: 2 |
| 34 | +Bundle-Name: H2 Database Engine |
| 35 | +Bundle-SymbolicName: com.h2database |
| 36 | +Bundle-Vendor: H2 Group |
| 37 | +Bundle-Version: 2.2.224 |
| 38 | +Bundle-License: https://h2database.com/html/license.html |
| 39 | +Bundle-Category: jdbc |
| 40 | +Multi-Release: true |
| 41 | +Import-Package: javax.crypto,javax.crypto.spec,javax.management,javax.naming;resolution:=optional,javax.naming.directory;resolution:=optional,.. |
| 42 | +Export-Package: org.h2;version="2.2.224",org.h2.api;version="2.2.224",org.h2.constant;version="2.2.224",org.h2.fulltext;version="2.2.224"... |
| 43 | +Provide-Capability: osgi.service;objectClass:List<String>=org.osgi.service.jdbc.DataSourceFactory |
| 44 | +Premain-Class: org.h2.util.Profiler |
| 45 | +``` |
| 46 | + |
| 47 | +You'll notice keys like `Import-Package` and `Export-Package` are very long and hard to read. `mf` allows enabling structured output (`-s` or `--structured`) that supports certain well-known keys and when enabled will print the values as lists or maps. |
| 48 | + |
| 49 | +[source,console] |
| 50 | +---- |
| 51 | +mf `jbang info jar com.h2database:h2:2.2.224` -s |
| 52 | +---- |
| 53 | + |
| 54 | +[source,bash] |
| 55 | +---- |
| 56 | +Manifest-Version: 1.0 |
| 57 | +Implementation-Title: H2 Database Engine |
| 58 | +... |
| 59 | +Import-Package: |
| 60 | + javax.crypto: true |
| 61 | + javax.crypto.spec: true |
| 62 | + javax.management: true |
| 63 | + javax.naming: |
| 64 | + resolution: optional |
| 65 | + javax.naming.directory: |
| 66 | + resolution: optional |
| 67 | + javax.naming.spi: |
| 68 | + resolution: optional |
| 69 | + ... |
| 70 | +Export-Package: |
| 71 | + org.h2: |
| 72 | + version: 2.2.224 |
| 73 | + org.h2.api: |
| 74 | + version: 2.2.224 |
| 75 | + org.h2.constant: |
| 76 | + version: 2.2.224 |
| 77 | + org.h2.fulltext: |
| 78 | + version: 2.2.224 |
| 79 | +... |
| 80 | +Provide-Capability: osgi.service;objectClass:List<String>=org.osgi.service.jdbc.DataSourceFactory |
| 81 | +Premain-Class: org.h2.util.Profiler |
| 82 | +---- |
| 83 | + |
| 84 | +Still long, but much easier to read. |
| 85 | + |
| 86 | +== Filtering |
| 87 | + |
| 88 | +`mf` supports filtering the manifest keys using a regex. |
| 89 | + |
| 90 | +In its simplest form it lets you substring on keys |
| 91 | + |
| 92 | +[source,bash] |
| 93 | +---- |
| 94 | +mf `jbang info jar com.h2database:h2:2.2.224` -s version |
| 95 | +---- |
| 96 | + |
| 97 | +[source,bash] |
| 98 | +---- |
| 99 | +Manifest-Version: 1.0 |
| 100 | +Implementation-Version: 2.2.224 |
| 101 | +... |
| 102 | +---- |
| 103 | + |
| 104 | +but you can also use a regex to filter the keys. |
| 105 | + |
| 106 | +[source,bash] |
| 107 | +---- |
| 108 | +mf `jbang info jar com.h2database:h2:2.2.224` "bundle|version" |
| 109 | +---- |
| 110 | + |
| 111 | +[source,bash] |
| 112 | +---- |
| 113 | +Manifest-Version: 1.0 |
| 114 | +Implementation-Version: 2.2.224 |
| 115 | +Bundle-Activator: org.h2.util.DbDriverActivator |
| 116 | +Bundle-ManifestVersion: 2 |
| 117 | +Bundle-Name: H2 Database Engine |
| 118 | +Bundle-SymbolicName: com.h2database |
| 119 | +Bundle-Vendor: H2 Group |
| 120 | +Bundle-Version: 2.2.224 |
| 121 | +Bundle-License: https://h2database.com/html/license.html |
| 122 | +Bundle-Category: jdbc |
| 123 | +---- |
| 124 | + |
| 125 | +== JSON & YAML |
| 126 | + |
| 127 | +Finally, `mf` supports JSON(`--json`) and YAML(`--yaml`) output. |
| 128 | + |
| 129 | +[source,bash] |
| 130 | +---- |
| 131 | +mf `jbang info jar com.h2database:h2:2.2.224` --json |
| 132 | +---- |
| 133 | + |
| 134 | +and they can be combined with the other options: |
| 135 | + |
| 136 | +[source,bash] |
| 137 | +---- |
| 138 | +mf `jbang info jar com.h2database:h2:2.2.224` --yaml -s "version|package" |
| 139 | +---- |
| 140 | + |
| 141 | +[source,yaml] |
| 142 | +---- |
| 143 | +Manifest-Version: "1.0" |
| 144 | +Implementation-Version: "2.2.224" |
| 145 | +Bundle-ManifestVersion: "2" |
| 146 | +Bundle-Version: "2.2.224" |
| 147 | +Import-Package: |
| 148 | + javax.crypto: true |
| 149 | + javax.crypto.spec: true |
| 150 | + javax.management: true |
| 151 | + javax.naming: |
| 152 | + resolution: "optional" |
| 153 | + javax.naming.directory: |
| 154 | + resolution: "optional" |
| 155 | + javax.naming.spi: |
| 156 | + resolution: "optional" |
| 157 | + javax.net: true |
| 158 | + javax.net.ssl: true |
| 159 | + javax.script: |
| 160 | + resolution: "optional" |
| 161 | + ... |
| 162 | +Export-Package: |
| 163 | + org.h2: |
| 164 | + version: "2.2.224" |
| 165 | + org.h2.api: |
| 166 | + version: "2.2.224" |
| 167 | + org.h2.constant: |
| 168 | + version: "2.2.224" |
| 169 | + org.h2.fulltext: |
| 170 | + version: "2.2.224" |
| 171 | + org.h2.jdbc: |
| 172 | + version: "2.2.224" |
| 173 | + ... |
| 174 | +---- |
| 175 | + |
0 commit comments