@Test(description = "Test if get balo path") public void getBaloPath() throws InvalidModuleException { Project project = context.get(Project.PROJECT_KEY); Names names = Names.getInstance(context); PackageID moduleId = new PackageID(names.fromString("abc"), names.fromString("fruits"), names.fromString("0.0.1")); String baloName = "fruits-" + ProgramFileConstants.IMPLEMENTATION_VERSION + "-any-0.0.1.balo"; Path baloPath = directoryManager.getSourceDirectory().getPath() .resolve("target").resolve("balo").resolve(baloName); Assert.assertEquals(project.getBaloPath(moduleId), baloPath); try { PackageID invalidModuleId = new PackageID(names.fromString("invalid"), names.fromString("fruits"), names.fromString("0.0.1")); project.getBaloPath(invalidModuleId); throw new AssertionError("Failed to identify invalid module"); } catch (InvalidModuleException e) { } }
@Override public Path getBaloPath(PackageID moduleId) throws InvalidModuleException { if (!isModuleExists(moduleId)) { throw new InvalidModuleException(); } String versionNo = manifest.getProject().getVersion(); String platform = manifest.getTargetPlatform(moduleId.name.value); String baloFileName = moduleId.name.value + "-" + ProgramFileConstants.IMPLEMENTATION_VERSION + "-" + platform + "-" + versionNo + BLANG_COMPILED_PKG_BINARY_EXT; return sourceDirectory.getPath() .resolve(ProjectDirConstants.TARGET_DIR_NAME) .resolve(ProjectDirConstants.TARGET_BALO_DIRECTORY) .resolve(baloFileName); }
SourceDirectoryManager implements Project { @Override public Path getBaloPath(PackageID moduleId) throws InvalidModuleException { if (!isModuleExists(moduleId)) { throw new InvalidModuleException(); } String versionNo = manifest.getProject().getVersion(); String platform = manifest.getTargetPlatform(moduleId.name.value); String baloFileName = moduleId.name.value + "-" + ProgramFileConstants.IMPLEMENTATION_VERSION + "-" + platform + "-" + versionNo + BLANG_COMPILED_PKG_BINARY_EXT; return sourceDirectory.getPath() .resolve(ProjectDirConstants.TARGET_DIR_NAME) .resolve(ProjectDirConstants.TARGET_BALO_DIRECTORY) .resolve(baloFileName); } }
SourceDirectoryManager implements Project { @Override public Path getBaloPath(PackageID moduleId) throws InvalidModuleException { if (!isModuleExists(moduleId)) { throw new InvalidModuleException(); } String versionNo = manifest.getProject().getVersion(); String platform = manifest.getTargetPlatform(moduleId.name.value); String baloFileName = moduleId.name.value + "-" + ProgramFileConstants.IMPLEMENTATION_VERSION + "-" + platform + "-" + versionNo + BLANG_COMPILED_PKG_BINARY_EXT; return sourceDirectory.getPath() .resolve(ProjectDirConstants.TARGET_DIR_NAME) .resolve(ProjectDirConstants.TARGET_BALO_DIRECTORY) .resolve(baloFileName); } private  SourceDirectoryManager(CompilerContext context); }
SourceDirectoryManager implements Project { @Override public Path getBaloPath(PackageID moduleId) throws InvalidModuleException { if (!isModuleExists(moduleId)) { throw new InvalidModuleException(); } String versionNo = manifest.getProject().getVersion(); String platform = manifest.getTargetPlatform(moduleId.name.value); String baloFileName = moduleId.name.value + "-" + ProgramFileConstants.IMPLEMENTATION_VERSION + "-" + platform + "-" + versionNo + BLANG_COMPILED_PKG_BINARY_EXT; return sourceDirectory.getPath() .resolve(ProjectDirConstants.TARGET_DIR_NAME) .resolve(ProjectDirConstants.TARGET_BALO_DIRECTORY) .resolve(baloFileName); } private  SourceDirectoryManager(CompilerContext context); static SourceDirectoryManager getInstance(CompilerContext context); Stream<PackageID> listSourceFilesAndPackages(); PackageID getPackageID(String sourcePackage); SourceDirectory getSourceDirectory(); @Override boolean isModuleExists(PackageID moduleId); @Override Path getBaloPath(PackageID moduleId); }
SourceDirectoryManager implements Project { @Override public Path getBaloPath(PackageID moduleId) throws InvalidModuleException { if (!isModuleExists(moduleId)) { throw new InvalidModuleException(); } String versionNo = manifest.getProject().getVersion(); String platform = manifest.getTargetPlatform(moduleId.name.value); String baloFileName = moduleId.name.value + "-" + ProgramFileConstants.IMPLEMENTATION_VERSION + "-" + platform + "-" + versionNo + BLANG_COMPILED_PKG_BINARY_EXT; return sourceDirectory.getPath() .resolve(ProjectDirConstants.TARGET_DIR_NAME) .resolve(ProjectDirConstants.TARGET_BALO_DIRECTORY) .resolve(baloFileName); } private  SourceDirectoryManager(CompilerContext context); static SourceDirectoryManager getInstance(CompilerContext context); Stream<PackageID> listSourceFilesAndPackages(); PackageID getPackageID(String sourcePackage); SourceDirectory getSourceDirectory(); @Override boolean isModuleExists(PackageID moduleId); @Override Path getBaloPath(PackageID moduleId);  }