org.netbeans.modules.maven.api.NbMavenProject Java Examples
The following examples show how to use
org.netbeans.modules.maven.api.NbMavenProject.
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: MavenPersistenceProvider.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates a new instance of MavenPersistenceProvider */ public MavenPersistenceProvider(Project proj, Lookup lkp) { NbMavenProject watcher = lkp.lookup(NbMavenProject.class); locProvider = new PersistenceLocationProviderImpl(proj, watcher); scopeProvider = new PersistenceScopeProviderImpl(locProvider, proj); scopesProvider = new PersistenceScopesProviderImpl(scopeProvider); propChangeSupport.addPropertyChangeListener(locProvider); propChangeSupport.addPropertyChangeListener(scopesProvider); //TODO add FileChangeListener on persistence.xml watcher.addWatchedPath(PersistenceLocationProviderImpl.DEF_PERSISTENCE); watcher.addWatchedPath(PersistenceLocationProviderImpl.ALT_PERSISTENCE); watcher.addPropertyChangeListener(WeakListeners.propertyChange(res, watcher)); }
Example #2
Source File: Utils.java From netbeans with Apache License 2.0 | 6 votes |
private static Set<String> collectClasspaths(Project prj) throws DependencyResolutionRequiredException { Set<String> toRet = new HashSet<String>(); NbMavenProject watcher = prj.getLookup().lookup(NbMavenProject.class); MavenProject mproject = watcher.getMavenProject(); //TODO this ought to be really configurable based on what class gets debugged. toRet.addAll(mproject.getTestClasspathElements()); //for poms also include all module projects recursively.. boolean isPom = NbMavenProject.TYPE_POM.equals(watcher.getPackagingType()); if (isPom) { ProjectContainerProvider subs = prj.getLookup().lookup(ProjectContainerProvider.class); ProjectContainerProvider.Result res = subs.getContainedProjects(); for (Project pr : res.getProjects()) { toRet.addAll(collectClasspaths(pr)); } } return toRet; }
Example #3
Source File: J2eeActions.java From netbeans with Apache License 2.0 | 6 votes |
public final @Override Action createContextAwareInstance(Lookup actionContext) { Collection<? extends Project> projects = actionContext.lookupAll(Project.class); if (projects.size() != 1) { return this; } Project prj = projects.iterator().next().getLookup().lookup(Project.class); if (prj == null) { return this; } J2eeModuleProvider prov = prj.getLookup().lookup(J2eeModuleProvider.class); if (prov == null) { return this; } NbMavenProject mProj = prj.getLookup().lookup(NbMavenProject.class); if (mProj == null) { return this; } if (!prov.hasVerifierSupport()) { return this; } return new VerifyAction(prj, mProj, prov); }
Example #4
Source File: Utils.java From netbeans with Apache License 2.0 | 6 votes |
private static Set<String> collectSourceRoots(Project prj) { Set<String> toRet = new HashSet<String>(); NbMavenProject watcher = prj.getLookup().lookup(NbMavenProject.class); MavenProject mproject = watcher.getMavenProject(); //TODO this ought to be really configurable based on what class gets debugged. toRet.addAll(mproject.getTestCompileSourceRoots()); //for poms also include all module projects recursively.. boolean isPom = NbMavenProject.TYPE_POM.equals(watcher.getPackagingType()); if (isPom) { //only for pom is correct use of subprojectprovider ProjectContainerProvider subs = prj.getLookup().lookup(ProjectContainerProvider.class); ProjectContainerProvider.Result res = subs.getContainedProjects(); for (Project pr : res.getProjects()) { toRet.addAll(collectSourceRoots(pr)); } } return toRet; }
Example #5
Source File: PackagesPanelProvider.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Category createCategory(Lookup context) { Project project = context.lookup(Project.class); NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); String effPackaging = watcher.getPackagingType(); String[] types = PluginPropertyUtils.getPluginPropertyList(project, OSGiConstants.GROUPID_FELIX, OSGiConstants.ARTIFACTID_BUNDLE_PLUGIN, "supportedProjectTypes", "supportedProjectType", /*"bundle" would not work for GlassFish parent POM*/null); if (types != null) { for (String type : types) { if (effPackaging.equals(type)) { effPackaging = NbMavenProject.TYPE_OSGI; } } } if (NbMavenProject.TYPE_OSGI.equalsIgnoreCase(effPackaging)) { return ProjectCustomizer.Category.create( ModelHandle2.PANEL_COMPILE, org.openide.util.NbBundle.getMessage(PackagesPanelProvider.class, "TIT_Packages"), null); } return null; }
Example #6
Source File: AbstractMavenActionsProvider.java From netbeans with Apache License 2.0 | 6 votes |
private NetbeansActionMapping findMapAction(Map<String, String> replaceMap, Project project, String actionName) throws XmlPullParserException, IOException { // TODO need some caching really badly here.. Reader read = performDynamicSubstitutions(replaceMap, getRawMappingsAsString()); ActionToGoalMapping mapping = reader.read(read); Iterator<NetbeansActionMapping> it = mapping.getActions().iterator(); NetbeansActionMapping action = null; NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class); String prjPack = mp.getPackagingType(); while (it.hasNext()) { NetbeansActionMapping elem = it.next(); if (actionName.equals(elem.getActionName()) && (elem.getPackagings().contains(prjPack.trim()) || elem.getPackagings().contains("*") || elem.getPackagings().isEmpty())) {//NOI18N action = elem; break; } } return action; }
Example #7
Source File: ProjectOpenedHookImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent pce) { if (NbMavenProject.PROP_PROJECT.equals(pce.getPropertyName())) { NbMavenProjectImpl project = proj.getLookup().lookup(NbMavenProjectImpl.class); Set<URI> newuris = getProjectExternalSourceRoots(project); synchronized (uriReferences) { Set<URI> olduris = new HashSet<URI>(uriReferences); olduris.removeAll(newuris); newuris.removeAll(uriReferences); for (URI old : olduris) { FileOwnerQuery.markExternalOwner(old, null, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); } for (URI nw : newuris) { FileOwnerQuery.markExternalOwner(nw, proj, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT); } uriReferences.removeAll(olduris); uriReferences.addAll(newuris); } } }
Example #8
Source File: CommandLineOutputHandler.java From netbeans with Apache License 2.0 | 6 votes |
@Override public @CheckForNull NbMavenProject find(@NonNull Project root) { // XXX EventSpy (#194090) would make this more reliable and efficient for (Project module : root.getLookup().lookup(ProjectContainerProvider.class).getContainedProjects().getProjects()) { if (Thread.interrupted()) { break; } NbMavenProject nbmp = module.getLookup().lookup(NbMavenProject.class); if (nbmp == null) { continue; } MavenProject mp = nbmp.getMavenProject(); if (firstFailure.equals(mp.getName())) { return nbmp; } } return null; }
Example #9
Source File: SubprojectProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
public SubprojectProviderImpl(Project proj) { project = proj; propertyChange = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) { cs.fireChange(); } } }; listener2 = new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { cs.fireChange(); } }; MavenFileOwnerQueryImpl.getInstance().addChangeListener( WeakListeners.change(listener2, MavenFileOwnerQueryImpl.getInstance())); }
Example #10
Source File: MavenNbModuleImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void run() { FileObject fo = project.getProjectDirectory().getFileObject("pom.xml"); //NOI18N final DependencyAdder monitor = this; ModelOperation<POMModel> operation = new ModelOperation<POMModel>() { @Override public void performOperation(POMModel model) { synchronized (monitor) { for (Dependency dep : toAdd) { org.netbeans.modules.maven.model.pom.Dependency mdlDep = ModelUtils.checkModelDependency(model, dep.getGroupId(), dep.getArtifactId(), true); mdlDep.setVersion(dep.getVersion()); if (dep.getScope() != null) { mdlDep.setScope(dep.getScope()); } } toAdd.clear(); } } }; Utilities.performPOMModelOperations(fo, Collections.singletonList(operation)); project.getLookup().lookup(NbMavenProject.class).synchronousDependencyDownload(); }
Example #11
Source File: EmbeddableEJBContainerHint.java From netbeans with Apache License 2.0 | 6 votes |
@Override public ChangeInfo implement() throws Exception { final Boolean[] added = new Boolean[1]; ModelOperation<POMModel> operation = new ModelOperation<POMModel>() { @Override public void performOperation(POMModel model) { added[0] = checkAndAddPom(pomUrl, model, file); } }; FileObject pom = project.getProjectDirectory().getFileObject("pom.xml");//NOI18N org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(pom, Collections.singletonList(operation)); //TODO is the manual reload necessary if pom.xml file is being saved? // NbMavenProject.fireMavenProjectReload(project); if (added[0]) { project.getLookup().lookup(NbMavenProject.class).triggerDependencyDownload(); } return null; }
Example #12
Source File: ReactorChecker.java From netbeans with Apache License 2.0 | 6 votes |
private static @CheckForNull NbMavenProject load(File parentDir) { if (parentDir == null) { return null; } FileObject d = FileUtil.toFileObject(parentDir); if (d != null) { try { Project p = ProjectManager.getDefault().findProject(d); if (p != null) { return p.getLookup().lookup(NbMavenProject.class); } } catch (IOException x) { Exceptions.printStackTrace(x); } } return null; }
Example #13
Source File: WebModuleImpl.java From netbeans with Apache License 2.0 | 6 votes |
private Profile getProfileFromPOM(final Project project) { final NbMavenProject nbMavenProject = project.getLookup().lookup(NbMavenProject.class); if (nbMavenProject != null) { MavenProject mavenProject = nbMavenProject.getMavenProject(); List<Dependency> dependencies = mavenProject.getDependencies(); for (Map.Entry<Profile, List<DependencyDesc>> entry : javaEEMap.entrySet()) { for (DependencyDesc dependencyDesc : entry.getValue()) { Dependency dependency = checkForDependency(dependencies, dependencyDesc); if (dependency != null) { String version = dependency.getVersion(); if (dependencyDesc.version == null || (version != null && version.startsWith(dependencyDesc.version))) { return entry.getKey(); } } } } } return null; }
Example #14
Source File: ProblemReporterImplTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMissingParent() throws Exception { TestFileUtils.writeFile(new File(getWorkDir(), "pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'><modelVersion>4.0.0</modelVersion>" + "<parent><groupId>g</groupId><artifactId>par</artifactId><version>0</version></parent>" + "<artifactId>m</artifactId>" + "</project>"); Project p = ProjectManager.getDefault().findProject(FileUtil.toFileObject(getWorkDir())); assertEquals("g:m:jar:0", p.getLookup().lookup(NbMavenProject.class).getMavenProject().getId()); ProblemReporterImpl pr = getReporter(p); MavenModelProblemsProvider mpp = new MavenModelProblemsProvider(p); Collection<? extends ProjectProblemsProvider.ProjectProblem> problems = mpp.getProblems(); waitForReports(); assertFalse(problems.isEmpty()); assertEquals(Collections.singleton(a2f(new DefaultArtifact("g", "par", "0", null, "pom", null, new DefaultArtifactHandler("pom")))), pr.getMissingArtifactFiles()); }
Example #15
Source File: NbMavenProjectImpl.java From netbeans with Apache License 2.0 | 6 votes |
private void check() { //this call effectively calls project.getLookup(), when called in constructor will get back to the project's baselookup only. // but when called from propertyChange() then will call on entire composite lookup, is it a problem? #230469 NbMavenProject watcher = watcherRef.get(); String newPackaging = packaging != null ? packaging : NbMavenProject.TYPE_JAR; if (watcher != null) { newPackaging = watcher.getPackagingType(); if (newPackaging == null) { newPackaging = NbMavenProject.TYPE_JAR; } } if (!newPackaging.equals(packaging)) { packaging = newPackaging; Lookup pack = Lookups.forPath("Projects/org-netbeans-modules-maven/" + packaging + "/Lookup"); setLookups(general, pack); } }
Example #16
Source File: ApplVisualPanel1.java From nb-springboot with Apache License 2.0 | 6 votes |
void read(WizardDescriptor wd) { boolean isTest = false; final String location = (String) wd.getProperty(ApplWizardIterator.WIZ_LOCATION); if (location != null) { isTest = location.equals("test"); } final Project project = Templates.getProject(wd); if (project != null) { nbProj = project.getLookup().lookup(NbMavenProject.class); // this will in turn update the resourceFolder field cbLocation.setSelectedIndex(isTest ? 1 : 0); } String baseName = (String) wd.getProperty(ApplWizardIterator.WIZ_BASE_NAME); if (baseName == null) { baseName = "application"; } this.txBaseName.setText(baseName); this.txBaseName.selectAll(); this.txProfile.setText((String) wd.getProperty(ApplWizardIterator.WIZ_PROFILE)); }
Example #17
Source File: Selenium2MavenSupportImpl.java From netbeans with Apache License 2.0 | 6 votes |
private FileObject getTestRoot(Project project) { NbMavenProject nbProject = project.getLookup().lookup(NbMavenProject.class); MavenProject mvp = nbProject.getMavenProject(); @SuppressWarnings("unchecked") List<String> testRoots = mvp.getTestCompileSourceRoots(); if (testRoots.isEmpty()) { return null; } File testRoot = new File(testRoots.get(0)); FileObject result = null; try { result = FileUtil.createFolder(testRoot); } catch (IOException ex) { Logger.getLogger(Selenium2MavenSupportImpl.class.getName()).log(Level.SEVERE, "Impossible to create test root file object", ex); //NOI18N } return result; }
Example #18
Source File: TransientRepositoriesTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testSimpleRegistration() throws Exception { FileObject d = FileUtil.toFileObject(getWorkDir()); TestFileUtils.writeFile(d, "pom.xml", "<project xmlns='http://maven.apache.org/POM/4.0.0'>\n" + " <modelVersion>4.0.0</modelVersion>\n" + " <groupId>grp</groupId>\n" + " <artifactId>art</artifactId>\n" + " <version>1.0</version>\n" + " <repositories>\n" + " <repository>\n" + " <id>stuff</id>\n" + " <name>Stuff</name>\n" + " <url>http://nowhere.net/stuff</url>\n" + " </repository>\n" + " </repositories>\n" + "</project>\n"); NbMavenProject p = ProjectManager.getDefault().findProject(d).getLookup().lookup(NbMavenProject.class); TransientRepositories tr = new TransientRepositories(p); assertRepos(CENTRAL_ANON); tr.register(); assertRepos("stuff:Stuff:http://nowhere.net/stuff/", CENTRAL_NAMED); tr.unregister(); assertRepos(CENTRAL_ANON); }
Example #19
Source File: MavenSourcesImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({ "SG_Sources=Source Packages", "SG_Test_Sources=Test Packages" }) private void checkChanges(boolean fireChanges, boolean checkAlsoNonJavaStuff) { boolean changed = false; synchronized (lock) { NbMavenProjectImpl project = project(); MavenProject mp = project.getOriginalMavenProject(); NbMavenProject watcher = project.getProjectWatcher(); File folder = FileUtilities.convertStringToFile(mp.getBuild().getSourceDirectory()); changed = changed | checkSourceGroupCache(folder, NAME_SOURCE, SG_Sources(), javaGroup, watcher); folder = FileUtilities.convertStringToFile(mp.getBuild().getTestSourceDirectory()); changed = changed | checkSourceGroupCache(folder, NAME_TESTSOURCE, SG_Test_Sources(), javaGroup, watcher); changed = changed | checkGeneratedGroupsCache(); if (checkAlsoNonJavaStuff) { changed = changed | checkOtherGroupsCache(project.getOtherRoots(false), false); changed = changed | checkOtherGroupsCache(project.getOtherRoots(true), true); } } if (changed) { if (fireChanges) { cs.fireChange(); } } }
Example #20
Source File: JavaPlatformProblemProvider.java From netbeans with Apache License 2.0 | 6 votes |
public JavaPlatformProblemProvider(Project project) { support = new ProjectProblemsProviderSupport(this); this.project = project; this.pchListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) { support.fireProblemsChange(); //always fire or first calculate and then fire? } } }; this.pchJavaPlatformListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { support.fireProblemsChange(); } }; }
Example #21
Source File: CPExtender.java From netbeans with Apache License 2.0 | 6 votes |
private boolean addRemoveLibraries(final Library[] libraries, SourceGroup grp, String type, final boolean add) throws IOException { final AtomicBoolean modified = new AtomicBoolean(); final String scope = findScope(grp, type); ModelOperation<POMModel> operation = new ModelOperation<POMModel>() { public @Override void performOperation(POMModel model) { for (Library library : libraries) { try { modified.compareAndSet(false, addRemoveLibrary(library, model, scope, add)); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } } }; FileObject pom = project.getProjectDirectory().getFileObject(POM_XML);//NOI18N org.netbeans.modules.maven.model.Utilities.performPOMModelOperations(pom, Collections.singletonList(operation)); //TODO is the manual reload necessary if pom.xml file is being saved? // NbMavenProject.fireMavenProjectReload(project); if (modified.get()) { project.getLookup().lookup(NbMavenProject.class).triggerDependencyDownload(); } return modified.get(); }
Example #22
Source File: CPExtenderTest.java From netbeans with Apache License 2.0 | 6 votes |
@RandomlyFails // frequently fails in NB-Core-Build; [CPExtender] checkLibraryForPoms on Library[Stuff] -> true and [Utilities] WORKDIR/o.n.m.m.c.C/testAddRemovePomLib/pom.xml@1:2: CHILD_REMOVED:org.netbeans.modules.maven.model.pom.impl.ProjectImpl$PList@4 yet [Utilities] no changes in org.openide.loaders.XMLDataObject@c[WORKDIR/o.n.m.m.c.C/testAddRemovePomLib/pom.xml@1:2] where modified=true public void testAddRemovePomLib() throws Exception { Library lib = LibraryManager.getDefault().createLibrary("j2se", "Stuff", Collections.singletonMap("maven-pom", Collections.singletonList(new URL("http://repo1.maven.org/maven2/grp/stuff/1.0/stuff-1.0.pom")))); Library lib2 = LibraryManager.getDefault().createLibrary("j2se", "Stuff2", Collections.singletonMap("maven-pom", Collections.singletonList(new URL("http://repo1.maven.org/maven2/grp/stuff/2.0/stuff-2.0.pom")))); FileObject d = FileUtil.toFileObject(getWorkDir()); TestFileUtils.writeFile(d, "pom.xml", "<project><modelVersion>4.0.0</modelVersion>" + "<groupId>test</groupId><artifactId>prj</artifactId>" + "<packaging>jar</packaging><version>1.0</version></project>"); FileObject java = TestFileUtils.writeFile(d, "src/main/java/p/C.java", "package p; class C {}"); Project p = ProjectManager.getDefault().findProject(d); NbMavenProject mp = p.getLookup().lookup(NbMavenProject.class); assertEquals("[]", mp.getMavenProject().getDependencies().toString()); assertTrue(ProjectClassPathModifier.addLibraries(new Library[] {lib}, java, ClassPath.COMPILE)); assertFalse(ProjectClassPathModifier.addLibraries(new Library[] {lib}, java, ClassPath.COMPILE)); NbMavenProject.fireMavenProjectReload(p); // XXX why is this necessary? assertEquals("[Dependency {groupId=grp, artifactId=stuff, version=1.0, type=jar}]", mp.getMavenProject().getDependencies().toString()); assertFalse(ProjectClassPathModifier.removeLibraries(new Library[] {lib2}, java, ClassPath.COMPILE)); assertTrue(ProjectClassPathModifier.removeLibraries(new Library[] {lib}, java, ClassPath.COMPILE)); assertFalse(ProjectClassPathModifier.removeLibraries(new Library[] {lib}, java, ClassPath.COMPILE)); NbMavenProject.fireMavenProjectReload(p); assertEquals("[]", mp.getMavenProject().getDependencies().toString()); }
Example #23
Source File: POMManager.java From netbeans with Apache License 2.0 | 6 votes |
public static void reload(Project project) { NbMavenProject mavenProject = project.getLookup().lookup(NbMavenProject.class); try { FileObject pomFileObject = toFileObject(mavenProject.getMavenProject().getFile()); POMModel model = POMModelFactory.getDefault().getModel(Utilities.createModelSource(pomFileObject)); Utilities.saveChanges(model); } catch (IOException ex) { Exceptions.printStackTrace(ex); } RP.post(() -> { mavenProject.triggerDependencyDownload(); }); SwingUtilities.invokeLater(() -> NbMavenProject.fireMavenProjectReload(project)); }
Example #24
Source File: DependencyGraphTopComponent.java From netbeans with Apache License 2.0 | 6 votes |
/** * @return map of maven artifact mapped to project icon */ private Map<Artifact, Icon> getIconsForOpenProjects() { Map<Artifact, Icon> result = new HashMap<Artifact, Icon>(); //NOTE: surely not the best way to get the project icon Project[] openProjects = OpenProjects.getDefault().getOpenProjects(); for (Project project : openProjects) { NbMavenProject mavenProject = project.getLookup().lookup(NbMavenProject.class); if (null != mavenProject) { Artifact artifact = mavenProject.getMavenProject().getArtifact(); //get icon from opened project Icon icon = ProjectUtils.getInformation(project).getIcon(); if (null != icon) { result.put(artifact, icon); } } } return result; }
Example #25
Source File: AuxPropsImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) { enabledSet.compareAndSet(true, false); synchronized (this) { recheck = true; } } }
Example #26
Source File: MavenProjectSupport.java From netbeans with Apache License 2.0 | 5 votes |
private static String readSettingsFromPom(Project project, final String key) { final NbMavenProject nbMavenProject = project.getLookup().lookup(NbMavenProject.class); if (nbMavenProject != null) { MavenProject mavenProject = nbMavenProject.getMavenProject(); java.util.Properties properties = mavenProject.getProperties(); if (properties != null) { return properties.getProperty(key); } } return null; }
Example #27
Source File: EarModuleProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public FileObject[] getSourceRoots() { ProjectSourcesClassPathProvider cppImpl = project.getLookup().lookup(ProjectSourcesClassPathProvider.class); ClassPath cp = cppImpl.getProjectSourcesClassPath(ClassPath.SOURCE); NbMavenProject prj = project.getLookup().lookup(NbMavenProject.class); List<URL> resUris = new ArrayList<URL>(); for (URI uri : prj.getResources(false)) { try { resUris.add(uri.toURL()); } catch (MalformedURLException ex) { // Exceptions.printStackTrace(ex); } } Iterator<ClassPath.Entry> en = cp.entries().listIterator(); List<FileObject> toRet = new ArrayList<FileObject>(); int index = 0; while (en.hasNext()) { ClassPath.Entry ent = en.next(); if (ent.getRoot() == null) continue; if (resUris.contains(ent.getURL())) { //put resources up front.. toRet.add(index, ent.getRoot()); index = index + 1; } else { toRet.add(ent.getRoot()); } } return toRet.toArray(new FileObject[0]); }
Example #28
Source File: ArtifactMultiViewFactory.java From netbeans with Apache License 2.0 | 5 votes |
@Override @CheckForNull public Lookup createLookup(@NonNull Project prj) { NbMavenProject mvPrj = prj.getLookup().lookup(NbMavenProject.class); MavenProject mvn = mvPrj.getMavenProject(); Artifact artifact = mvn.getArtifact(); //artifact null with unloadable projects?? return artifact != null ? createPomEditorLookup(prj, artifact) : null; }
Example #29
Source File: ServiceRegistrations.java From netbeans with Apache License 2.0 | 5 votes |
@ProjectServiceProvider( service = PersistenceProviderSupplier.class, projectType = { "org-netbeans-modules-maven/" + NbMavenProject.TYPE_WAR, "org-netbeans-modules-maven/" + NbMavenProject.TYPE_EJB, "org-netbeans-modules-maven/" + NbMavenProject.TYPE_APPCLIENT } ) public static PersistenceProviderSupplier createPersistenceProviderSupplier(Project project) { return new PersistenceProviderSupplierImpl(project); }
Example #30
Source File: RecommendedTemplatesImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public String[] getRecommendedTypes() { String packaging = project.getLookup().lookup(NbMavenProject.class).getPackagingType(); if (packaging == null) { packaging = NbMavenProject.TYPE_JAR; } packaging = packaging.trim(); if (NbMavenProject.TYPE_POM.equals(packaging)) { if (ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA).length > 0) { return JAR_APPLICATION_TYPES.clone(); // #192735 // #192735 } return POM_APPLICATION_TYPES.clone(); } if (NbMavenProject.TYPE_JAR.equals(packaging)) { return JAR_APPLICATION_TYPES.clone(); } if (NbMavenProject.TYPE_WAR.equals(packaging)) { return GENERIC_WEB_TYPES.clone(); } if (NbMavenProject.TYPE_EJB.equals(packaging)) { return GENERIC_EJB_TYPES.clone(); } if (NbMavenProject.TYPE_EAR.equals(packaging)) { return GENERIC_EAR_TYPES.clone(); } if (prohibited.contains(packaging)) { return new String[0]; } // If packaging is unknown, any type of sources is recommanded. //TODO in future we probably can try to guess based on what plugins are // defined in the lifecycle. // If packaging is unknown, any type of sources is recommanded. //TODO in future we probably can try to guess based on what plugins are // defined in the lifecycle. return ALL_TYPES.clone(); }