@Override public void run() { //#211158 after being reset, recreate the instance for followup usage. //makes the performance stats of the project embedder after resetting more predictable getProjectEmbedder(); } });
public static @NonNull MavenEmbedder getOnlineEmbedder() { synchronized (ONLINE_LOCK) { if (online == null) { try { online = createOnlineEmbedder(); } catch (PlexusContainerException ex) { rethrowThreadDeath(ex); throw new IllegalStateException(ex); } } return online; } }
public static @NonNull MavenEmbedder getProjectEmbedder() { synchronized (PROJECT_LOCK) { if (project == null) { try { project = createProjectLikeEmbedder(); } catch (PlexusContainerException ex) { rethrowThreadDeath(ex); throw new IllegalStateException(ex); } projectLoaded.set(true); } return project; } }
static Properties cloneStaticProps() { synchronized (statics) { if (statics.isEmpty()) { // not yet initialized // Now a misnomer, but available to activate profiles only during NB project parse: statics.setProperty("netbeans.execution", "true"); // NOI18N EmbedderFactory.fillEnvVars(statics); statics.putAll(excludeNetBeansProperties(System.getProperties())); } Properties toRet = new Properties(); toRet.putAll(statics); return toRet; } }
protected @Override URLConnection openConnection(URL u) throws IOException { String path = u.getPath(); if (!path.startsWith("/")) { throw new IOException(path); } String stuff = path.substring(1); MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); Artifact a; String[] pieces = stuff.split(":"); if (pieces.length == 4) { a = online.createArtifact(pieces[0], pieces[1], pieces[2], pieces[3]); } else if (pieces.length == 5) { a = online.createArtifactWithClassifier(pieces[0], pieces[1], pieces[2], pieces[3], pieces[4]); } else { throw new IOException(stuff); } try { online.resolve(a, Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID)), online.getLocalRepository()); } catch (Exception x) { throw new IOException(stuff + ": " + x, x); } File f = a.getFile(); if (!f.isFile()) { throw new IOException("failed to download " + stuff); } Logger.getLogger(MavenProtocolHandler.class.getName()).log(Level.FINE, "resolved {0} -> {1}", new Object[] {stuff, f}); return Utilities.toURI(f).toURL().openConnection(); }
public static MavenEmbedder createProjectLikeEmbedder() { Configuration req = new DefaultConfiguration(); req.setClassLoader(EmbedderFactory.class.getClassLoader()); setLocalRepoPreference(req); Properties props = copySystemProperties(); req.setSystemProperties(fillEnvVars(props)); File userSettingsPath = MavenEmbedder.DEFAULT_USER_SETTINGS_FILE; File globalSettingsPath = InstalledFileLocator.getDefault().locate("maven2/settings.xml", null, false); //NOI18N
public static @NonNull MavenEmbedder createProjectLikeEmbedder() throws PlexusContainerException { final String mavenCoreRealmId = "plexus.core"; ContainerConfiguration dpcreq = new DefaultContainerConfiguration() .setClassWorld( new ClassWorld(mavenCoreRealmId, EmbedderFactory.class.getClassLoader()) ) .setName("maven"); DefaultPlexusContainer pc = new DefaultPlexusContainer(dpcreq, new ExtensionModule()); pc.setLoggerManager(new NbLoggerManager()); Properties userprops = new Properties(); userprops.putAll(getCustomGlobalUserProperties()); EmbedderConfiguration configuration = new EmbedderConfiguration(pc, cloneStaticProps(), userprops, true, getSettingsXml()); try { return new MavenEmbedder(configuration); //MEVENIDE-634 make all instances non-interactive // WagonManager wagonManager = (WagonManager) embedder.getPlexusContainer().lookup(WagonManager.ROLE); // wagonManager.setInteractive(false); } catch (ComponentLookupException ex) { throw new PlexusContainerException(ex.toString(), ex); } }
public synchronized static MavenEmbedder getOnlineEmbedder() { return createOnlineEmbedder(); // if (online == null) { // online = createOnlineEmbedder(); // } // return online; }
public synchronized static MavenEmbedder getProjectEmbedder() /*throws MavenEmbedderException*/ { MavenEmbedder projectEmbedder; //since yarda's introduction of lazy project loading, mutliple threads use the embedder at startup at once. // that breaks embedder/plexus in many ways.. // introducing ThreadLocal project embedder instance to workaround the problem // if (!wasReset) { projectEmbedder = projectTL.get(); } else { projectEmbedder = project; projectTL.remove(); } if (projectEmbedder == null) { MavenEmbedder embedder = createProjectLikeEmbedder(); if (!wasReset) { projectTL.set(embedder); } else { project = embedder; } projectEmbedder = embedder; } return projectEmbedder; }
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); } }
MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); Artifact art = online.createArtifact(gav[0], gav[1], gav[2], "maven-plugin"); online.resolve(art, Collections.<ArtifactRepository>emptyList(), online.getLocalRepository());
/*public*/ static MavenEmbedder createOnlineEmbedder() { Configuration req = new DefaultConfiguration(); req.setClassLoader(EmbedderFactory.class.getClassLoader()); setLocalRepoPreference(req); Properties props = copySystemProperties(); req.setSystemProperties(fillEnvVars(props));
userprops.putAll(getCustomGlobalUserProperties()); EmbedderConfiguration req = new EmbedderConfiguration(pc, cloneStaticProps(), userprops, false, getSettingsXml());
final MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); online.setUpLegacySupport();
ArtifactDependencyIndexCreator() { super(ArtifactDependencyIndexCreator.class.getName(), Arrays.asList(MinimalArtifactInfoIndexCreator.ID)); embedder = EmbedderFactory.getProjectEmbedder(); remoteRepos = RepositoryPreferences.getInstance().remoteRepositories(embedder); }
MavenEmbedder embedder2 = EmbedderFactory.getOnlineEmbedder(); DefaultMirrorSelector selectorWithGroups = new DefaultMirrorSelector(); DefaultMirrorSelector selectorWithoutGroups = new DefaultMirrorSelector();
@Messages({ "DownloadAction_sources_label=Download Sources", "DownloadAction_javadoc_label=Download Javadoc" }) DownloadAction(Artifact primaryArt, boolean javadoc) { super(javadoc ? DownloadAction_javadoc_label() : DownloadAction_sources_label()); art = EmbedderFactory.getProjectEmbedder().createArtifactWithClassifier(primaryArt.getGroupId(), primaryArt.getArtifactId(), primaryArt.getVersion(), "jar", javadoc ? "javadoc" : "sources"); primary = false; setEnabled((javadoc ? hasJavadoc : hasSources) && info.isRemoteDownloadable() && !FileUtilities.convertArtifactToLocalRepositoryFile(art).isFile()); } @Messages({"# {0} - artifact ID", "DownloadAction_downloading=Downloading {0}"})
/** * Tries to download an artifact. * @param info a version of an artifact * @return the file in the local repository (might not exist if download failed) * @throws AbstractArtifactResolutionException currently never? * @since 1.17 */ public static File downloadArtifact(NBVersionInfo info) throws Exception { Artifact a = createArtifact(info); MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); List<ArtifactRepository> remotes; RepositoryInfo repo = RepositoryPreferences.getInstance().getRepositoryInfoById(info.getRepoId()); if (repo != null && repo.isRemoteDownloadable()) { remotes = Collections.singletonList(online.createRemoteRepository(repo.getRepositoryUrl(), repo.getId())); } else { remotes = Collections.singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID)); } online.resolve(a, remotes, online.getLocalRepository()); return a.getFile(); }
@Override public File getLocation() { if (location != null) { return location; } MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder(); Artifact art = embedder.createProjectArtifact(groupId, artifactId, version); File file = new File(embedder.getLocalRepositoryFile(), embedder.getLocalRepository().pathOf(art)); location = FileUtil.normalizeFile(file); return location; }
@Override public void run() { MavenEmbedder embedder = EmbedderFactory.getOnlineEmbedder(); AggregateProgressHandle hndl = AggregateProgressFactory.createHandle(Progress_Download(), new ProgressContributor[] {