Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IClasspathContainer


    if (javaProject == null) return;
    ClasspathContainerInitializer scalaInitializer = JavaCore.getClasspathContainerInitializer(SCALA_CONTAINER_PATH);
    if (scalaInitializer == null) return;
    IPath scalaContainerPath = Path.fromPortableString(SCALA_CONTAINER_PATH);
    Boolean updateAble = scalaInitializer.canUpdateClasspathContainer(scalaContainerPath, javaProject);
    final IClasspathContainer scalaLibrary = JavaCore.getClasspathContainer(scalaContainerPath, javaProject);
    final IClasspathEntry[] cpEntries = scalaLibrary.getClasspathEntries();

    for(int i = 0; i < cpEntries.length; i++ ) {
      IClasspathEntry cpe = cpEntries[i];
      LinkedHashMap<String, IClasspathAttribute> attrs = new LinkedHashMap<String, IClasspathAttribute>();
      for(IClasspathAttribute attr : cpe.getExtraAttributes()) {
        //Keep all existing attributes except the non_deployable key
        if(!attr.getName().equals(NON_DEPLOYABLE_KEY)) {
          attrs.put(attr.getName(), attr);
        }
      }
      attrs.put(deployableAttribute.getName(), deployableAttribute);
      IClasspathAttribute[] newAttrs = attrs.values().toArray(new IClasspathAttribute[attrs.size()]);
      cpEntries[i] = JavaCore.newLibraryEntry(cpe.getPath(), cpe.getSourceAttachmentPath(),
          cpe.getSourceAttachmentRootPath(), cpe.getAccessRules(), newAttrs, cpe.isExported());
    }

    IClasspathContainer candidateScalaContainer = new IClasspathContainer() {
      public IPath getPath() { return scalaLibrary.getPath(); }
      public IClasspathEntry[] getClasspathEntries() { return cpEntries; }
      public String getDescription() { return scalaLibrary.getDescription(); }
      public int getKind() { return scalaLibrary.getKind(); }
    };
