/** * When plugin.xml has changed re-read our data and perhaps clear cached data in the * JavaModelManager and RequirePluginsClasspathContainer. */ void reload() { this.hasChanges = true; HashMap<String, HashSet<String>> oldForcedExports = this.base2forcedExports; HashMap<String, HashSet<String>> oldTeamBindings = this.team2basePlugins; // clear internal storage: this.team2basePlugins = null; // be sure to initialize new sets if needed, so we can compare sets using // mapHasChanged this.base2forcedExports = null; this.adaptationInfos .clear(); // these two are created by default (and no need to compare old/new) this.teamsAdaptingSelf.clear(); if (!this.readAspectBindings(this.iProject, getSaxParserFactory())) { OTDTPlugin.getDefault() .getLog() .log( new Status( Status.ERROR, OTDTPlugin.PLUGIN_ID, "Unable to re-read plugin.xml!;")); //$NON-NLS-1$ return; } // remove cached data if forced exports or team bindings have changed: if (mapHasChanged(oldForcedExports, this.base2forcedExports) || mapHasChanged(oldTeamBindings, this.team2basePlugins)) { resetRequiredPluginsClasspathContainer(this.iProject); } }
/** OT: new method: OT specific project creation. Creates a IJavaProject. */ public static IJavaProject createOTJavaProject(String projectName, String binFolderName) throws CoreException { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject(projectName); if (!project.exists()) { project.create(null); } else { project.refreshLocal(IResource.DEPTH_INFINITE, null); } if (!project.isOpen()) { project.open(null); } IPath outputLocation; if (binFolderName != null && binFolderName.length() > 0) { IFolder binFolder = project.getFolder(binFolderName); if (!binFolder.exists()) { CoreUtility.createFolder(binFolder, false, true, null); } outputLocation = binFolder.getFullPath(); } else { outputLocation = project.getFullPath(); } if (!project.hasNature(JavaCore.NATURE_ID) && !project.hasNature(JavaCore.OTJ_NATURE_ID)) { addNatureToProject(project, JavaCore.NATURE_ID, null); // add OT nature to project addNatureToProject(project, JavaCore.OTJ_NATURE_ID, null); } IProjectDescription description = project.getDescription(); // add OT build spec to project description.setBuildSpec(OTDTPlugin.createProjectBuildCommands(description)); project.setDescription(description, null); IJavaProject jproject = JavaCore.create(project); jproject.setOutputLocation(outputLocation, null); jproject.setRawClasspath(new IClasspathEntry[0], null); OTREContainer.initializeOTJProject(project); return jproject; }
private void resetRequiredPluginsClasspathContainer(IProject project) { IJavaProject jProject = JavaCore.create(project); IPluginModelBase model = fPluginModelManager.findModel(project); try { IBuild build = ClasspathUtilCore.getBuild(model); RequiredPluginsClasspathContainer container = new RequiredPluginsClasspathContainer(model, build); // this triggers recomputing the classpath: JavaCore.setClasspathContainer( PDECore.REQUIRED_PLUGINS_CONTAINER_PATH, new IJavaProject[] {jProject}, new IClasspathContainer[] {container}, null); // AspectBindingReader is automatically shared via the ResourceProjectAdaptor.OTEquinoxProject // see // org.eclipse.objectteams.otdt.internal.compiler.adaptor.AdaptorActivator.JavaCore.setClasspathContainer(..) } catch (CoreException ce) { OTDTPlugin.logException( "Failed to reload classpath container for " + project, ce); // $NON-NLS-1$ } }