@Test public void testManifestWithVersioningAndBuildInfo() throws IOException { final File narDir = new File("src/test/resources/nars/nar-with-versioning"); final BundleDetails narDetails = NarBundleUtil.fromNarDirectory(narDir); assertEquals(narDir.getPath(), narDetails.getWorkingDirectory().getPath()); assertEquals("org.apache.nifi", narDetails.getCoordinate().getGroup()); assertEquals("nifi-hadoop-nar", narDetails.getCoordinate().getId()); assertEquals("1.2.0", narDetails.getCoordinate().getVersion()); assertEquals("org.apache.nifi.hadoop", narDetails.getDependencyCoordinate().getGroup()); assertEquals("nifi-hadoop-libraries-nar", narDetails.getDependencyCoordinate().getId()); assertEquals("1.2.1", narDetails.getDependencyCoordinate().getVersion()); assertEquals("NIFI-3380", narDetails.getBuildBranch()); assertEquals("1.8.0_74", narDetails.getBuildJdk()); assertEquals("a032175", narDetails.getBuildRevision()); assertEquals("HEAD", narDetails.getBuildTag()); assertEquals("2017-01-23T10:36:27Z", narDetails.getBuildTimestamp()); assertEquals("bbende", narDetails.getBuiltBy()); }
public static BundleDetails fromNarDirectory(final File narDirectory) throws IOException, IllegalStateException { if (narDirectory == null) { throw new IllegalArgumentException("NAR Directory cannot be null"); } final File manifestFile = new File(narDirectory, "META-INF/MANIFEST.MF"); try (final FileInputStream fis = new FileInputStream(manifestFile)) { final Manifest manifest = new Manifest(fis); final Attributes attributes = manifest.getMainAttributes(); final BundleDetails.Builder builder = new BundleDetails.Builder(); builder.workingDir(narDirectory); final String group = attributes.getValue(NarManifestEntry.NAR_GROUP.getManifestName()); final String id = attributes.getValue(NarManifestEntry.NAR_ID.getManifestName()); final String version = attributes.getValue(NarManifestEntry.NAR_VERSION.getManifestName()); builder.coordinate(new BundleCoordinate(group, id, version)); final String dependencyGroup = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_GROUP.getManifestName()); final String dependencyId = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_ID.getManifestName()); final String dependencyVersion = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_VERSION.getManifestName()); if (!StringUtils.isBlank(dependencyId)) { builder.dependencyCoordinate(new BundleCoordinate(dependencyGroup, dependencyId, dependencyVersion)); } builder.buildBranch(attributes.getValue(NarManifestEntry.BUILD_BRANCH.getManifestName())); builder.buildTag(attributes.getValue(NarManifestEntry.BUILD_TAG.getManifestName())); builder.buildRevision(attributes.getValue(NarManifestEntry.BUILD_REVISION.getManifestName())); builder.buildTimestamp(attributes.getValue(NarManifestEntry.BUILD_TIMESTAMP.getManifestName())); builder.buildJdk(attributes.getValue(NarManifestEntry.BUILD_JDK.getManifestName())); builder.builtBy(attributes.getValue(NarManifestEntry.BUILT_BY.getManifestName())); return builder.build(); } }
NarBundleUtil { public static BundleDetails fromNarDirectory(final File narDirectory) throws IOException, IllegalStateException { if (narDirectory == null) { throw new IllegalArgumentException("NAR Directory cannot be null"); } final File manifestFile = new File(narDirectory, "META-INF/MANIFEST.MF"); try (final FileInputStream fis = new FileInputStream(manifestFile)) { final Manifest manifest = new Manifest(fis); final Attributes attributes = manifest.getMainAttributes(); final BundleDetails.Builder builder = new BundleDetails.Builder(); builder.workingDir(narDirectory); final String group = attributes.getValue(NarManifestEntry.NAR_GROUP.getManifestName()); final String id = attributes.getValue(NarManifestEntry.NAR_ID.getManifestName()); final String version = attributes.getValue(NarManifestEntry.NAR_VERSION.getManifestName()); builder.coordinate(new BundleCoordinate(group, id, version)); final String dependencyGroup = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_GROUP.getManifestName()); final String dependencyId = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_ID.getManifestName()); final String dependencyVersion = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_VERSION.getManifestName()); if (!StringUtils.isBlank(dependencyId)) { builder.dependencyCoordinate(new BundleCoordinate(dependencyGroup, dependencyId, dependencyVersion)); } builder.buildBranch(attributes.getValue(NarManifestEntry.BUILD_BRANCH.getManifestName())); builder.buildTag(attributes.getValue(NarManifestEntry.BUILD_TAG.getManifestName())); builder.buildRevision(attributes.getValue(NarManifestEntry.BUILD_REVISION.getManifestName())); builder.buildTimestamp(attributes.getValue(NarManifestEntry.BUILD_TIMESTAMP.getManifestName())); builder.buildJdk(attributes.getValue(NarManifestEntry.BUILD_JDK.getManifestName())); builder.builtBy(attributes.getValue(NarManifestEntry.BUILT_BY.getManifestName())); return builder.build(); } } }
NarBundleUtil { public static BundleDetails fromNarDirectory(final File narDirectory) throws IOException, IllegalStateException { if (narDirectory == null) { throw new IllegalArgumentException("NAR Directory cannot be null"); } final File manifestFile = new File(narDirectory, "META-INF/MANIFEST.MF"); try (final FileInputStream fis = new FileInputStream(manifestFile)) { final Manifest manifest = new Manifest(fis); final Attributes attributes = manifest.getMainAttributes(); final BundleDetails.Builder builder = new BundleDetails.Builder(); builder.workingDir(narDirectory); final String group = attributes.getValue(NarManifestEntry.NAR_GROUP.getManifestName()); final String id = attributes.getValue(NarManifestEntry.NAR_ID.getManifestName()); final String version = attributes.getValue(NarManifestEntry.NAR_VERSION.getManifestName()); builder.coordinate(new BundleCoordinate(group, id, version)); final String dependencyGroup = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_GROUP.getManifestName()); final String dependencyId = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_ID.getManifestName()); final String dependencyVersion = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_VERSION.getManifestName()); if (!StringUtils.isBlank(dependencyId)) { builder.dependencyCoordinate(new BundleCoordinate(dependencyGroup, dependencyId, dependencyVersion)); } builder.buildBranch(attributes.getValue(NarManifestEntry.BUILD_BRANCH.getManifestName())); builder.buildTag(attributes.getValue(NarManifestEntry.BUILD_TAG.getManifestName())); builder.buildRevision(attributes.getValue(NarManifestEntry.BUILD_REVISION.getManifestName())); builder.buildTimestamp(attributes.getValue(NarManifestEntry.BUILD_TIMESTAMP.getManifestName())); builder.buildJdk(attributes.getValue(NarManifestEntry.BUILD_JDK.getManifestName())); builder.builtBy(attributes.getValue(NarManifestEntry.BUILT_BY.getManifestName())); return builder.build(); } }  }
NarBundleUtil { public static BundleDetails fromNarDirectory(final File narDirectory) throws IOException, IllegalStateException { if (narDirectory == null) { throw new IllegalArgumentException("NAR Directory cannot be null"); } final File manifestFile = new File(narDirectory, "META-INF/MANIFEST.MF"); try (final FileInputStream fis = new FileInputStream(manifestFile)) { final Manifest manifest = new Manifest(fis); final Attributes attributes = manifest.getMainAttributes(); final BundleDetails.Builder builder = new BundleDetails.Builder(); builder.workingDir(narDirectory); final String group = attributes.getValue(NarManifestEntry.NAR_GROUP.getManifestName()); final String id = attributes.getValue(NarManifestEntry.NAR_ID.getManifestName()); final String version = attributes.getValue(NarManifestEntry.NAR_VERSION.getManifestName()); builder.coordinate(new BundleCoordinate(group, id, version)); final String dependencyGroup = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_GROUP.getManifestName()); final String dependencyId = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_ID.getManifestName()); final String dependencyVersion = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_VERSION.getManifestName()); if (!StringUtils.isBlank(dependencyId)) { builder.dependencyCoordinate(new BundleCoordinate(dependencyGroup, dependencyId, dependencyVersion)); } builder.buildBranch(attributes.getValue(NarManifestEntry.BUILD_BRANCH.getManifestName())); builder.buildTag(attributes.getValue(NarManifestEntry.BUILD_TAG.getManifestName())); builder.buildRevision(attributes.getValue(NarManifestEntry.BUILD_REVISION.getManifestName())); builder.buildTimestamp(attributes.getValue(NarManifestEntry.BUILD_TIMESTAMP.getManifestName())); builder.buildJdk(attributes.getValue(NarManifestEntry.BUILD_JDK.getManifestName())); builder.builtBy(attributes.getValue(NarManifestEntry.BUILT_BY.getManifestName())); return builder.build(); } }  static BundleDetails fromNarDirectory(final File narDirectory); }
NarBundleUtil { public static BundleDetails fromNarDirectory(final File narDirectory) throws IOException, IllegalStateException { if (narDirectory == null) { throw new IllegalArgumentException("NAR Directory cannot be null"); } final File manifestFile = new File(narDirectory, "META-INF/MANIFEST.MF"); try (final FileInputStream fis = new FileInputStream(manifestFile)) { final Manifest manifest = new Manifest(fis); final Attributes attributes = manifest.getMainAttributes(); final BundleDetails.Builder builder = new BundleDetails.Builder(); builder.workingDir(narDirectory); final String group = attributes.getValue(NarManifestEntry.NAR_GROUP.getManifestName()); final String id = attributes.getValue(NarManifestEntry.NAR_ID.getManifestName()); final String version = attributes.getValue(NarManifestEntry.NAR_VERSION.getManifestName()); builder.coordinate(new BundleCoordinate(group, id, version)); final String dependencyGroup = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_GROUP.getManifestName()); final String dependencyId = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_ID.getManifestName()); final String dependencyVersion = attributes.getValue(NarManifestEntry.NAR_DEPENDENCY_VERSION.getManifestName()); if (!StringUtils.isBlank(dependencyId)) { builder.dependencyCoordinate(new BundleCoordinate(dependencyGroup, dependencyId, dependencyVersion)); } builder.buildBranch(attributes.getValue(NarManifestEntry.BUILD_BRANCH.getManifestName())); builder.buildTag(attributes.getValue(NarManifestEntry.BUILD_TAG.getManifestName())); builder.buildRevision(attributes.getValue(NarManifestEntry.BUILD_REVISION.getManifestName())); builder.buildTimestamp(attributes.getValue(NarManifestEntry.BUILD_TIMESTAMP.getManifestName())); builder.buildJdk(attributes.getValue(NarManifestEntry.BUILD_JDK.getManifestName())); builder.builtBy(attributes.getValue(NarManifestEntry.BUILT_BY.getManifestName())); return builder.build(); } }  static BundleDetails fromNarDirectory(final File narDirectory);  }