本文整理了Java中org.guvnor.common.services.project.model.Package.getPackageMainSrcPath()
方法的一些代码示例,展示了Package.getPackageMainSrcPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.getPackageMainSrcPath()
方法的具体详情如下:
包路径:org.guvnor.common.services.project.model.Package
类名称:Package
方法名:getPackageMainSrcPath
暂无
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Override
public Path resolveDefaultPath(Package pkg) {
return pkg.getPackageMainSrcPath();
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Override
public boolean accept(final Path path) {
final Package pkg = moduleService.resolvePackage(path);
if (pkg == null) {
return false;
}
return pkg.getPackageMainSrcPath().equals(path) ||
pkg.getPackageMainResourcesPath().equals(path) ||
pkg.getPackageTestSrcPath().equals(path) ||
pkg.getPackageTestResourcesPath().equals(path);
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-backend
public List<FolderItem> getItems(final Package pkg,
final ActiveOptions options) {
final List<FolderItem> folderItems = new ArrayList<FolderItem>();
if (pkg == null) {
return emptyList();
}
final Set<Package> childPackages = moduleService.resolvePackages(pkg);
for (final Package childPackage : childPackages) {
folderItems.add(toFolderItem(childPackage));
}
folderItems.addAll(getItems(pkg.getPackageMainSrcPath(),
options));
folderItems.addAll(getItems(pkg.getPackageTestSrcPath(),
options));
folderItems.addAll(getItems(pkg.getPackageMainResourcesPath(),
options));
folderItems.addAll(getItems(pkg.getPackageTestResourcesPath(),
options));
Collections.sort(folderItems,
Sorters.ITEM_SORTER);
return folderItems;
}
代码示例来源:origin: org.kie.workbench.widgets/kie-wb-common-ui
@Override
public Path getTargetPath() {
if (thereIsAnActiveProject()) {
final String path = presenter.getPath().toURI();
final Package selectedPackage = packageListBox.getSelectedPackage();
if (path.contains(ModuleResourcePaths.MAIN_RESOURCES_PATH)) {
return selectedPackage.getPackageMainResourcesPath();
} else if (path.contains(ModuleResourcePaths.MAIN_SRC_PATH)) {
return selectedPackage.getPackageMainSrcPath();
} else if (path.contains(ModuleResourcePaths.TEST_RESOURCES_PATH)) {
return selectedPackage.getPackageTestResourcesPath();
} else if (path.contains(ModuleResourcePaths.TEST_SRC_PATH)) {
return selectedPackage.getPackageTestSrcPath();
}
}
return null;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Before
public void setUp() {
resolver = new JavaFileProjectResourcePathResolver();
when( pkg.getPackageMainSrcPath() ).thenReturn( packageMainSrcPath );
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-client
private Path getFolderItemPath(final FolderItem folderItem) {
if (folderItem.getItem() instanceof Package) {
final Package pkg = ((Package) folderItem.getItem());
return pkg.getPackageMainSrcPath();
} else if (folderItem.getItem() instanceof Path) {
return (Path) folderItem.getItem();
}
return null;
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-data-modeller-backend
private void prepareEnsurePackageTest() {
module = mock(Module.class);
defaultPackage = mock(Package.class);
Path mainSrcPath = Paths.convert(testRootPath.resolve("myProject/src/main/java"));
when(moduleService.resolveDefaultPackage(module)).thenReturn(defaultPackage);
when(defaultPackage.getPackageMainSrcPath()).thenReturn(mainSrcPath);
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-data-modeller-backend
public Package ensurePackageStructure(final Module module,
final String packageName) {
if (packageName == null || "".equals(packageName) || module == null) {
return null;
}
final Package defaultPackage = moduleService.resolveDefaultPackage(module);
final Path defaultPackagePath = Paths.convert(defaultPackage.getPackageMainSrcPath());
final String newPackageName = packageName.replace(".", "/");
final Path newPackagePath = defaultPackagePath.resolve(newPackageName);
if (!ioService.exists(newPackagePath)) {
return moduleService.newPackage(defaultPackage,
packageName);
} else {
return moduleService.resolvePackage(Paths.convert(newPackagePath));
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-datamodel-backend
public void invalidateProjectPackagesCache(@Observes final InvalidateDMOModuleCacheEvent event) {
PortablePreconditions.checkNotNull("event",
event);
final Path resourcePath = event.getResourcePath();
final KieModule module = moduleService.resolveModule(resourcePath);
//If resource was not within a Module there's nothing to invalidate
if (module == null) {
return;
}
final String moduleUri = module.getRootPath().toURI();
final List<Package> cacheEntriesToInvalidate = new ArrayList<Package>();
for (final Package pkg : getKeys()) {
final Path packageMainSrcPath = pkg.getPackageMainSrcPath();
final Path packageTestSrcPath = pkg.getPackageTestSrcPath();
final Path packageMainResourcesPath = pkg.getPackageMainResourcesPath();
final Path packageTestResourcesPath = pkg.getPackageTestResourcesPath();
if (packageMainSrcPath != null && packageMainSrcPath.toURI().startsWith(moduleUri)) {
cacheEntriesToInvalidate.add(pkg);
} else if (packageTestSrcPath != null && packageTestSrcPath.toURI().startsWith(moduleUri)) {
cacheEntriesToInvalidate.add(pkg);
} else if (packageMainResourcesPath != null && packageMainResourcesPath.toURI().startsWith(moduleUri)) {
cacheEntriesToInvalidate.add(pkg);
} else if (packageTestResourcesPath != null && packageTestResourcesPath.toURI().startsWith(moduleUri)) {
cacheEntriesToInvalidate.add(pkg);
}
}
for (final Package pkg : cacheEntriesToInvalidate) {
invalidateCache(pkg);
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolveByDefaultPath() {
assertEquals( packageMainSrcPath, resolver.resolveDefaultPath( pkg ) );
verify( pkg, times( 1 ) ).getPackageMainSrcPath();
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Before
public void setUp() {
super.setUp();
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean,
KieModuleService.class,
cc);
assertNotNull(moduleService);
final Set<Bean<?>> beans = beanManager.getBeans(ResourceTypeDefinition.class);
assertNotNull(beans);
assertFalse(beans.isEmpty());
resourceTypes = beans.stream()
.map(bean -> ((ResourceTypeDefinition) beanManager.getReference(bean,
bean.getBeanClass(),
cc)).getSuffix())
.collect(Collectors.toList());
pkg = mock(Package.class);
packageMainResourcesPath = mock(Path.class);
packageMainSrcPath = mock(Path.class);
when(pkg.getPackageMainResourcesPath()).thenReturn(packageMainResourcesPath);
when(pkg.getPackageMainSrcPath()).thenReturn(packageMainSrcPath);
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-data-modeller-backend
/**
* Given a path within a module calculates the expected class name for the given class.
*/
public String calculateClassName(final Module module,
final org.uberfire.backend.vfs.Path path) {
PortablePreconditions.checkNotNull("module", module);
if (path == null) {
return null;
}
final Package defaultPackage = moduleService.resolveDefaultPackage(module);
if (defaultPackage == null) {
return null;
}
final Path mainSrcNioPath = Paths.convert(defaultPackage.getPackageMainSrcPath());
final Path testSrcNioPath = Paths.convert(defaultPackage.getPackageTestSrcPath());
final Path nioPath = Paths.convert(path);
Path relativePath = null;
if (mainSrcNioPath != null && nioPath.startsWith(mainSrcNioPath)) {
relativePath = mainSrcNioPath.relativize(nioPath);
} else if (testSrcNioPath != null && nioPath.startsWith(testSrcNioPath)) {
relativePath = testSrcNioPath.relativize(nioPath);
}
if (relativePath != null) {
String className = relativePath.toString().replace("/", ".");
return className.substring(0, className.lastIndexOf(".java"));
}
return null;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageDefaultJava() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean,
KieModuleService.class,
cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test /src/main/java resolves as the default package
final Package result = moduleService.resolvePackage(testPath);
assertEquals(rootPath.toURI(),
result.getPackageMainSrcPath().toURI());
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageWithJavaFileInDefaultPackage() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean,
KieModuleService.class,
cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java/Bean.java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test a Java file resolves to the containing package
final Package result = moduleService.resolvePackage(testPath);
assertEquals(rootPath.toURI(),
result.getPackageMainSrcPath().toURI());
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageWithJavaFileInSubPackage() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean,
KieModuleService.class,
cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java/org/kie/test");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java/org/kie/test/Bean.java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test a Java file resolves to the containing package
final Package result = moduleService.resolvePackage(testPath);
assertEquals(rootPath.toURI(),
result.getPackageMainSrcPath().toURI());
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-client
final Path pkgMainSrcPath = pkg.getPackageMainSrcPath();
final Path pkgTestSrcPath = pkg.getPackageTestSrcPath();
final Path pkgMainResourcesPath = pkg.getPackageMainResourcesPath();
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-backend
public boolean hasAssets(final Package pkg) {
if (pkg == null) {
return false;
}
if (hasAssets(pkg.getPackageMainSrcPath())
|| hasAssets(pkg.getPackageTestSrcPath())
|| hasAssets(pkg.getPackageMainResourcesPath())
|| hasAssets(pkg.getPackageTestResourcesPath())) {
return true;
}
final Set<Package> childPackages = moduleService.resolvePackages(pkg);
for (final Package childPackage : childPackages) {
if (!childPackage.equals(pkg) && hasAssets(childPackage)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-client
final Path pkgMainSrcPath = pkg.getPackageMainSrcPath();
final Path pkgTestSrcPath = pkg.getPackageTestSrcPath();
final Path pkgMainResourcesPath = pkg.getPackageMainResourcesPath();
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-backend
return new ArrayList<Path>(4) {{
add(pkg.getPackageMainResourcesPath());
add(pkg.getPackageMainSrcPath());
add(pkg.getPackageTestResourcesPath());
add(pkg.getPackageTestSrcPath());
return new ArrayList<Path>(4) {{
add(pkg.getPackageMainResourcesPath());
add(pkg.getPackageMainSrcPath());
add(pkg.getPackageTestResourcesPath());
add(pkg.getPackageTestSrcPath());
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-data-modeller-backend
Path testSrcPath = Paths.convert(testRootPath.resolve("myProject/src/test/java"));
when(defaultPackage.getPackageMainSrcPath()).thenReturn(mainSrcPath);
when(defaultPackage.getPackageTestSrcPath()).thenReturn(testSrcPath);
内容来源于网络,如有侵权,请联系作者删除!