Get the software version from Maven. @return The version of the software.
()
| 475 | * @return The version of the software. |
| 476 | */ |
| 477 | public static String getOrcVersion() { |
| 478 | Class<OrcFile> cls = OrcFile.class; |
| 479 | // try to load from maven properties first |
| 480 | try (InputStream is = cls.getResourceAsStream( |
| 481 | "/META-INF/maven/org.apache.orc/orc-core/pom.properties")) { |
| 482 | if (is != null) { |
| 483 | Properties p = new Properties(); |
| 484 | p.load(is); |
| 485 | String version = p.getProperty("version", null); |
| 486 | if (version != null) { |
| 487 | return version; |
| 488 | } |
| 489 | } |
| 490 | } catch (IOException e) { |
| 491 | // ignore |
| 492 | } |
| 493 | |
| 494 | // fallback to using Java API |
| 495 | Package aPackage = cls.getPackage(); |
| 496 | if (aPackage != null) { |
| 497 | String version = aPackage.getImplementationVersion(); |
| 498 | if (version != null) { |
| 499 | return version; |
| 500 | } |
| 501 | } |
| 502 | return "unknown"; |
| 503 | } |
| 504 | } |