Java Code Examples for org.netbeans.spi.java.classpath.support.ClassPathSupport#createProxyClassPath()
The following examples show how to use
org.netbeans.spi.java.classpath.support.ClassPathSupport#createProxyClassPath() .
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: AddGoogleDependencyAction.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
private void findCompileTimeDependencies(NbAndroidProject project, List<ArtifactData> compileDependecies) { final ClassPathProvider cpProvider = project.getLookup().lookup(ClassPathProvider.class); if (cpProvider != null) { Sources srcs = ProjectUtils.getSources(project); SourceGroup[] sourceGroups = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); Set<FileObject> roots = Sets.newHashSet(); for (SourceGroup sg : sourceGroups) { roots.add(sg.getRootFolder()); } Iterable<ClassPath> compileCPs = Iterables.transform(roots, new Function<FileObject, ClassPath>() { @Override public ClassPath apply(FileObject f) { return cpProvider.findClassPath(f, ClassPath.COMPILE); } }); ClassPath compileCP = ClassPathSupport.createProxyClassPath(Lists.newArrayList(compileCPs).toArray(new ClassPath[0])); if (cpProvider instanceof AndroidClassPath) { for (FileObject cpRoot : compileCP.getRoots()) { ArtifactData lib = ((AndroidClassPath) cpProvider).getArtifactData(cpRoot.toURL()); compileDependecies.add(lib); } } } }
Example 2
Source File: ShellProjectUtils.java From netbeans with Apache License 2.0 | 6 votes |
public static ClassPath projecRuntimeClassPath(Project project) { if (project == null) { return null; } boolean modular = isModularProject(project); List<ClassPath> delegates = new ArrayList<>(); for (SourceGroup sg : org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) { if (!isNormalRoot(sg)) { continue; } ClassPath del; if (modular) { del = ClassPath.getClassPath(sg.getRootFolder(), JavaClassPathConstants.MODULE_EXECUTE_CLASS_PATH); } else { del = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE); } if (del != null && !del.entries().isEmpty()) { delegates.add(del); } } return ClassPathSupport.createProxyClassPath(delegates.toArray(new ClassPath[delegates.size()])); }
Example 3
Source File: ProjectRunnerImpl.java From netbeans with Apache License 2.0 | 6 votes |
@CheckForNull private static FileObject findOwnerRoot( @NonNull final String className, @NonNull final String[] extensions, @NonNull final ClassPath... binCps) { final String binaryResource = FileObjects.convertPackage2Folder(className); final ClassPath merged = ClassPathSupport.createProxyClassPath(binCps); for (String ext : extensions) { final FileObject res = merged.findResource(String.format( "%s.%s", //NOI18N binaryResource, ext)); if (res != null) { return merged.findOwnerRoot(res); } } return null; }
Example 4
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 6 votes |
static ClassPath createSourcePath ( Project project, Path modulepath, Path classpath, Path sourcepath, boolean isSourcePathExclusive ) { if (sourcepath != null && isSourcePathExclusive) { return convertToClassPath (project, sourcepath); } ClassPath cp = convertToSourcePath (project, classpath, true); ClassPath modulesSources = convertToSourcePath(project, modules(project, modulepath), true); ClassPath sp = convertToClassPath (project, sourcepath); ClassPath sourcePath = ClassPathSupport.createProxyClassPath ( new ClassPath[] {cp, modulesSources, sp} ); return sourcePath; }
Example 5
Source File: GlobalAndroidClassPathRegistry.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
public synchronized static final ClassPath getClassPath(final String id, URL[] urls) { if (urls.length == 0) { return ClassPath.EMPTY; } else { ClassPath tmp[] = new ClassPath[urls.length]; for (int i = 0; i < urls.length; i++) { ClassPath classPath = cache.get(urls[i]); if (classPath == null) { classPath = ClassPathSupport.createClassPath(urls[i]); cache.put(urls[i], classPath); } tmp[i] = classPath; } return ClassPathSupport.createProxyClassPath(tmp); } }
Example 6
Source File: IDEOutputListenerProvider.java From netbeans with Apache License 2.0 | 6 votes |
private ClassPath createCP(Project prj, HashSet<Project> parents) { parents.add(prj); List<ClassPath> list = new ArrayList<ClassPath>(); ProjectSourcesClassPathProvider cpp = prj.getLookup().lookup(ProjectSourcesClassPathProvider.class); ClassPath[] cp = cpp.getProjectClassPaths(ClassPath.EXECUTE); list.addAll(Arrays.asList(cp)); //for pom packaging projects subprojects/modules matter //TODO for application project it's DependencyProjectProvider, for pom project (run-ide?) it's containerprojectprovider SubprojectProvider spp = prj.getLookup().lookup(SubprojectProvider.class); if (spp != null) { for (Project sub : spp.getSubprojects()) { if (parents.contains(sub)) { continue; } ClassPath c = createCP(sub, parents); if (c != null) { list.add(c); } } } if (list.size() > 0) { return ClassPathSupport.createProxyClassPath(list.toArray(new ClassPath[list.size()])); } return null; }
Example 7
Source File: JsfModelProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
private static ClassPath getClassPath(Project project, String type) { ClassPathProvider provider = project.getLookup().lookup( ClassPathProvider.class); if (provider == null) { return null; } Sources sources = ProjectUtils.getSources(project); if (sources == null) { return null; } SourceGroup[] sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); for (SourceGroup sourceGroup : sourceGroups) { FileObject rootFolder = sourceGroup.getRootFolder(); ClassPath path = provider.findClassPath(rootFolder, type); // return classpath of the first source group, that is ignore test source roots: return ClassPathSupport.createProxyClassPath(path); } return null; }
Example 8
Source File: OutputUtils.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected ClassPath getClassPath() { Project prj = ref.get(); if(prj != null) { ClassPath[] cp = prj.getLookup().lookup(ProjectSourcesClassPathProvider.class).getProjectClassPaths(ClassPath.EXECUTE); return ClassPathSupport.createProxyClassPath(cp); } return null; }
Example 9
Source File: RulesManagerImpl.java From netbeans with Apache License 2.0 | 5 votes |
public Holder(ClasspathInfo cpInfo) { cpInfo.addChangeListener(this); LinkedList<ClassPath> cps = new LinkedList<ClassPath>(); cps.add(cpInfo.getClassPath(PathKind.BOOT)); cps.add(cpInfo.getClassPath(PathKind.COMPILE)); cps.add(cpInfo.getClassPath(PathKind.SOURCE)); compound = ClassPathSupport.createProxyClassPath(cps.toArray(new ClassPath[0])); }
Example 10
Source File: EjbJarActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void updateJavaRunnerClasspath(String command, Map<String, Object> execProperties) { if (COMMAND_TEST_SINGLE.equals(command) || COMMAND_DEBUG_TEST_SINGLE.equals(command) || SingleMethod.COMMAND_DEBUG_SINGLE_METHOD.equals(command) || SingleMethod.COMMAND_RUN_SINGLE_METHOD.equals(command) || COMMAND_RUN_SINGLE.equals(command) || COMMAND_DEBUG_SINGLE.equals(command) || COMMAND_PROFILE_SINGLE.equals(command) || COMMAND_PROFILE_TEST_SINGLE.equals(command)) { FileObject fo = (FileObject)execProperties.get(JavaRunner.PROP_EXECUTE_FILE); ClassPath cp = getCallback().findClassPath(fo, ClassPath.EXECUTE); ClassPath cp2 = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( FileUtil.toFile(getProject().getProjectDirectory()), getEvaluator(), new String[]{"j2ee.platform.classpath", "j2ee.platform.embeddableejb.classpath"})); cp = ClassPathSupport.createProxyClassPath(cp, cp2); execProperties.put(JavaRunner.PROP_EXECUTE_CLASSPATH, cp); Collection<String> coll = (Collection<String>)execProperties.get(JavaRunner.PROP_RUN_JVMARGS); if (coll == null) { coll = new LinkedList<String>(); execProperties.put(JavaRunner.PROP_RUN_JVMARGS, coll); } String s = getEvaluator().getProperty(EjbJarProjectProperties.RUNMAIN_JVM_ARGS); if (s != null && s.trim().length() > 0) { coll.add(s); } s = getEvaluator().getProperty(ProjectProperties.ENDORSED_CLASSPATH); if (s != null && s.trim().length() > 0) { ClassPath ecp = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( FileUtil.toFile(getProject().getProjectDirectory()), getEvaluator(), new String[]{ProjectProperties.ENDORSED_CLASSPATH})); coll.add("-Xbootclasspath/p:\""+ecp.toString(ClassPath.PathConversionMode.WARN) +"\""); } } }
Example 11
Source File: AppClientPersistenceProvider.java From netbeans with Apache License 2.0 | 5 votes |
private ClassPath getProjectSourcesClassPath() { synchronized (this) { if (projectSourcesClassPath == null) { projectSourcesClassPath = ClassPathSupport.createProxyClassPath(new ClassPath[] { cpProvider.getProjectSourcesClassPath(ClassPath.SOURCE), cpProvider.getProjectSourcesClassPath(ClassPath.COMPILE), }); } return projectSourcesClassPath; } }
Example 12
Source File: AndroidJavaPlatform.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
AndroidJavaPlatform(AndroidPlatformInfo pkg, String javaVersion) { this.pkg = pkg; this.specification = new Specification("j2se", new SpecificationVersion(javaVersion)); if ("1.8".equals(javaVersion)) { URL java8 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(VIRTUALJAVA8ROOT_DIR)); ClassPath java8ClassPath = ClassPathSupport.createClassPath(new URL[]{java8}); this.boot = ClassPathSupport.createProxyClassPath(java8ClassPath, GlobalAndroidClassPathRegistry.getClassPath(ClassPath.BOOT, pkg.getBootURLs())); } else { this.boot = GlobalAndroidClassPathRegistry.getClassPath(ClassPath.BOOT, pkg.getBootURLs()); } this.source = GlobalAndroidClassPathRegistry.getClassPath(ClassPath.SOURCE, pkg.getSrcURLs()); }
Example 13
Source File: AndroidClassPathProvider.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
private ClassPath createExecute(ClassPath compile) { if (androidProjectModel != null) { Variant variant = buildConfig.getCurrentVariant(); if (variant != null) { return ClassPathSupport.createProxyClassPath(compile, ClassPathSupport.createClassPath( FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(variant.getMainArtifact().getClassesFolder())))); } } return compile; }
Example 14
Source File: ShellSession.java From netbeans with Apache License 2.0 | 5 votes |
private void initClasspath() { ClasspathInfo.Builder bld = new ClasspathInfo.Builder( projectInfo.getClassPath(ClasspathInfo.PathKind.BOOT) ); ClassPath snippetSource = ClassPathSupport.createProxyClassPath( projectInfo.getClassPath(PathKind.SOURCE), ClassPathSupport.createClassPath(editorWorkRoot), ClassPathSupport.createClassPath(workRoot) ); ClassPath compileClasspath = projectInfo.getClassPath(PathKind.COMPILE); ClassPath modBoot = projectInfo.getClassPath(ClasspathInfo.PathKind.MODULE_BOOT); ClassPath modClass = projectInfo.getClassPath(ClasspathInfo.PathKind.MODULE_CLASS); ClassPath modCompile = projectInfo.getClassPath(ClasspathInfo.PathKind.MODULE_COMPILE); bld. setClassPath(compileClasspath). setSourcePath(snippetSource). setModuleBootPath(modBoot). setModuleClassPath(modClass). setModuleCompilePath(modCompile); /* this.cpInfo = ClasspathInfo.create( projectInfo.getClassPath(PathKind.BOOT), compileClasspath, snippetSource ); */ this.cpInfo = bld.build(); this.consoleDocument.putProperty("java.classpathInfo", this.cpInfo); }
Example 15
Source File: ClassPathProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
private synchronized ClassPath getSourcepath(FileType type) { if (type == FileType.WEB_SOURCE) { ClassPath cp = cache.get(ClassPathCache.WEB_SOURCE); if (cp == null) { cp = ClassPathSupport.createProxyClassPath(new ClassPath[] { ClassPathFactory.createClassPath(new JspSourcePathImplementation(helper, evaluator)), ClassPathFactory.createClassPath(ClassPathSupportFactory.createSourcePathImplementation (this.sourceRoots, helper, evaluator)), }); cache.put(ClassPathCache.WEB_SOURCE, cp); } return cp; } return null; }
Example 16
Source File: WebActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void updateJavaRunnerClasspath(String command, Map<String, Object> execProperties) { if (COMMAND_TEST_SINGLE.equals(command) || COMMAND_DEBUG_TEST_SINGLE.equals(command) || COMMAND_PROFILE_TEST_SINGLE.equals(command) || SingleMethod.COMMAND_DEBUG_SINGLE_METHOD.equals(command) || SingleMethod.COMMAND_RUN_SINGLE_METHOD.equals(command) || COMMAND_RUN_SINGLE.equals(command) || COMMAND_DEBUG_SINGLE.equals(command) || COMMAND_PROFILE_SINGLE.equals(command)) { FileObject fo = (FileObject)execProperties.get(JavaRunner.PROP_EXECUTE_FILE); ClassPath cp = getCallback().findClassPath(fo, ClassPath.EXECUTE); ClassPath cp2 = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( FileUtil.toFile(getProject().getProjectDirectory()), getEvaluator(), new String[]{"j2ee.platform.classpath", "j2ee.platform.embeddableejb.classpath"})); cp = ClassPathSupport.createProxyClassPath(cp, cp2); execProperties.put(JavaRunner.PROP_EXECUTE_CLASSPATH, cp); Collection<String> coll = (Collection<String>)execProperties.get(JavaRunner.PROP_RUN_JVMARGS); if (coll == null) { coll = new LinkedList<String>(); execProperties.put(JavaRunner.PROP_RUN_JVMARGS, coll); } String s = getEvaluator().getProperty(WebProjectProperties.RUNMAIN_JVM_ARGS); if (s != null && s.trim().length() > 0) { coll.add(s); } s = getEvaluator().getProperty(ProjectProperties.ENDORSED_CLASSPATH); if (s != null && s.trim().length() > 0) { ClassPath ecp = ClassPathFactory.createClassPath( ProjectClassPathSupport.createPropertyBasedClassPathImplementation( FileUtil.toFile(getProject().getProjectDirectory()), getEvaluator(), new String[]{ProjectProperties.ENDORSED_CLASSPATH})); coll.add("-Xbootclasspath/p:\""+ecp.toString(ClassPath.PathConversionMode.WARN) +"\""); } } }
Example 17
Source File: ComputeOverridersTest.java From netbeans with Apache License 2.0 | 5 votes |
public ClassPath findClassPath(FileObject file, String type) { try { FileObject root = findRoot(file); if (root == null) { return null; } if (ClassPath.BOOT == type) { return ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0])); } if (ClassPath.SOURCE == type) { return ClassPathSupport.createClassPath(new FileObject[] { root }); } if (ClassPath.COMPILE == type) { return root2ClassPath.get(root); } if (ClassPath.EXECUTE == type) { return ClassPathSupport.createProxyClassPath( root2ClassPath.get(root), ClassPathSupport.createClassPath(new FileObject[] { root2BuildRoot.get(root) }) ); } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 18
Source File: PersistenceScopeImpl.java From netbeans with Apache License 2.0 | 5 votes |
private ClassPath getProjectSourcesClassPath() { synchronized (this) { if (projectSourcesClassPath == null) { projectSourcesClassPath = ClassPathSupport.createProxyClassPath(new ClassPath[] { cpProvider.getProjectSourcesClassPath(ClassPath.SOURCE), cpProvider.getProjectSourcesClassPath(ClassPath.COMPILE), }); } return projectSourcesClassPath; } }
Example 19
Source File: J2SEPersistenceProvider.java From netbeans with Apache License 2.0 | 5 votes |
private ClassPath getProjectSourcesClassPath() { synchronized (this) { if (projectSourcesClassPath == null) { projectSourcesClassPath = ClassPathSupport.createProxyClassPath(new ClassPath[]{ cpProvider.getProjectSourcesClassPath(ClassPath.SOURCE), cpProvider.getProjectSourcesClassPath(ClassPath.COMPILE),}); } return projectSourcesClassPath; } }
Example 20
Source File: ContainerCPModifierImpl.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void extendClasspath(final FileObject file, final String[] symbolicNames) { if (symbolicNames == null) { return; } final Boolean[] added = new Boolean[1]; added[0] = Boolean.FALSE; ModelOperation<POMModel> operation = new ModelOperation<POMModel>() { @Override public void performOperation(POMModel model) { Map<String, Item> items = createItemList(); ProjectSourcesClassPathProvider prv = project.getLookup().lookup(ProjectSourcesClassPathProvider.class); ClassPath[] cps = prv.getProjectClassPaths(ClassPath.COMPILE); ClassPath cp = ClassPathSupport.createProxyClassPath(cps); Profile version = Profile.JAVA_EE_5; //sort of fallback WebModule wm = WebModule.getWebModule(file); if (wm != null) { version = wm.getJ2eeProfile(); } else { EjbJar ejb = EjbJar.getEjbJar(file); if (ejb != null) { version = ejb.getJ2eeProfile(); } } for (String name : symbolicNames) { Item item = items.get(name + ":" + version.toPropertiesString()); //NOI18N if (item != null) { if (item.classToCheck != null) { FileObject fo = cp.findResource(item.classToCheck); if (fo != null) { //skip, already on CP somehow.. continue; } } Dependency dep = ModelUtils.checkModelDependency(model, item.groupId, item.artifactId, true); dep.setVersion(item.version); dep.setScope(Artifact.SCOPE_PROVIDED); added[0] = Boolean.TRUE; } else { LOGGER.log(Level.WARNING, "Cannot process api with symbolic name: {0}. Nothing will be added to project''s classpath.", name); } } } }; FileObject pom = project.getProjectDirectory().getFileObject("pom.xml"); //NOI18N Utilities.performPOMModelOperations(pom, Collections.singletonList(operation)); if (added[0]) { if (!SwingUtilities.isEventDispatchThread()) { project.getLookup().lookup(NbMavenProject.class).downloadDependencyAndJavadocSource(true); } } }