@Test void shouldParseVersionedBuild() { URL bazelVersioned = BazelInfoReaderTest.class.getClassLoader().getResource(BAZEL_VERSIONED); File file = Urls.toFile(bazelVersioned); Path root = file.toPath().getParent(); BuildInfo info = new BazelInfoReader().getInfo(root); assertNotNull(info); assertEquals("bazel-versioned", info.getName()); assertEquals("0.0.1", info.getVersion()); assertEquals("jar", info.getPackaging()); }
@Override public BuildInfo getInfo(Path root) { Path build = root.resolve(BUILD); Map<String, String> properties = new HashMap<>(); properties.putAll(readBuild(build)); String name = properties.getOrDefault(NAME, properties.getOrDefault(NAME, root.getFileName().toString())); String version = properties.get(VERSION); String extension = properties.getOrDefault(EXTENSION, JAR); String classifier = properties.get(CLASSIFIER); String destinationDir = properties.getOrDefault(DESTINATION_DIR, BAZEL_BIN); Path outputDir = root.resolve(destinationDir); StringBuilder sb = new StringBuilder(); sb.append(name); if (Strings.isNotNullOrEmpty(version)) { sb.append(DASH).append(version); } if (Strings.isNotNullOrEmpty(classifier)) { sb.append(DASH).append(classifier); } sb.append(DOT).append(extension); return new BuildInfoBuilder() .withName(name) .withVersion(version) .withPackaging(extension) .withBuildTool(BAZEL) .withBuildToolVersion(null) .withOutputFile(outputDir.resolve(sb.toString())) .withClassOutputDir(root.resolve(BAZEL_OUT)) .build(); }
BazelInfoReader implements BuildInfoReader { @Override public BuildInfo getInfo(Path root) { Path build = root.resolve(BUILD); Map<String, String> properties = new HashMap<>(); properties.putAll(readBuild(build)); String name = properties.getOrDefault(NAME, properties.getOrDefault(NAME, root.getFileName().toString())); String version = properties.get(VERSION); String extension = properties.getOrDefault(EXTENSION, JAR); String classifier = properties.get(CLASSIFIER); String destinationDir = properties.getOrDefault(DESTINATION_DIR, BAZEL_BIN); Path outputDir = root.resolve(destinationDir); StringBuilder sb = new StringBuilder(); sb.append(name); if (Strings.isNotNullOrEmpty(version)) { sb.append(DASH).append(version); } if (Strings.isNotNullOrEmpty(classifier)) { sb.append(DASH).append(classifier); } sb.append(DOT).append(extension); return new BuildInfoBuilder() .withName(name) .withVersion(version) .withPackaging(extension) .withBuildTool(BAZEL) .withBuildToolVersion(null) .withOutputFile(outputDir.resolve(sb.toString())) .withClassOutputDir(root.resolve(BAZEL_OUT)) .build(); } }
BazelInfoReader implements BuildInfoReader { @Override public BuildInfo getInfo(Path root) { Path build = root.resolve(BUILD); Map<String, String> properties = new HashMap<>(); properties.putAll(readBuild(build)); String name = properties.getOrDefault(NAME, properties.getOrDefault(NAME, root.getFileName().toString())); String version = properties.get(VERSION); String extension = properties.getOrDefault(EXTENSION, JAR); String classifier = properties.get(CLASSIFIER); String destinationDir = properties.getOrDefault(DESTINATION_DIR, BAZEL_BIN); Path outputDir = root.resolve(destinationDir); StringBuilder sb = new StringBuilder(); sb.append(name); if (Strings.isNotNullOrEmpty(version)) { sb.append(DASH).append(version); } if (Strings.isNotNullOrEmpty(classifier)) { sb.append(DASH).append(classifier); } sb.append(DOT).append(extension); return new BuildInfoBuilder() .withName(name) .withVersion(version) .withPackaging(extension) .withBuildTool(BAZEL) .withBuildToolVersion(null) .withOutputFile(outputDir.resolve(sb.toString())) .withClassOutputDir(root.resolve(BAZEL_OUT)) .build(); }  }
BazelInfoReader implements BuildInfoReader { @Override public BuildInfo getInfo(Path root) { Path build = root.resolve(BUILD); Map<String, String> properties = new HashMap<>(); properties.putAll(readBuild(build)); String name = properties.getOrDefault(NAME, properties.getOrDefault(NAME, root.getFileName().toString())); String version = properties.get(VERSION); String extension = properties.getOrDefault(EXTENSION, JAR); String classifier = properties.get(CLASSIFIER); String destinationDir = properties.getOrDefault(DESTINATION_DIR, BAZEL_BIN); Path outputDir = root.resolve(destinationDir); StringBuilder sb = new StringBuilder(); sb.append(name); if (Strings.isNotNullOrEmpty(version)) { sb.append(DASH).append(version); } if (Strings.isNotNullOrEmpty(classifier)) { sb.append(DASH).append(classifier); } sb.append(DOT).append(extension); return new BuildInfoBuilder() .withName(name) .withVersion(version) .withPackaging(extension) .withBuildTool(BAZEL) .withBuildToolVersion(null) .withOutputFile(outputDir.resolve(sb.toString())) .withClassOutputDir(root.resolve(BAZEL_OUT)) .build(); }  @Override int order(); @Override boolean isApplicable(Path root); @Override BuildInfo getInfo(Path root); }
BazelInfoReader implements BuildInfoReader { @Override public BuildInfo getInfo(Path root) { Path build = root.resolve(BUILD); Map<String, String> properties = new HashMap<>(); properties.putAll(readBuild(build)); String name = properties.getOrDefault(NAME, properties.getOrDefault(NAME, root.getFileName().toString())); String version = properties.get(VERSION); String extension = properties.getOrDefault(EXTENSION, JAR); String classifier = properties.get(CLASSIFIER); String destinationDir = properties.getOrDefault(DESTINATION_DIR, BAZEL_BIN); Path outputDir = root.resolve(destinationDir); StringBuilder sb = new StringBuilder(); sb.append(name); if (Strings.isNotNullOrEmpty(version)) { sb.append(DASH).append(version); } if (Strings.isNotNullOrEmpty(classifier)) { sb.append(DASH).append(classifier); } sb.append(DOT).append(extension); return new BuildInfoBuilder() .withName(name) .withVersion(version) .withPackaging(extension) .withBuildTool(BAZEL) .withBuildToolVersion(null) .withOutputFile(outputDir.resolve(sb.toString())) .withClassOutputDir(root.resolve(BAZEL_OUT)) .build(); }  @Override int order(); @Override boolean isApplicable(Path root); @Override BuildInfo getInfo(Path root);  }