Java Code Examples for org.netbeans.api.project.FileOwnerQuery#markExternalOwner()
The following examples show how to use
org.netbeans.api.project.FileOwnerQuery#markExternalOwner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectOpenedHookImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent pce) { if (NbMavenProject.PROP_PROJECT.equals(pce.getPropertyName())) { NbMavenProjectImpl project = proj.getLookup().lookup(NbMavenProjectImpl.class); Set<URI> newuris = getProjectExternalSourceRoots(project); synchronized (uriReferences) { Set<URI> olduris = new HashSet<URI>(uriReferences); olduris.removeAll(newuris); newuris.removeAll(uriReferences); for (URI old : olduris) { FileOwnerQuery.markExternalOwner(old, null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); } for (URI nw : newuris) { FileOwnerQuery.markExternalOwner(nw, proj, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); } uriReferences.removeAll(olduris); uriReferences.addAll(newuris); } } }
Example 2
Source File: ActionProviderImplTest.java From netbeans with Apache License 2.0 | 6 votes |
private void doTestStandaloneLangtools(String langtoolsClassesDir) throws Exception { createDir("langtools/src/java.compiler/share/classes"); createDir(langtoolsClassesDir); FileObject langtoolsProject = createDir("langtools/make/netbeans/langtools"); FileObject testFile = createFile("langtools/test/Test.java"); FileOwnerQuery.markExternalOwner(testFile.getParent(), FileOwnerQuery.getOwner(langtoolsProject), FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); ClassPath allSources = ActionProviderImpl.allSources(testFile); assertEquals(new HashSet<>(Arrays.asList("langtools/src/java.compiler/share/classes")), relative(FileUtil.toFileObject(getWorkDir()), Arrays.asList(allSources.getRoots()))); String builtClassesDirs = ActionProviderImpl.builtClassesDirsForBootClassPath(testFile); builtClassesDirs = builtClassesDirs.replace(getWorkDir().getAbsolutePath(), ""); assertEquals("/" + langtoolsClassesDir, builtClassesDirs); String jtregOutputDirs = Utilities.jtregOutputDir(testFile).getAbsolutePath(); jtregOutputDirs = jtregOutputDirs.replace(getWorkDir().getAbsolutePath(), ""); assertEquals("/langtools/build/nb-jtreg", jtregOutputDirs); }
Example 3
Source File: ActionProviderImplTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testImages2() throws Exception { createFile("modules.xml"); createDir("jdk/src/java.base/share/classes"); createDir("build/conf/jdk"); createDir("build/conf/images/jdk"); createDir("langtools/src/java.compiler/share/classes"); FileObject testFile = createFile("langtools/test/Test.java"); createDir("").setAttribute(BuildUtils.NB_JDK_PROJECT_BUILD, FileUtil.toFile(createDir("build/conf"))); FileOwnerQuery.markExternalOwner(testFile.getParent(), FileOwnerQuery.getOwner(createDir("langtools/src/java.compiler")), FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); File target = BuildUtils.findTargetJavaHome(testFile); assertEquals("/build/conf/jdk", target.getAbsolutePath().substring(getWorkDir().getAbsolutePath().length())); }
Example 4
Source File: ActionProviderImplTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testImages1() throws Exception { createFile("modules.xml"); createDir("jdk/src/java.base/share/classes"); createDir("build/conf/images/j2sdk-image"); createDir("langtools/src/java.compiler/share/classes"); FileObject testFile = createFile("langtools/test/Test.java"); createDir("").setAttribute(BuildUtils.NB_JDK_PROJECT_BUILD, FileUtil.toFile(createDir("build/conf"))); FileOwnerQuery.markExternalOwner(testFile.getParent(), FileOwnerQuery.getOwner(createDir("langtools/src/java.compiler")), FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); File target = BuildUtils.findTargetJavaHome(testFile); assertEquals("/build/conf/images/j2sdk-image", target.getAbsolutePath().substring(getWorkDir().getAbsolutePath().length())); }
Example 5
Source File: SourcePathImplementationTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testIncludesFiredJustOnce() throws Exception { File src1 = new File(getWorkDir(), "src1"); src1.mkdir(); File src2 = new File(getWorkDir(), "src2"); src2.mkdir(); AntProjectHelper h = J2SEProjectGenerator.createProject(new File(getWorkDir(), "prj"), "test", new File[] {src1, src2}, new File[0], null, null, null); Project p = ProjectManager.getDefault().findProject(h.getProjectDirectory()); FileOwnerQuery.markExternalOwner(Utilities.toURI(src1), p, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); ClassPath cp = ClassPath.getClassPath(FileUtil.toFileObject(src1), ClassPath.SOURCE); assertNotNull(cp); assertEquals(2, cp.getRoots().length); ClassPath.Entry cpe2 = cp.entries().get(1); assertEquals(Utilities.toURI(src2).toURL(), cpe2.getURL()); assertTrue(cpe2.includes("stuff/")); assertTrue(cpe2.includes("whatever/")); class L implements PropertyChangeListener { int cnt; public void propertyChange(PropertyChangeEvent e) { if (ClassPath.PROP_INCLUDES.equals(e.getPropertyName())) { cnt++; } } } L l = new L(); cp.addPropertyChangeListener(l); EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); ep.setProperty(ProjectProperties.INCLUDES, "whatever/"); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); ProjectManager.getDefault().saveProject(p); assertEquals(1, l.cnt); assertFalse(cpe2.includes("stuff/")); assertTrue(cpe2.includes("whatever/")); ep.setProperty(ProjectProperties.INCLUDES, "whateverelse/"); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); ProjectManager.getDefault().saveProject(p); assertEquals(2, l.cnt); assertFalse(cpe2.includes("stuff/")); assertFalse(cpe2.includes("whatever/")); ep.remove(ProjectProperties.INCLUDES); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); ProjectManager.getDefault().saveProject(p); assertEquals(3, l.cnt); assertTrue(cpe2.includes("stuff/")); assertTrue(cpe2.includes("whatever/")); }
Example 6
Source File: ActionProviderImplTest.java From netbeans with Apache License 2.0 | 4 votes |
private void doTestModulatizedFullJDK(String langtoolsClassesDir) throws Exception { createFile("modules.xml"); FileObject javaBaseSource = createDir("jdk/src/java.base/share/classes"); FileObject javaBaseTestFile = createFile("jdk/test/Test.java"); createDir("jdk/src/java.base/linux/classes"); createDir("jdk/src/java.desktop/share/classes"); createDir("build/conf/jdk/modules/java.base"); createDir("build/conf/jdk/modules/java.desktop"); FileObject javaCompilerSource = createDir("langtools/src/java.compiler/share/classes"); createDir(langtoolsClassesDir); FileObject langtoolsTestFile = createFile("langtools/test/Test.java"); createDir("").setAttribute(BuildUtils.NB_JDK_PROJECT_BUILD, FileUtil.toFile(createDir("build/conf"))); FileOwnerQuery.markExternalOwner(javaBaseTestFile.getParent(), FileOwnerQuery.getOwner(javaBaseSource), FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); FileOwnerQuery.markExternalOwner(langtoolsTestFile.getParent(), FileOwnerQuery.getOwner(javaCompilerSource), FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); Set<String> expectedAllSources = new HashSet<>(Arrays.asList("langtools/src/java.compiler/share/classes", "jdk/src/java.base/linux/classes", "jdk/src/java.base/share/classes", "jdk/src/java.desktop/share/classes")); assertEquals(expectedAllSources, relative(FileUtil.toFileObject(getWorkDir()), Arrays.asList(ActionProviderImpl.allSources(javaBaseTestFile).getRoots()))); assertEquals(expectedAllSources, relative(FileUtil.toFileObject(getWorkDir()), Arrays.asList(ActionProviderImpl.allSources(langtoolsTestFile).getRoots()))); String builtClassesJDKDirs = ActionProviderImpl.builtClassesDirsForBootClassPath(javaBaseTestFile); builtClassesJDKDirs = builtClassesJDKDirs.replace(getWorkDir().getAbsolutePath(), ""); assertEquals(new HashSet<>(Arrays.asList("/build/conf/jdk/modules/java.desktop", "/build/conf/jdk/modules/java.base")), new HashSet<>(Arrays.asList(builtClassesJDKDirs.split(Pattern.quote(File.pathSeparator))))); String builtClassesLangtoolsDirs = ActionProviderImpl.builtClassesDirsForBootClassPath(langtoolsTestFile); builtClassesLangtoolsDirs = builtClassesLangtoolsDirs.replace(getWorkDir().getAbsolutePath(), ""); assertEquals("/" + langtoolsClassesDir, builtClassesLangtoolsDirs); String jtregOutputDirs = Utilities.jtregOutputDir(langtoolsTestFile).getAbsolutePath(); jtregOutputDirs = jtregOutputDirs.replace(getWorkDir().getAbsolutePath(), ""); assertEquals("/langtools/build/nb-jtreg", jtregOutputDirs); }