@Override public Package resolvePackage(final Path resource) { return resourceResolver.resolvePackage(resource); } }
@Override public org.guvnor.common.services.project.model.Package resolvePackage(final Path resource) { try { //Null resource paths cannot resolve to a Module if (resource == null) { return null; } //If Path is not within a Module we cannot resolve a package final Module module = resolveModule(resource); if (module == null) { return null; } //pom.xml is not inside a package if (isPom(resource)) { return null; } return makePackage(module, resource); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public Path resolveDefaultPath(Package pkg, String resourceType) { return resourceResolver.resolveDefaultPath(pkg, resourceType); }
@Override public org.guvnor.common.services.project.model.Package resolvePackage(final Path resource) { try { //Null resource paths cannot resolve to a Project if (resource == null) { return null; } //If Path is not within a Project we cannot resolve a package final Project project = resolveProject(resource); if (project == null) { return null; } //pom.xml is not inside a package if (isPom(resource)) { return null; } return makePackage(project, resource); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioProjectRootPath.resolve(src); packageNames.addAll(getPackageNames(nioProjectRootPath, nioPackageRootSrcPath, true, final org.uberfire.java.nio.file.Path nioPackagePath = nioProjectRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { packages.add(resolvePackage(Paths.convert(nioPackagePath))); resolvedPackages.add(packagePathSuffix);
@Override public Package resolveDefaultWorkspacePackage(final Project project) { final Path projectRootPath = project.getRootPath(); final GAV gav = project.getPom().getGav(); final String defaultWorkspacePackagePath = getDefaultWorkspacePath(gav); final org.uberfire.java.nio.file.Path defaultWorkspacePath = Paths.convert(projectRootPath).resolve(MAIN_RESOURCES_PATH + "/" + defaultWorkspacePackagePath); return resolvePackage(Paths.convert(defaultWorkspacePath)); }
final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioProjectRootPath.resolve(src).resolve(resolvePkgName(pkg.getCaption())); packageNames.addAll(getPackageNames(nioProjectRootPath, nioPackageRootSrcPath, false, final org.uberfire.java.nio.file.Path nioPackagePath = nioProjectRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { packages.add(resolvePackage(Paths.convert(nioPackagePath))); resolvedPackages.add(packagePathSuffix);
@Override public KieModule resolveModule(Path resource, boolean loadPOM) { return (KieModule) resourceResolver.resolveModule(resource, loadPOM); }
@Test public void getDefaultWorkspacePathTest() { final Module project = mock(Module.class); final POM pom = mock(POM.class); doReturn(pom).when(project).getPom(); final GAV gav = mock(GAV.class); doReturn(gav).when(pom).getGav(); final Path path = mock(Path.class); doReturn(path).when(project).getRootPath(); when(path.toURI()).thenReturn("file:///myproject/"); doReturn("com.group").when(gav).getGroupId(); doReturn("package").when(gav).getArtifactId(); final ArgumentCaptor<Path> packagePathArgumentCaptor = ArgumentCaptor.forClass(Path.class); resourceResolver.resolveDefaultWorkspacePackage(project); verify(resourceResolver).resolvePackage(packagePathArgumentCaptor.capture()); final Path packagePath = packagePathArgumentCaptor.getValue(); assertEquals("file:///myproject/src/main/resources/com/group/_package", packagePath.toURI()); }
@Test public void resolveDefaultWorkspacePackageTest() { final GAV gav = mock(GAV.class); doReturn("com.group").when(gav).getGroupId(); doReturn("package").when(gav).getArtifactId(); assertEquals("com/group/_package", resourceResolver.getDefaultWorkspacePath(gav)); }
packageNames.add(getPackagePathSuffix(nioModuleRootPath, nioPackageSrcPath)); for (org.uberfire.java.nio.file.Path nioChildPackageSrcPath : nioChildPackageSrcPaths) { if (recursive) { packageNames.addAll(getPackageNames(nioModuleRootPath, nioChildPackageSrcPath, includeDefault, recursive)); } else { packageNames.add(getPackagePathSuffix(nioModuleRootPath, nioChildPackageSrcPath));
final Path testResourcesPath = Paths.convert(nioTestResourcesPath.resolve(packagePath)); final String displayName = getPackageDisplayName(packageName); packageName, displayName, getPackageRelativeCaption(displayName, resource.getFileName())); return pkg;
@Override public Package resolveDefaultWorkspacePackage(final Module project) { return resourceResolver.resolveDefaultWorkspacePackage(project); }
@Override public boolean isPom(final Path resource) { return resourceResolver.isPom(resource); }
public String getDefaultWorkspacePath(final GAV gav) { return StringUtils.join(getLegalId(gav.getGroupId()), "/") + "/" + StringUtils.join(getLegalId(gav.getArtifactId()), "/"); }
for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioModuleRootPath.resolve(src); packageNames.addAll(getPackageNames(nioModuleRootPath, nioPackageRootSrcPath, true, final org.uberfire.java.nio.file.Path nioPackagePath = nioModuleRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { packages.add(resolvePackage(Paths.convert(nioPackagePath))); resolvedPackages.add(packagePathSuffix);
@Override public Package resolveDefaultWorkspacePackage(final Module module) { final Path moduleRootPath = module.getRootPath(); final GAV gav = module.getPom().getGav(); final String defaultWorkspacePackagePath = getDefaultWorkspacePath(gav); final org.uberfire.java.nio.file.Path defaultWorkspacePath = Paths.convert(moduleRootPath).resolve(MAIN_RESOURCES_PATH + "/" + defaultWorkspacePackagePath); return resolvePackage(Paths.convert(defaultWorkspacePath)); }
final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioModuleRootPath.resolve(src).resolve(resolvePkgName(pkg.getCaption())); packageNames.addAll(getPackageNames(nioModuleRootPath, nioPackageRootSrcPath, false, final org.uberfire.java.nio.file.Path nioPackagePath = nioModuleRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { packages.add(resolvePackage(Paths.convert(nioPackagePath))); resolvedPackages.add(packagePathSuffix);
@Override public T resolveModule(final Path resource) { return resolveModule(resource, true); }
@Test public void getDefaultWorkspacePathTest() { final Project project = mock(Project.class); final POM pom = mock(POM.class); doReturn(pom).when(project).getPom(); final GAV gav = mock(GAV.class); doReturn(gav).when(pom).getGav(); final Path path = mock(Path.class); doReturn(path).when(project).getRootPath(); when(path.toURI()).thenReturn("default:///myproject/"); doReturn("com.group").when(gav).getGroupId(); doReturn("package").when(gav).getArtifactId(); final ArgumentCaptor<Path> packagePathArgumentCaptor = ArgumentCaptor.forClass(Path.class); resourceResolver.resolveDefaultWorkspacePackage(project); verify(resourceResolver).resolvePackage(packagePathArgumentCaptor.capture()); final Path packagePath = packagePathArgumentCaptor.getValue(); assertEquals("default:///myproject/src/main/resources/com/group/_package", packagePath.toURI()); }