@Override public Package resolvePackage(final Path resource) { return resourceResolver.resolvePackage(resource); } }
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);
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);
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);
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);
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 org.guvnor.common.services.project.model.Package resolveDefaultPackage(final Module module) { final Set<String> packageNames = new HashSet<>(); if (module == null) { return null; } //Build a set of all package names across /src/main/java, /src/main/resources, /src/test/java and /src/test/resources paths //It is possible (if the module was not created within the workbench that some packages only exist in certain paths) final Path moduleRoot = module.getRootPath(); final org.uberfire.java.nio.file.Path nioModuleRootPath = Paths.convert(moduleRoot); for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioModuleRootPath.resolve(src); packageNames.addAll(getPackageNames(nioModuleRootPath, nioPackageRootSrcPath, true, true, false)); } //Construct Package objects for each package name final java.util.Set<String> resolvedPackages = new java.util.HashSet<>(); for (String packagePathSuffix : packageNames) { for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackagePath = nioModuleRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { return resolvePackage(Paths.convert(nioPackagePath)); } } } return null; }
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 org.guvnor.common.services.project.model.Package resolveDefaultPackage(final Project project) { final Set<String> packageNames = new HashSet<String>(); if (project == null) { return null; } //Build a set of all package names across /src/main/java, /src/main/resources, /src/test/java and /src/test/resources paths //It is possible (if the project was not created within the workbench that some packages only exist in certain paths) final Path projectRoot = project.getRootPath(); final org.uberfire.java.nio.file.Path nioProjectRootPath = Paths.convert(projectRoot); for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioProjectRootPath.resolve(src); packageNames.addAll(getPackageNames(nioProjectRootPath, nioPackageRootSrcPath, true, true, false)); } //Construct Package objects for each package name final java.util.Set<String> resolvedPackages = new java.util.HashSet<String>(); for (String packagePathSuffix : packageNames) { for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackagePath = nioProjectRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { return resolvePackage(Paths.convert(nioPackagePath)); } } } return null; }
@Override public org.guvnor.common.services.project.model.Package resolveDefaultPackage(final Module module) { final Set<String> packageNames = new HashSet<>(); if (module == null) { return null; } //Build a set of all package names across /src/main/java, /src/main/resources, /src/test/java and /src/test/resources paths //It is possible (if the module was not created within the workbench that some packages only exist in certain paths) final Path moduleRoot = module.getRootPath(); final org.uberfire.java.nio.file.Path nioModuleRootPath = Paths.convert(moduleRoot); for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackageRootSrcPath = nioModuleRootPath.resolve(src); packageNames.addAll(getPackageNames(nioModuleRootPath, nioPackageRootSrcPath, true, true, false)); } //Construct Package objects for each package name final java.util.Set<String> resolvedPackages = new java.util.HashSet<>(); for (String packagePathSuffix : packageNames) { for (String src : SOURCE_PATHS) { final org.uberfire.java.nio.file.Path nioPackagePath = nioModuleRootPath.resolve(src).resolve(packagePathSuffix); if (Files.exists(nioPackagePath) && !resolvedPackages.contains(packagePathSuffix)) { return resolvePackage(Paths.convert(nioPackagePath)); } } } return null; }
@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 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 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()); }
@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)); }
@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)); }
@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)); }
return resolvePackage(Paths.convert(nioPackagePath));
return resolvePackage(Paths.convert(nioPackagePath));
return resolvePackage(Paths.convert(nioPackagePath));
final Package newPackage = resolvePackage(pkgPath); return newPackage; } catch (Exception e) {