public void run() { if (current != null) { File file = FileUtil.toFile(current.getPrimaryFile()); // can be null for stuff in jars? if (file != null) { try { ModelLineage lin = EmbedderFactory.createModelLineage(file, EmbedderFactory.createOnlineEmbedder(), false); final Children ch = new PomChildren(lin); SwingUtilities.invokeLater(new Runnable() { public void run() { treeView.setRootVisible(false); explorerManager.setRootContext(new AbstractNode(ch)); } }); } catch (ProjectBuildingException ex) { Logger.getLogger(getClass().getName()).log(Level.FINE, "Error reading model lineage", ex); } } else { SwingUtilities.invokeLater(new Runnable() { public void run() { treeView.setRootVisible(false); explorerManager.setRootContext(new WaitNode()); } }); } } }
@Override protected List getDynamicCompletion(String path, HintContext hintCtx, org.jdom.Element parent) { if (path.endsWith("plugins/plugin/configuration") || //NOI18N path.endsWith("plugins/plugin/executions/execution/configuration")) { //NOI18N // assuming we have the configuration node as parent.. // does not need to be true for complex stuff Node previous = path.indexOf("execution") > 0 //NOI18N ? hintCtx.getParentNode().getParentNode().getParentNode().getPreviousSibling() : hintCtx.getParentNode().getPreviousSibling(); MavenEmbedder embedder = EmbedderFactory.getOnlineEmbedder(); ArtifactInfoHolder info = findPluginInfo(previous, embedder, true); Document pluginDoc = loadDocument(info, embedder); if (pluginDoc != null) { return collectPluginParams(pluginDoc, hintCtx); } } return Collections.EMPTY_LIST; }
public MavenEmbedder getEmbedder() { return EmbedderFactory.getProjectEmbedder(); }
public synchronized static MavenEmbedder getOnlineEmbedder() { if (online == null) { online = createOnlineEmbedder(); } return online; }
private Artifact downloadNGArchetype(Archetype arch) throws ArtifactResolutionException, ArtifactNotFoundException { MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); Artifact art = online.createArtifact( arch.getGroupId(), List repos; if (arch.getRepository() == null) { repos = Collections.singletonList(EmbedderFactory.createRemoteRepository(online, "http://repo1.maven.org/maven2", "central"));//NOI18N } else { repos = Collections.singletonList(EmbedderFactory.createRemoteRepository(online, arch.getRepository(), "custom-repo"));//NOI18N
embedder = EmbedderFactory.createExecuteEmbedder(out); super.buildPlan.setEmbedder(embedder); if (config.getProject() != null) { EmbedderFactory.fillEnvVars(props); props.putAll(excludeNetBeansProperties(System.getProperties())); props.putAll(config.getProperties()); EmbedderFactory.resetProjectEmbedder(); final List<File> fireList = MyLifecycleExecutor.getAffectedProjects(); RequestProcessor.getDefault().post(new Runnable() { //#103460
Properties props = new Properties(); props.putAll(System.getProperties()); req.setSystemProperties(fillEnvVars(props)); File userSettingsPath = MavenEmbedder.DEFAULT_USER_SETTINGS_FILE; File globalSettingsPath = InstalledFileLocator.getDefault().locate("maven2/settings.xml", null, false); //NOI18N
public void actionPerformed(java.awt.event.ActionEvent event) { EmbedderFactory.resetProjectEmbedder(); for (NbMavenProject prj : context.lookupAll(NbMavenProject.class)) { ProjectURLWatcher.fireMavenProjectReload(prj); } }
private static void copyConfig(PlexusConfiguration old, XmlPlexusConfiguration conf) throws PlexusConfigurationException { conf.setValue(old.getValue()); String[] attrNames = old.getAttributeNames(); if (attrNames != null && attrNames.length > 0) { for (int i = 0; i < attrNames.length; i++) { conf.setAttribute(attrNames[i], old.getAttribute(attrNames[i])); } } if ("lifecycle".equals(conf.getName())) { //NOI18N conf.setAttribute("implementation", "org.apache.maven.lifecycle.Lifecycle"); //NOI18N } for (int i = 0; i < old.getChildCount(); i++) { PlexusConfiguration oldChild = old.getChild(i); XmlPlexusConfiguration newChild = new XmlPlexusConfiguration(oldChild.getName()); conf.addChild(newChild); copyConfig(oldChild, newChild); } }
req.setSystemProperties(fillEnvVars(props));
public static MavenProject readMavenProject(String grId, String artId, String ver, ArtifactRepository repository) { MavenProject mavenProject = null; try { // we need to use the online embedder as the project one never // puts anything in the local repository, thus not resolving dependencies. //mkleint: this is somewhat strange thing to do for indexing remote repositories // via the maven-repo-utils CLI tool.. ArtifactFactory artifactFactory = (ArtifactFactory) EmbedderFactory.getOnlineEmbedder().getPlexusContainer().lookup(ArtifactFactory.class); Artifact projectArtifact = artifactFactory.createProjectArtifact( grId, artId, ver, null); MavenProjectBuilder builder = (MavenProjectBuilder) EmbedderFactory.getOnlineEmbedder().getPlexusContainer().lookup(MavenProjectBuilder.class); mavenProject = builder.buildFromRepository(projectArtifact, new ArrayList(), repository); } catch (InvalidProjectModelException ex) { //ignore nexus is falling ??? ex.printStackTrace(); } catch (ProjectBuildingException ex) { ex.printStackTrace(); } catch (Exception exception) { exception.printStackTrace(); } return mavenProject; } }
private static void extractProfilesFromModelLineage(File file, Set<String> profileIds) { try { ModelLineage lineage = EmbedderFactory.createModelLineage(file, EmbedderFactory.createOnlineEmbedder(), true); Iterator it = lineage.modelIterator(); while (it.hasNext()) {
public void run() { GoalsProvider provider = Lookup.getDefault().lookup(GoalsProvider.class); if (provider != null) { final Set<String> strs = provider.getAvailableGoals(); try { List<String> phases = EmbedderFactory.getProjectEmbedder().getLifecyclePhases(); strs.addAll(phases); } catch (Exception e) { // oh wel just ignore.. e.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { public void run() { goalcompleter.setValueList(strs); goalcompleter.setLoading(false); } }); } } });
private static Artifact createArtifact(NBVersionInfo info, String classifier) { Artifact art; if (info.getClassifier() != null || classifier != null) { art = EmbedderFactory.getOnlineEmbedder().createArtifactWithClassifier(info.getGroupId(), info.getArtifactId(), info.getVersion(), info.getType(), classifier == null ? info.getClassifier() : classifier); } else { art = EmbedderFactory.getOnlineEmbedder().createArtifact(info.getGroupId(), info.getArtifactId(), info.getVersion(), null, info.getType()); } ArtifactRepository repo = EmbedderFactory.getOnlineEmbedder().getLocalRepository(); String localPath = repo.pathOf(art); art.setFile(new File(repo.getBasedir(), localPath)); return art; }
public static MavenProject readMavenProject(Artifact artifact) { MavenProject mavenProject = null; String absolutePath = artifact.getFile().getAbsolutePath(); String extension = artifact.getArtifactHandler().getExtension(); String pomPath = absolutePath.substring(0, absolutePath.length() - extension.length()); pomPath += "pom";//NOI18N File file = new File(pomPath); if (file.exists()) { try { mavenProject = EmbedderFactory.getProjectEmbedder(). readProject(file); } catch (InvalidProjectModelException ex) { //ignore nexus is falling ??? } catch (ProjectBuildingException ex) { Exceptions.printStackTrace(ex); } catch (ExtensionScanningException ex) { Exceptions.printStackTrace(ex); } catch (MavenExecutionException ex) { Exceptions.printStackTrace(ex); } } return mavenProject; } }
MavenEmbedder embedder = EmbedderFactory.getOnlineEmbedder(); ArtifactInfoHolder info = findPluginInfo(previous, embedder, true); Document pluginDoc = loadDocument(info, embedder); MavenEmbedder embedder = EmbedderFactory.getOnlineEmbedder(); List phases = embedder.getLifecyclePhases(); return super.createTextValueList((String[])phases.toArray(new String[phases.size()]), virtualTextCtx);
public NexusRepositoryIndexserImpl() { //to prevent MaxClauseCount exception (will investigate better way) BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE); try { PlexusContainer embedder; ContainerConfiguration config = new DefaultContainerConfiguration(); embedder = new DefaultPlexusContainer(config); repository = EmbedderFactory.getProjectEmbedder().getLocalRepository(); indexer = (NexusIndexer) embedder.lookup(NexusIndexer.class); remoteIndexUpdater = (IndexUpdater) embedder.lookup(IndexUpdater.class); contextProducer = (ArtifactContextProducer) embedder.lookup(ArtifactContextProducer.class); } catch (ComponentLookupException ex) { Exceptions.printStackTrace(ex); } catch (PlexusContainerException ex) { Exceptions.printStackTrace(ex); } lookup = Lookups.singleton(this); }
public void run() { MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); AggregateProgressHandle hndl = AggregateProgressFactory.createHandle(NbBundle.getMessage(ProjectURLWatcher.class, "Progress_Download"), new ProgressContributor[] { AggregateProgressFactory.createProgressContributor("zaloha") }, //NOI18N null, null); boolean ok = true; try { ProgressTransferListener.setAggregateHandle(hndl); hndl.start(); MavenExecutionRequest req = new DefaultMavenExecutionRequest(); req.setPom(FileUtil.toFile(project.getProjectDirectory().getFileObject("pom.xml"))); MavenExecutionResult res = online.readProjectWithDependencies(req); //NOI18N if (res.hasExceptions()) { ok = false; Exception ex = (Exception)res.getExceptions().get(0); StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(ProjectURLWatcher.class, "MSG_Failed", ex.getLocalizedMessage())); } } finally { hndl.finish(); ProgressTransferListener.clearAggregateHandle(); } if (ok) { StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(ProjectURLWatcher.class, "MSG_Done")); } ProjectURLWatcher.fireMavenProjectReload(project); } });
private static String checkConfiguration(MavenProject prj, Object conf, String property) { if (conf != null && conf instanceof Xpp3Dom) { Xpp3Dom dom = (Xpp3Dom)conf; Xpp3Dom source = dom.getChild(property); if (source != null) { NBPluginParameterExpressionEvaluator eval = new NBPluginParameterExpressionEvaluator(prj, EmbedderFactory.getProjectEmbedder().getSettings(), new Properties()); try { Object evaluated = eval.evaluate(source.getValue().trim()); return evaluated != null ? ("" + evaluated) : source.getValue().trim(); } catch (ExpressionEvaluationException ex) { Exceptions.printStackTrace(ex); } return source.getValue().trim(); } } return null; }
public void run() { MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); Node[] nds = getChildren().getNodes(); ProgressContributor[] contribs = new ProgressContributor[nds.length];