Java Code Examples for org.eclipse.core.runtime.IPath#removeLastSegments()
The following examples show how to use
org.eclipse.core.runtime.IPath#removeLastSegments() .
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: RemoteGenerateManifestOperation.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * This method takes the auto-detection case into consideration. * * {@inheritDoc} */ @Override protected boolean matchesDirectoryTrace(IPath archivePath, Entry<Pattern, TracePackageTraceElement> entry) { if (METADATA_FILE_NAME.equals(archivePath.lastSegment())) { IPath archiveParentPath = archivePath.removeLastSegments(1); String parentPathString = TmfTraceCoreUtils.safePathToString(archiveParentPath.toString()); if (entry.getKey().matcher(parentPathString).matches()) { String traceType = entry.getValue().getTraceType(); // empty string is for auto-detection if (traceType.isEmpty() || TmfTraceType.isDirectoryTraceType(traceType)) { return true; } } } return false; }
Example 2
Source File: JarWriter2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void registerInWorkspaceIfNeeded() { IPath jarPath= fJarPackage.getAbsoluteJarLocation(); IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); for (int i= 0; i < projects.length; i++) { IProject project= projects[i]; // The Jar is always put into the local file system. So it can only be // part of a project if the project is local as well. So using getLocation // is currently save here. IPath projectLocation= project.getLocation(); if (projectLocation != null && projectLocation.isPrefixOf(jarPath)) { try { jarPath= jarPath.removeFirstSegments(projectLocation.segmentCount()); jarPath= jarPath.removeLastSegments(1); IResource containingFolder= project.findMember(jarPath); if (containingFolder != null && containingFolder.isAccessible()) containingFolder.refreshLocal(IResource.DEPTH_ONE, null); } catch (CoreException ex) { // don't refresh the folder but log the problem JavaPlugin.log(ex); } } } }
Example 3
Source File: JarWriter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void registerInWorkspaceIfNeeded() { IPath jarPath= fJarPackage.getAbsoluteJarLocation(); IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); for (int i= 0; i < projects.length; i++) { IProject project= projects[i]; // The Jar is always put into the local file system. So it can only be // part of a project if the project is local as well. So using getLocation // is currently save here. IPath projectLocation= project.getLocation(); if (projectLocation != null && projectLocation.isPrefixOf(jarPath)) { try { jarPath= jarPath.removeFirstSegments(projectLocation.segmentCount()); jarPath= jarPath.removeLastSegments(1); IResource containingFolder= project.findMember(jarPath); if (containingFolder != null && containingFolder.isAccessible()) containingFolder.refreshLocal(IResource.DEPTH_ONE, null); } catch (CoreException ex) { // don't refresh the folder but log the problem JavaPlugin.log(ex); } } } }
Example 4
Source File: FileFieldSetter.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override public void widgetSelected(SelectionEvent event) { IPath inputPath = new Path(fileField.getText().trim()); IPath filterPath = preProcessInputPath(inputPath); while (!filterPath.isEmpty() && !filterPath.isRoot() && !filterPath.toFile().isDirectory()) { filterPath = filterPath.removeLastSegments(1); } dialog.setFilterPath(filterPath.toString()); dialog.setFilterExtensions(Arrays.copyOf(filterExtensions, filterExtensions.length)); String result = dialog.open(); if (result != null) { IPath pathToSet = postProcessResultPath(new Path(result)); fileField.setText(pathToSet.toString()); } }
Example 5
Source File: JavadocConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private String chooseArchive() { if (fWorkspaceRadio.isSelected()) { return chooseWorkspaceArchive(); } IPath currPath= new Path(fArchiveField.getText()); if (ArchiveFileFilter.isArchivePath(currPath, true)) { currPath= currPath.removeLastSegments(1); } FileDialog dialog= new FileDialog(fShell, SWT.OPEN); dialog.setFilterExtensions(ArchiveFileFilter.JAR_ZIP_FILTER_EXTENSIONS); dialog.setText(PreferencesMessages.JavadocConfigurationBlock_zipImportSource_title); dialog.setFilterPath(currPath.toOSString()); return dialog.open(); }
Example 6
Source File: HostedSiteServlet.java From orion.server with Eclipse Public License 1.0 | 6 votes |
/** * Returns paths constructed by rewriting pathInfo using rules from the hosted site's mappings. * Paths are ordered from most to least specific match. * @param site The hosted site. * @param pathInfo Path to be rewritten. * @param queryString * @return The rewritten path. May be either:<ul> * <li>A path to a file in the Orion workspace, eg. <code>/ProjectA/foo/bar.txt</code></li> * <li>An absolute URL pointing to another site, eg. <code>http://foo.com/bar.txt</code></li> * </ul> * @return The rewritten paths. * @throws URISyntaxException */ private URI[] getMapped(IHostedSite site, IPath pathInfo, String queryString) throws URISyntaxException { final Map<String, List<String>> map = site.getMappings(); final IPath originalPath = pathInfo; IPath path = originalPath.removeTrailingSeparator(); List<URI> uris = new ArrayList<URI>(); String rest = null; final int count = path.segmentCount(); for (int i = 0; i <= count; i++) { List<String> base = map.get(path.toString()); if (base != null) { rest = originalPath.removeFirstSegments(count - i).toString(); for (int j = 0; j < base.size(); j++) { URI uri = (rest.equals("") || rest.equals("/")) ? new URI(base.get(j)) : URIUtil.append(new URI(base.get(j)), rest); uris.add(createUri(uri, queryString)); } } path = path.removeLastSegments(1); } if (uris.size() == 0) // No mapping for / return null; else return uris.toArray(new URI[uris.size()]); }
Example 7
Source File: GitUtils.java From orion.server with Eclipse Public License 1.0 | 6 votes |
public static String getRelativePath(IPath filePath, IPath pathToGitRoot) { StringBuilder sb = new StringBuilder(); String file = null; if (!filePath.hasTrailingSeparator()) { file = filePath.lastSegment(); filePath = filePath.removeLastSegments(1); } for (int i = 0; i < pathToGitRoot.segments().length; i++) { if (pathToGitRoot.segments()[i].equals("..")) sb.append(filePath.segment(filePath.segments().length - pathToGitRoot.segments().length + i)).append("/"); // else TODO } if (file != null) sb.append(file); return sb.toString(); }
Example 8
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processVMInstallType(IVMInstallType installType, List<IPath> locations, List<String> labels) { if (installType != null) { IVMInstall[] installs= installType.getVMInstalls(); boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); for (int i= 0; i < installs.length; i++) { String label= getFormattedLabel(installs[i].getName()); LibraryLocation[] libLocations= installs[i].getLibraryLocations(); if (libLocations != null) { processLibraryLocation(libLocations, label); } else { IPath filePath= Path.fromOSString(installs[i].getInstallLocation().getAbsolutePath()); // On MacOS X, install locations end in an additional "/Home" segment; remove it. if (isMac && "Home".equals(filePath.lastSegment())) //$NON-NLS-1$ filePath= filePath.removeLastSegments(1); locations.add(filePath); labels.add(label); } } } }
Example 9
Source File: GitIndexHandlerV1.java From orion.server with Eclipse Public License 1.0 | 5 votes |
@Override public boolean handleRequest(HttpServletRequest request, HttpServletResponse response, String path) throws ServletException { Repository db = null; try { IPath p = new Path(path); IPath filePath = p.hasTrailingSeparator() ? p : p.removeLastSegments(1); if (!AuthorizationService.checkRights(request.getRemoteUser(), "/" + filePath.toString(), request.getMethod())) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return true; } Set<Entry<IPath, File>> set = GitUtils.getGitDirs(filePath, Traverse.GO_UP).entrySet(); File gitDir = set.iterator().next().getValue(); if (gitDir == null) return false; // TODO: or an error response code, 405? db = FileRepositoryBuilder.create(gitDir); switch (getMethod(request)) { case GET: return handleGet(request, response, db, GitUtils.getRelativePath(p, set.iterator().next().getKey())); case PUT: return handlePut(request, response, db, GitUtils.getRelativePath(p, set.iterator().next().getKey())); case POST: return handlePost(request, response, db, p); default: // fall through and return false below } } catch (Exception e) { String msg = NLS.bind("Failed to process an operation on index for {0}", path); //$NON-NLS-1$ ServerStatus status = new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e); LogHelper.log(status); return statusHandler.handleRequest(request, response, status); } finally { if (db != null) db.close(); } return false; }
Example 10
Source File: WizardSaveAsPage.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Returns a <code>boolean</code> indicating whether a container name * represents a valid container resource in the workbench. An error message * is stored for future reference if the name does not represent a valid * container. * * @return <code>boolean</code> indicating validity of the container name */ protected boolean validateContainer( ) { IPath path = containerGroup.getContainerFullPath( ); if ( path == null ) { problemType = PROBLEM_CONTAINER_EMPTY; problemMessage = Messages.getString( "WizardSaveAsPage.FolderEmpty" ); //$NON-NLS-1$ return false; } IWorkspace workspace = ResourcesPlugin.getWorkspace( ); String projectName = path.segment( 0 ); if ( projectName == null || !workspace.getRoot( ).getProject( projectName ).exists( ) ) { problemType = PROBLEM_PROJECT_DOES_NOT_EXIST; problemMessage = Messages.getString( "WizardSaveAsPage.NoProject" ); //$NON-NLS-1$ return false; } // path is invalid if any prefix is occupied by a file IWorkspaceRoot root = workspace.getRoot( ); while ( path.segmentCount( ) > 1 ) { if ( root.getFile( path ).exists( ) ) { problemType = PROBLEM_PATH_OCCUPIED; problemMessage = Messages.getFormattedString( "WizardSaveAsPage.PathOccupied", new Object[]{path.makeRelative( )} ); //$NON-NLS-1$ return false; } path = path.removeLastSegments( 1 ); } return true; }
Example 11
Source File: SarlEmbededSdkClasspathProvider.java From sarl with Apache License 2.0 | 5 votes |
private synchronized URL getSingleArchiveFromClasspath() { URL singleUrl = this.singleUrl == null ? null : this.singleUrl.get(); if (singleUrl == null) { final String javaHome = Strings.emptyToNull(System.getProperty("java.home")); //$NON-NLS-1$ IPath javaHomePath = javaHome == null ? null : Path.fromOSString(javaHome); if (javaHomePath != null && "jre".equalsIgnoreCase(javaHomePath.lastSegment())) { //$NON-NLS-1$ javaHomePath = javaHomePath.removeLastSegments(1); } final Iterator<URL> iterator = ClasspathUtil.getClasspath(); while (iterator.hasNext()) { final URL url = iterator.next(); if (singleUrl != null) { // If more then 2 jar files are on the classpath, then there is not a single archive. return null; } final File jarFile = FileSystem.convertURLToFile(url); if (jarFile != null) { if (javaHomePath == null) { singleUrl = url; } else { final IPath jarPath = Path.fromOSString(jarFile.getAbsolutePath()); if (!javaHomePath.isPrefixOf(jarPath)) { singleUrl = url; } } } } this.singleUrl = new SoftReference<>(singleUrl); } return singleUrl; }
Example 12
Source File: MavenUtils.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Creates a MavenInfo instance based on the path to a Maven artifact in a local repository and * the artifact's group id. * * @param artifactPath the path to the artifact in the user's local repository (e.g., * <code>/home/user/.m2/repository/com/google/gwt/gwt * -user/2.1-SNAPSHOT/gwt-user-2.1-SNAPSHOT.jar</code>) * @param groupId the group id of the artifact (e.g., <code>com.google.gwt</code>) * @return an instance of MavenInfo, or null if one could not be found due to a mismatch between * the group id and the artifact path */ public static MavenInfo create(IPath artifactPath, String groupId) { if (artifactPath == null || artifactPath.isEmpty() || groupId == null || StringUtilities.isEmpty(groupId)) { return null; } IPath groupPath = Path.fromPortableString(groupId.replace('.', '/')); final int numTrailingSegmentsAfterRepositoryBase = NUM_TRAILING_SEGMENTS_AFTER_GROUP_ID + groupPath.segmentCount(); if (artifactPath.segmentCount() <= numTrailingSegmentsAfterRepositoryBase) { return null; } String artifactName = artifactPath.lastSegment(); String version = artifactPath.segment(artifactPath.segmentCount() - VERSION_INDEX_FROM_END_OF_MAVEN_PATH - 1); String artifactId = artifactPath.segment(artifactPath.segmentCount() - ARTIFACTID_INDEX_FROM_END_OF_MAVEN_PATH - 1); if (!artifactPath.removeLastSegments(NUM_TRAILING_SEGMENTS_AFTER_GROUP_ID) .removeTrailingSeparator().toPortableString().endsWith(groupPath.toPortableString())) { return null; } IPath repositoryPath = artifactPath.removeLastSegments(numTrailingSegmentsAfterRepositoryBase); return new MavenInfo(repositoryPath, groupId, artifactId, artifactName, version); }
Example 13
Source File: UiBinderXmlParser.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private UiBinderXmlParser(IDOMModel xmlModel, IFile xmlFile, IPath xmlClasspathRelativePath, ReferenceManager referenceManager, IValidationResultPlacementStrategy<?> validationResultPlacementStrategy, IJavaProject javaProject) { this.referenceManager = referenceManager; this.xmlModel = xmlModel; this.xmlFile = xmlFile; this.javaProject = javaProject; xmlReferenceLocation = new ClasspathRelativeFileReferenceLocation( xmlClasspathRelativePath); classpathRelativeDir = xmlClasspathRelativePath.removeLastSegments(1); problemMarkerManager = new UiBinderProblemMarkerManager(xmlFile, xmlModel.getStructuredDocument(), validationResultPlacementStrategy); }
Example 14
Source File: JavaProjectHelper.java From testability-explorer with Apache License 2.0 | 5 votes |
public String getProjectLocation(IJavaProject javaProject) { IProject project = javaProject.getProject(); IPath rawLocation = project.getRawLocation(); IPath projectLocation; if (rawLocation != null) { projectLocation = rawLocation.removeLastSegments(1); } else { projectLocation = project.getParent().getLocation(); } return projectLocation.toOSString(); }
Example 15
Source File: GwtSdk.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Returns the value of the gwt_devjar variable or <code>null</code> if the variable is not defined. */ private IPath computeGwtDevJarVariableValue() { IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager(); IValueVariable valueVariable = variableManager.getValueVariable("gwt_devjar"); if (valueVariable != null) { String value = valueVariable.getValue(); if (value != null) { IPath path = new Path(value); return path.removeLastSegments(1); } } return null; }
Example 16
Source File: NewProjectFromScratchPage.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void validateEclipseProjectAndLocation(String projectName, String projectRoot, boolean folderFirst) throws ValidationException { if (folderFirst) { validateProjectFolder(projectRoot); validateProjectName(projectName); } else { validateProjectName(projectName); validateProjectFolder(projectRoot); } // check whether project already exists final IProject handle= ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (handle.exists()) { throw new ValidationException(Messages.NewProjectFromScratchPage_ProjectAlreadyExists, true); } IProject p = ProjectUtils.getXdsProjectWithProjectRoot(projectRoot); if (p != null) { throw new ValidationException(String.format(Messages.NewProjectFromScratchPage_OtherProjectUsesThisFilesLocation, p.getName()), true); } // Another checks: IPath ipPrj = new Path(projectRoot); IPath ipPrjParent = ipPrj.removeLastSegments(1); IPath ipWorkspace = ResourcesPlugin.getWorkspace().getRoot().getLocation(); if (isPathsEquals(ipPrjParent, ipWorkspace)) { if (handle.getName().equals(ipPrj.lastSegment())) { // <workspace_dir>\<projectName> is legal location but // workspace.validateProjectLocation() rejects it } else { IStatus is = ResourcesPlugin.getWorkspace().validateProjectLocation(handle, ipPrj); if (!is.isOK()) { throw new ValidationException (is.getMessage(), true); } } } }
Example 17
Source File: HostingTest.java From orion.server with Eclipse Public License 1.0 | 4 votes |
@Test // Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=382760 public void testDisallowedSiteAccess() throws SAXException, IOException, JSONException, URISyntaxException, CoreException { UserInfo userBObject = createUser("userB", "userB"); String userB = userBObject.getUniqueId(); // User "test": create file in test's workspace final String filename = "foo.html"; final String fileContent = "<html><body>This is a test file</body></html>"; WebResponse createdFile = createFileOnServer("", filename, fileContent); URL fileLocation = createdFile.getURL(); IPath filepath = new Path(fileLocation.getPath()); filepath = filepath.removeFirstSegments(new Path(FILE_SERVLET_LOCATION).segmentCount()); // chop off leading /file/ filepath = filepath.removeLastSegments(1); // chop off trailing /foo.html filepath = filepath.makeAbsolute(); filepath = filepath.addTrailingSeparator(); String parentFolder = filepath.toString(); // User B: Give access to test's workspace String bWorkspaceId = workspaceId; AuthorizationService.addUserRight(userBObject.getUniqueId(), "/workspace/" + bWorkspaceId); AuthorizationService.addUserRight(userBObject.getUniqueId(), "/workspace/" + bWorkspaceId + "/*"); // User B: create a site against B's workspace that exposes a file in test's workspace final String siteName = "My hosted site"; final String filePath = parentFolder; //"/" + filename; final String mountAt = "/"; //"/file.html"; final JSONArray mappings = makeMappings(new String[][] {{mountAt, filePath}}); WebRequest createSiteReq = getCreateSiteRequest(siteName, bWorkspaceId, mappings, null); setAuthentication(createSiteReq, userB, userB); WebResponse createSiteResp = webConversation.getResponse(createSiteReq); assertEquals(HttpURLConnection.HTTP_CREATED, createSiteResp.getResponseCode()); JSONObject siteObject = new JSONObject(createSiteResp.getText()); // User B: Start the site String location = siteObject.getString(ProtocolConstants.HEADER_LOCATION); siteObject = startSite(location, userB, userB); final JSONObject hostingStatus = siteObject.getJSONObject(SiteConfigurationConstants.KEY_HOSTING_STATUS); final String hostedURL = hostingStatus.getString(SiteConfigurationConstants.KEY_HOSTING_STATUS_URL); // Attempt to access file on user B's site, should fail WebRequest getFileReq = new GetMethodWebRequest(hostedURL + mountAt); WebResponse getFileResp = webConversation.getResponse(getFileReq); assertEquals(HttpURLConnection.HTTP_FORBIDDEN, getFileResp.getResponseCode()); }
Example 18
Source File: RemoteGenerateManifestOperation.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Scan traceFolder for files that match the patterns specified in the * template file. When there is a match, the trace package element is used * to determine the trace name and trace type. * * @param traceGroup * The parent trace group element * @param parentElement * The immediate parent trace group or folder element * @param traceFolder * The folder to scan * @param recursionLevel * The recursion level (needed to find directory traces under the traceFolder * @param monitor * The progress monitor * @throws CoreException * Thrown by the file system implementation * @throws InterruptedException * Thrown if operation was cancelled */ private void generateElementsFromArchive( final RemoteImportTraceGroupElement traceGroup, final TracePackageElement parentElement, final IFileStore traceFolder, final int recursionLevel, IProgressMonitor monitor) throws CoreException, InterruptedException { int localRecursionLevel = recursionLevel + 1; IFileStore[] sources = traceFolder.childStores(EFS.NONE, monitor); for (int i = 0; i < sources.length; i++) { ModalContext.checkCanceled(monitor); SubMonitor subMonitor = SubMonitor.convert(monitor, sources.length); IFileStore fileStore = sources[i]; IPath fullArchivePath = TmfTraceCoreUtils.newSafePath(fileStore.toURI().getPath()); IFileInfo sourceInfo = fileStore.fetchInfo(); if (!sourceInfo.isDirectory()) { String rootPathString = traceGroup.getRootImportPath(); IPath rootPath = TmfTraceCoreUtils.newSafePath(rootPathString); IPath relativeTracePath = Path.EMPTY; if (rootPath.isPrefixOf(fullArchivePath)) { relativeTracePath = fullArchivePath.makeRelativeTo(rootPath); } Entry<Pattern, TracePackageTraceElement> matchingTemplateEntry = getMatchingTemplateElement(relativeTracePath); if (matchingTemplateEntry != null) { TracePackageTraceElement matchingTemplateElement = matchingTemplateEntry.getValue(); String traceType = matchingTemplateElement.getTraceType(); // If a single file is part of a directory trace, use the parent directory instead TracePackageElement parent = parentElement; if (matchesDirectoryTrace(relativeTracePath, matchingTemplateEntry)) { fullArchivePath = fullArchivePath.removeLastSegments(1); fDirectoryTraces.add(fullArchivePath); fileStore = fileStore.getParent(); sourceInfo = fileStore.fetchInfo(); parent = parentElement.getParent(); // Let the auto-detection choose the best trace type traceType = null; } else if ((localRecursionLevel > 1) && (!traceGroup.isRecursive())) { // Don't consider file traces on level 2 if it's not recursive continue; } if (sourceInfo.getLength() > 0 || sourceInfo.isDirectory()) { // Only add non-empty files String traceName = fullArchivePath.lastSegment(); String fileName = fileStore.getName(); // create new elements to decouple from input elements TracePackageTraceElement traceElement = new TracePackageTraceElement(parent, traceName, traceType); RemoteImportTraceFilesElement tracePackageFilesElement = new RemoteImportTraceFilesElement(traceElement, fileName, fileStore); tracePackageFilesElement.setVisible(false); } } } else { if (traceGroup.isRecursive() || localRecursionLevel < 2) { RemoteImportFolderElement folder = new RemoteImportFolderElement(parentElement, fileStore.getName()); generateElementsFromArchive(traceGroup, folder, fileStore, localRecursionLevel, subMonitor); } } } }
Example 19
Source File: BasePublishOperation.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
protected void publishJar(String jarURI, Properties properties, List<IStatus> statuses, IProgressMonitor monitor) throws CoreException { IPath path = getModuleDeployDirectory(module[0]); boolean moving = false; // Get URI used for previous publish, if known String oldURI = (String) properties.get(module[1].getId()); if (oldURI != null) { // If old URI found, detect if jar is moving or changing its name if (jarURI != null) { moving = !oldURI.equals(jarURI); } } // If we don't have a jar URI, make a guess so we have one if we need it if (jarURI == null) { jarURI = "WEB-INF/lib/" + module[1].getName() + ".jar"; } IPath jarPath = path.append(jarURI); // Make our best determination of the path to the old jar IPath oldJarPath = jarPath; if (oldURI != null) { oldJarPath = path.append(oldURI); } // Establish the destination directory path = jarPath.removeLastSegments(1); // Remove if requested or if previously published and are now serving without publishing if (moving || kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED || isServeModulesWithoutPublish()) { File file = oldJarPath.toFile(); if (file.exists()) file.delete(); properties.remove(module[1].getId()); if (deltaKind == ServerBehaviourDelegate.REMOVED || isServeModulesWithoutPublish()) return; } if (!moving && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL) { // avoid changes if no changes to module since last publish IModuleResourceDelta[] delta = getPublishedResourceDelta(module); if (delta == null || delta.length == 0) return; } // make directory if it doesn't exist if (!path.toFile().exists()) { path.toFile().mkdirs(); } IModuleResource[] mr = getResources(module); IStatus[] status = helper.publishZip(mr, jarPath, monitor); addArrayToList(statuses, status); properties.put(module[1].getId(), jarURI); }
Example 20
Source File: ManifestBasedSREInstall.java From sarl with Apache License 2.0 | 4 votes |
@Override public void getAsXML(Document document, Element element) throws IOException { if (isDirty()) { setDirty(false); resolveDirtyFields(true); } final IPath path = getJarFile(); element.setAttribute(SREXmlPreferenceConstants.XML_LIBRARY_PATH, path.toPortableString()); final String name = Strings.nullToEmpty(getName()); if (!name.equals(this.manifestName)) { element.setAttribute(SREXmlPreferenceConstants.XML_SRE_NAME, name); } final String mainClass = Strings.nullToEmpty(getMainClass()); if (!mainClass.equals(this.manifestMainClass)) { element.setAttribute(SREXmlPreferenceConstants.XML_MAIN_CLASS, mainClass); } final String bootstrap = Strings.nullToEmpty(getBootstrap()); if (!Strings.isNullOrEmpty(bootstrap)) { element.setAttribute(SREXmlPreferenceConstants.XML_BOOTSTRAP, bootstrap); } else { element.removeAttribute(SREXmlPreferenceConstants.XML_BOOTSTRAP); } final List<IRuntimeClasspathEntry> libraries = getClassPathEntries(); if (libraries.size() != 1 || !libraries.get(0).getClasspathEntry().getPath().equals(this.jarFile)) { final IPath rootPath = path.removeLastSegments(1); for (final IRuntimeClasspathEntry location : libraries) { final Element libraryNode = document.createElement(SREXmlPreferenceConstants.XML_LIBRARY_LOCATION); libraryNode.setAttribute(SREXmlPreferenceConstants.XML_SYSTEM_LIBRARY_PATH, makeRelativePath(location.getPath(), path, rootPath)); libraryNode.setAttribute(SREXmlPreferenceConstants.XML_PACKAGE_ROOT_PATH, makeRelativePath(location.getSourceAttachmentRootPath(), path, rootPath)); libraryNode.setAttribute(SREXmlPreferenceConstants.XML_SOURCE_PATH, makeRelativePath(location.getSourceAttachmentPath(), path, rootPath)); /* No javadoc path accessible from ClasspathEntry final URL javadoc = location.getJavadocLocation(); if (javadoc != null) { libraryNode.setAttribute(SREConstants.XML_JAVADOC_PATH, javadoc.toString()); } */ element.appendChild(libraryNode); } } }