View Full Code Here


     */
    public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
        if (IvyClasspathUtil.isIvyClasspathContainer(containerPath)) {

            // try to get an existing one
            IClasspathContainer container = null;
            try {
                container = JavaCore.getClasspathContainer(containerPath, project);
            } catch (JavaModelException ex) {
                // unless there are issues with the JDT, this should never happen
                IvyPlugin.log(IStatus.ERROR, "Unable to get container for "
                        + containerPath.toString(), ex);
                return;
            }

            try {
                IvyClasspathContainer ivycp;

                if (container instanceof IvyClasspathContainer) {
                    ivycp = (IvyClasspathContainer) container;
                } else {

                    IClasspathEntry entry =
                            IvyClasspathUtil.getIvyClasspathEntry(containerPath, project);
                    IClasspathAttribute[] attributes = new IClasspathAttribute[0];
                    if (entry != null) {
                        attributes = entry.getExtraAttributes();
                    }

                    if (container == null) {
                        ivycp = new IvyClasspathContainer(project, containerPath,
                                new IClasspathEntry[0], attributes);
                    } else {
                        // this might be the persisted one : reuse the persisted entries
                        ivycp = new IvyClasspathContainer(project, containerPath, container
                                .getClasspathEntries(), attributes);
                    }                   
                }

                // set the container
View Full Code Here

     * @return the IvyClasspathContainer is such, null, if not
     */
    public static IvyClasspathContainer jdt2IvyCPC(ClassPathContainer cpc) {
        IClasspathEntry entry = cpc.getClasspathEntry();
        try {
            IClasspathContainer icp = JavaCore.getClasspathContainer(entry.getPath(), cpc
                    .getJavaProject());
            if (icp instanceof IvyClasspathContainer) {
                return (IvyClasspathContainer) icp;
            }
        } catch (JavaModelException e) {
View Full Code Here

            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry entry = entries[i];
                if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                    IPath path = entry.getPath();
                    if (isIvyClasspathContainer(path)) {
                        IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
                        if (cp instanceof IvyClasspathContainer) {
                            containers.add(cp);
                        }
                    }
                }
View Full Code Here

            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry entry = entries[i];
                if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                    IPath path = entry.getPath();
                    if (isIvyClasspathContainer(path)) {
                        IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
                        if (cp instanceof IvyClasspathContainer) {
                            IvyClasspathContainer ivycp = (IvyClasspathContainer) cp;
                            if (ivycp.getConf().getIvyXmlPath().equals(
                                ivyfile.getProjectRelativePath().toString())) {
                                containers.add(ivycp);
View Full Code Here

            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry entry = entries[i];
                if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                    IPath path = entry.getPath();
                    if (isIvyClasspathContainer(path)) {
                        IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
                        if (cp instanceof IvyClasspathContainer) {
                            IvyClasspathContainer ivycp = (IvyClasspathContainer) cp;
                            String settingsPath;
                            try {
                                settingsPath = ivycp.getConf().getInheritedIvySettingsPath();
View Full Code Here

            IRuntimeClasspathEntry entry, IJavaProject project) throws CoreException {
        if (project == null || entry == null) {
            // cannot resolve without entry or project context
            return new IRuntimeClasspathEntry[0];
        }
        IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project);
        if (container == null) {
            String message = "Could not resolve classpath container: " + entry.getPath().toString();
            throw new CoreException(new Status(IStatus.ERROR, IvyPlugin.ID,
                    IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, null));
            // execution will not reach here - exception will be thrown
        }
        IvyClasspathContainer ivycp = (IvyClasspathContainer) container;
        if (ivycp.getConf().isInheritedResolveBeforeLaunch()) {
            IStatus status = ivycp.launchResolve(false, false, new NullProgressMonitor());
            if (status.getCode() != IStatus.OK) {
                throw new CoreException(status);
            }
        }
        IClasspathEntry[] cpes = container.getClasspathEntries();
        int property = -1;
        switch (container.getKind()) {
            case IClasspathContainer.K_APPLICATION:
                property = IRuntimeClasspathEntry.USER_CLASSES;
                break;
            case IClasspathContainer.K_DEFAULT_SYSTEM:
                property = IRuntimeClasspathEntry.STANDARD_CLASSES;
View Full Code Here

    public static String installedRuntimeClasspath() throws CoreException {
       
        List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
        for (IExtension extension: Platform.getExtensionRegistry().getExtensionPoint(TUSCANY_RUNTIME_LIBRARIES).getExtensions()) {
            for (IConfigurationElement configuration: extension.getConfigurationElements()) {
                IClasspathContainer container = (IClasspathContainer)configuration.createExecutableExtension("class");
                classpathEntries.addAll(Arrays.asList(container.getClasspathEntries()));
            }
        }
       
        String separator = System.getProperty("path.separator");
        StringBuffer classpath = new StringBuffer();
View Full Code Here

      IClasspathEntry entry = cp[i];
      int kind = entry.getEntryKind();
      String path = null;
      if(kind == IClasspathEntry.CPE_CONTAINER) {
        if("org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER".equals(entry.getPath().toString())) {
          IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), jp);
          IClasspathEntry[] containerEntries = container.getClasspathEntries();
          for(int j = 0; j  < containerEntries.length; j++) {
            addEntry(entries, resolveVarOrLibEntry(containerEntries[j]));
          }
        }
      } else if (kind == IClasspathEntry.CPE_PROJECT) {
View Full Code Here

    }
    if (project == null || entry == null) {
      // cannot resolve without entry or project context
      return new IRuntimeClasspathEntry[0];
    }
    IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project);
    if (container == null) {
      abort(MessageFormat.format(LaunchingMessages.JavaRuntime_Could_not_resolve_classpath_container___0__1, new Object[] { entry.getPath().toString() }), null);
      // execution will not reach here - exception will be thrown
      return null;
    }
    IClasspathEntry[] cpes = container.getClasspathEntries();
    int property = -1;
    switch (container.getKind()) {
    case IClasspathContainer.K_APPLICATION:
      property = IRuntimeClasspathEntry.USER_CLASSES;
      break;
    case IClasspathContainer.K_DEFAULT_SYSTEM:
      property = IRuntimeClasspathEntry.STANDARD_CLASSES;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IClasspathContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.