List of usage examples for org.eclipse.jdt.core IJavaProject getRawClasspath
IClasspathEntry[] getRawClasspath() throws JavaModelException;
From source file:org.eclipse.ajdt.core.tests.builder.AJBuilderTest2.java
License:Open Source License
private boolean projectHasLibraryOnClasspath(IJavaProject proj, String libName) throws JavaModelException { IClasspathEntry[] entries = proj.getRawClasspath(); IPath libPath = proj.getProject().getLocation().append(libName); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { if (entry.getPath().equals(libPath) || entry.getPath().equals(libPath.makeAbsolute())) { return true; }//ww w . j av a 2s . c o m } } return false; }
From source file:org.eclipse.ajdt.core.tests.builder.AJBuilderTest2.java
License:Open Source License
private void addProjectDependency(IProject project, IProject projectDependedOn) throws JavaModelException { IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] originalCP = javaProject.getRawClasspath(); IClasspathEntry newEntry = JavaCore.newProjectEntry(projectDependedOn.getFullPath()); int originalCPLength = originalCP.length; IClasspathEntry[] newCP = new IClasspathEntry[originalCPLength + 1]; System.arraycopy(originalCP, 0, newCP, 0, originalCPLength); newCP[originalCPLength] = newEntry;/*from w w w . ja va 2 s . com*/ javaProject.setRawClasspath(newCP, null); }
From source file:org.eclipse.ajdt.core.tests.builder.AJBuilderTest2.java
License:Open Source License
private boolean projectHasProjectDependency(IJavaProject proj, IProject projectDependedOn) throws JavaModelException { IClasspathEntry[] entries = proj.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { if (entry.getPath().equals(projectDependedOn.getFullPath()) || entry.getPath().equals(projectDependedOn.getFullPath().makeAbsolute())) { return true; }//from w ww . j a v a2 s .c o m } } return false; }
From source file:org.eclipse.ajdt.core.tests.builder.Bug99133Test.java
License:Open Source License
/** * A depends on B and in particular calls a method in B. * The signature of an unreferenced method in B changes. Then an * incremental build of project B and a full build of project A * should occur. (both A and B are AJ projects) *//* w w w . j a v a 2 s .c om*/ // public void testBug99133d() throws Exception { // // //change the return type of the method m1() in bug99133b\src\p\C1.java // IFile c1 = getFile(pB,"p","C1.java"); //$NON-NLS-1$ //$NON-NLS-2$ // BufferedReader br1 = new BufferedReader(new InputStreamReader(c1.getContents())); // // StringBuffer sb1 = new StringBuffer(); // int lineNumber1 = 1; // String line1 = br1.readLine(); // while (line1 != null) { // if (lineNumber1 == 8) { // sb1.append("public String m2() {"); //$NON-NLS-1$ // } else if (lineNumber1 == 9) { // sb1.append("return \"Hello\";"); //$NON-NLS-1$ // } else { // sb1.append(line1); // } // sb1.append(System.getProperty("line.separator")); //$NON-NLS-1$ // lineNumber1++; // line1 = br1.readLine(); // } // br1.close(); // StringReader reader1 = new StringReader(sb1.toString()); // c1.setContents(new ReaderInputStream(reader1), true, true, null); // waitForAutoBuild(); // waitForAutoBuild(); // // assertEquals("two more builds should have occured", //$NON-NLS-1$ // numberOfBuilds + 2, // testLog.getNumberOfBuildsRun()); // // List buildLogB = testLog.getPreviousBuildEntry(2); // boolean incB = listContainsString(buildLogB, // "AspectJ reports build successful, build was: INCREMENTAL"); //$NON-NLS-1$ // boolean fullB = listContainsString(buildLogB, // "AspectJ reports build successful, build was: FULL"); //$NON-NLS-1$ // // if not an incremental build of project bug99133b build then fail // // printing out whether did a full build instead // if (!incB) { // fail("Changing the signature of a method in project bug99133b " //$NON-NLS-1$ // + "should cause an incremental build of project bug99133b " //$NON-NLS-1$ // + ": (did a full build instead:" + fullB+")"); //$NON-NLS-1$ //$NON-NLS-2$ // } // // List buildLogA = testLog.getPreviousBuildEntry(1); // boolean incA = listContainsString(buildLogA, // "AspectJ reports build successful, build was: INCREMENTAL"); //$NON-NLS-1$ // boolean fullA = listContainsString(buildLogA, // "AspectJ reports build successful, build was: FULL"); //$NON-NLS-1$ // // if not a full build of project bug99133a build then fail // // printing out whether did an incremental build instead // if (!fullA) { // fail("Changing the signature of an unreferenced method in" //$NON-NLS-1$ // + " project bug99133b should cause a full build of " //$NON-NLS-1$ // + " dependent project bug99133a " //$NON-NLS-1$ // + ": (did an incremental build instead:" + incA + ")"); //$NON-NLS-1$ //$NON-NLS-2$ // } // } // // /** // * A depends on B and in particular calls a method in B. // * A new method is added to a class in B. // * Then an incremental build of project B and a full build // * of project A should occurr. (both A and B are AJ projects) // */ // public void testBug99133e() throws Exception { // // //change the return type of the method m1() in bug99133b\src\p\C1.java // IFile c1 = getFile(pB,"p","C1.java"); //$NON-NLS-1$ //$NON-NLS-2$ // BufferedReader br1 = new BufferedReader(new InputStreamReader(c1.getContents())); // // StringBuffer sb1 = new StringBuffer(); // int lineNumber1 = 1; // String line1 = br1.readLine(); // while (line1 != null) { // if (lineNumber1 == 10) { // sb1.append("}"); //$NON-NLS-1$ // sb1.append(System.getProperty("line.separator")); //$NON-NLS-1$ // sb1.append("public void m3() {}"); //$NON-NLS-1$ // } else { // sb1.append(line1); // } // sb1.append(System.getProperty("line.separator")); //$NON-NLS-1$ // lineNumber1++; // line1 = br1.readLine(); // } // br1.close(); // StringReader reader1 = new StringReader(sb1.toString()); // c1.setContents(new ReaderInputStream(reader1), true, true, null); // waitForAutoBuild(); // waitForAutoBuild(); // // assertEquals("two more builds should have occured", //$NON-NLS-1$ // numberOfBuilds + 2, // testLog.getNumberOfBuildsRun()); // // List buildLogB = testLog.getPreviousBuildEntry(2); // boolean incB = listContainsString(buildLogB, // "AspectJ reports build successful, build was: INCREMENTAL"); //$NON-NLS-1$ // boolean fullB = listContainsString(buildLogB, // "AspectJ reports build successful, build was: FULL"); //$NON-NLS-1$ // // if not an incremental build of project bug99133b build then fail // // printing out whether did a full build instead // if (!incB) { // fail("Adding a method in project bug99133b " //$NON-NLS-1$ // + "should cause an incremental build of project bug99133b " //$NON-NLS-1$ // + ": (did a full build instead:" + fullB+")"); //$NON-NLS-1$ //$NON-NLS-2$ // } // // List buildLogA = testLog.getPreviousBuildEntry(1); // boolean incA = listContainsString(buildLogA, // "AspectJ reports build successful, build was: INCREMENTAL"); //$NON-NLS-1$ // boolean fullA = listContainsString(buildLogA, // "AspectJ reports build successful, build was: FULL"); //$NON-NLS-1$ // // if not a full build of project bug99133a build then fail // // printing out whether did an incremental build instead // if (!fullA) { // fail("Adding a method in project bug99133b " //$NON-NLS-1$ // + "should cause an full build of dependent project bug99133b " //$NON-NLS-1$ // + ": (did an incremental build instead:" + incA + ")"); //$NON-NLS-1$ //$NON-NLS-2$ // } // // } private void addProjectDependency(IProject project, IProject projectDependedOn) throws JavaModelException { IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] originalCP = javaProject.getRawClasspath(); IClasspathEntry newEntry = JavaCore.newProjectEntry(projectDependedOn.getFullPath()); int originalCPLength = originalCP.length; IClasspathEntry[] newCP = new IClasspathEntry[originalCPLength + 1]; System.arraycopy(originalCP, 0, newCP, 0, originalCPLength); newCP[originalCPLength] = newEntry; javaProject.setRawClasspath(newCP, null); waitForAutoBuild(); }
From source file:org.eclipse.ajdt.core.tests.builder.Bug99133Test.java
License:Open Source License
private void removeProjectDependency(IProject project, IProject projectDependedOn) throws JavaModelException { IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] cpEntry = javaProject.getRawClasspath(); List newEntries = new ArrayList(); for (int j = 0; j < cpEntry.length; j++) { IClasspathEntry entry = cpEntry[j]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { if (!entry.getPath().equals(projectDependedOn.getFullPath()) && !entry.getPath().equals(projectDependedOn.getFullPath().makeAbsolute())) { newEntries.add(entry);/*ww w . j a va 2 s.c o m*/ } } else { newEntries.add(entry); } } IClasspathEntry[] newCP = (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]); javaProject.setRawClasspath(newCP, null); }
From source file:org.eclipse.ajdt.core.tests.builder.DerivedTests.java
License:Open Source License
public void testDeleteSourceFolder() throws Exception { IProject proj = createPredefinedProject("CopyDerived1"); getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); IJavaProject jProj = JavaCore.create(proj); IClasspathEntry[] classpath = jProj.getRawClasspath(); IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length - 1]; // remove the classpath entry corresponding to src for (int i = 0, j = 0; i < classpath.length; i++, j++) { if (classpath[i].getPath().lastSegment().toString().equals("src")) { j--;/*from ww w .j a v a 2 s . c om*/ continue; } newClasspath[j] = classpath[i]; } jProj.setRawClasspath(newClasspath, true, null); proj.build(IncrementalProjectBuilder.FULL_BUILD, null); IFolder out = proj.getFolder("bin"); checkFolderIsNotDerived(out, ""); checkFileNoExist(out, "file.txt"); checkFileNoExist(out, "Nothing.class"); checkFileNoExist(out, "Nothing2.class"); checkFolderNoExist(out, "package1"); checkFileNoExist(out, "package1/file.txt"); checkFileNoExist(out, "package1/Nothing.class"); checkFileNoExist(out, "package1/Nothing2.class"); }
From source file:org.eclipse.ajdt.internal.builder.UIBuildListener.java
License:Open Source License
private void removeOutjarFromDependingProjects(IProject project, IClasspathEntry unwantedEntry) { IProject[] dependingProjects = getDependingProjects(project); for (int i = 0; i < dependingProjects.length; i++) { IJavaProject javaProject = JavaCore.create(dependingProjects[i]); if (javaProject == null) continue; try {// www . ja v a2 s . c o m IClasspathEntry[] cpEntry = javaProject.getRawClasspath(); List newEntries = new ArrayList(); for (int j = 0; j < cpEntry.length; j++) { if (!cpEntry[j].equals(unwantedEntry)) { newEntries.add(cpEntry[j]); } } IClasspathEntry[] newCP = (IClasspathEntry[]) newEntries .toArray(new IClasspathEntry[newEntries.size()]); javaProject.setRawClasspath(newCP, new NullProgressMonitor()); } catch (CoreException e) { } } }
From source file:org.eclipse.ajdt.internal.builder.UIBuildListener.java
License:Open Source License
private void updateDependingProjectsWithJar(IProject project, IClasspathEntry newEntry) { IProject[] dependingProjects = getDependingProjects(project); goThroughProjects: for (int i = 0; i < dependingProjects.length; i++) { IJavaProject javaProject = JavaCore.create(dependingProjects[i]); if (javaProject == null) continue; try {/*from w w w .j a v a 2 s . c o m*/ IClasspathEntry[] cpEntry = javaProject.getRawClasspath(); List newEntries = new ArrayList(); for (int j = 0; j < cpEntry.length; j++) { if (cpEntry[j].equals(newEntry)) { continue goThroughProjects; } else { newEntries.add(cpEntry[j]); } } newEntries.add(newEntry); IClasspathEntry[] newCP = (IClasspathEntry[]) newEntries .toArray(new IClasspathEntry[newEntries.size()]); javaProject.setRawClasspath(newCP, new NullProgressMonitor()); } catch (CoreException e) { } } }
From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java
License:Open Source License
/** * @return true if there is more than one output directory being used by * this project and false otherwise *//*from ww w . j a v a 2 s . c o m*/ private boolean isUsingSeparateOutputFolders(IJavaProject jp) { if (getInpathOutputFolder() != null) { return true; } try { IClasspathEntry[] cpe = jp.getRawClasspath(); for (int i = 0; i < cpe.length; i++) { if (cpe[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) { if (cpe[i].getOutputLocation() != null) { return true; } } } } catch (JavaModelException e) { } return false; }
From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java
License:Open Source License
private void mapProject(IJavaProject jp) throws JavaModelException { IClasspathEntry[] cpes = jp.getRawClasspath(); for (int i = 0; i < cpes.length; i++) { if (cpes[i].isExported() || cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE || jp == jProject) { handleClassPathEntry(jp, cpes[i]); }/* w w w.java2 s .c o m*/ } }