org.apache.maven.artifact.resolver.ArtifactNotFoundException Java Examples
The following examples show how to use
org.apache.maven.artifact.resolver.ArtifactNotFoundException.
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: SCoveragePreCompileMojo.java From scoverage-maven-plugin with Apache License 2.0 | 6 votes |
private Artifact getScalaScoverageRuntimeArtifact( String scalaMainVersion ) throws ArtifactNotFoundException, ArtifactResolutionException { Artifact result = null; String resolvedScalacRuntimeVersion = scalacPluginVersion; if ( resolvedScalacRuntimeVersion == null || "".equals( resolvedScalacRuntimeVersion ) ) { for ( Artifact artifact : pluginArtifacts ) { if ( "org.scoverage".equals( artifact.getGroupId() ) && "scalac-scoverage-plugin_2.12".equals( artifact.getArtifactId() ) ) { resolvedScalacRuntimeVersion = artifact.getVersion(); break; } } } result = getResolvedArtifact( "org.scoverage", "scalac-scoverage-runtime_" + scalaMainVersion, resolvedScalacRuntimeVersion ); return result; }
Example #2
Source File: BasicPanelVisual.java From netbeans with Apache License 2.0 | 6 votes |
@Messages("Handle_Download=Downloading Archetype") private Artifact downloadArchetype(Archetype arch) throws ArtifactResolutionException, ArtifactNotFoundException { AggregateProgressHandle hndl = AggregateProgressFactory.createHandle(Handle_Download(), new ProgressContributor[] { AggregateProgressFactory.createProgressContributor("zaloha") }, //NOI18N ProgressTransferListener.cancellable(), null); synchronized (HANDLE_LOCK) { handle = hndl; } try { arch.resolveArtifacts(hndl); } finally { synchronized (HANDLE_LOCK) {//prevent store()/read() methods to call finish - issue 236251 if (hndl == handle) { handle = null; } } } //#154913 RepositoryIndexer.updateIndexWithArtifacts(RepositoryPreferences.getInstance().getLocalRepository(), Collections.singletonList(arch.getArtifact())); return arch.getArtifact(); }
Example #3
Source File: AbstractTomEEMojo.java From tomee with Apache License 2.0 | 6 votes |
private FileWithMavenMeta mvnToFile(final String lib, final String defaultType) throws ArtifactResolutionException, ArtifactNotFoundException { final String[] infos = lib.split(":"); final String classifier; final String type; if (infos.length < 3) { throw new TomEEException("format for librairies should be <groupId>:<artifactId>:<version>[:<type>[:<classifier>]]"); } if (infos.length >= 4) { type = infos[3]; } else { type = defaultType; } if (infos.length == 5) { classifier = infos[4]; } else { classifier = null; } return resolve(infos[0], infos[1], infos[2], classifier, type); }
Example #4
Source File: AbstractManagementMojo.java From portals-pluto with Apache License 2.0 | 6 votes |
private Map<String, File> getPortletApplications() throws ArtifactNotFoundException, ArtifactResolutionException { Map<String, File> files = new HashMap<String, File>(); InstallationDependency dep = InstallationDependency.TESTSUITE; Artifact artifact = artifactFactory.createBuildArtifact( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getType() ); artifactResolver.resolve(artifact, remoteRepositories, artifactRepository); files.put("testsuite", artifact.getFile()); /* Iterator apps = portletApps.iterator(); while(apps.hasNext()) { //files.add(artifactFactory.createBuildArtifact( // InstallMojo.GROUP_ID, apps.next().toString(), version, "war" //).getFile()); } */ return files; }
Example #5
Source File: AbstractManagementMojo.java From portals-pluto with Apache License 2.0 | 6 votes |
private List<File> getDependencies(Collection<InstallationDependency> artifacts) throws ArtifactNotFoundException, ArtifactResolutionException { List<File> list = new ArrayList<File>(); Iterator<InstallationDependency> it = artifacts.iterator(); while(it.hasNext()) { InstallationDependency dep = it.next(); Artifact artifact = artifactFactory.createArtifactWithClassifier( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getType(), null ); artifactResolver.resolve(artifact, remoteRepositories, artifactRepository); if(artifact.getFile() == null) { getLog().warn("Unable to find file for artifact: "+artifact.getArtifactId()); } list.add(artifact.getFile()); } return list; }
Example #6
Source File: ArtifactUtils.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 6 votes |
public static Collection<Artifact> resolve( final ArtifactFactory artifactFactory, final ArtifactResolver artifactResolver, final ArtifactRepository localRepository, final ArtifactMetadataSource artifactMetadataSource, final Dependency[] dependencies, final MavenProject project) throws InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException { if (dependencies == null) { return Collections.emptyList(); } @SuppressWarnings("unchecked") final Set<Artifact> artifacts = MavenMetadataSource.createArtifacts( artifactFactory, Arrays.asList(dependencies), "runtime", null, project); for (Artifact artifact : artifacts) { artifactResolver.resolve(artifact, project.getRemoteArtifactRepositories(), localRepository); } final Set<Artifact> resolvedArtifacts = artifacts; return resolvedArtifacts; }
Example #7
Source File: RawXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 6 votes |
protected void resolveEpisodeArtifacts() throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException { this.episodeArtifacts = new LinkedHashSet<Artifact>(); { final Collection<Artifact> episodeArtifacts = ArtifactUtils.resolve(getArtifactFactory(), getArtifactResolver(), getLocalRepository(), getArtifactMetadataSource(), getEpisodes(), getProject()); this.episodeArtifacts.addAll(episodeArtifacts); } { if (getUseDependenciesAsEpisodes()) { @SuppressWarnings("unchecked") final Collection<Artifact> projectArtifacts = getProject().getArtifacts(); final AndArtifactFilter filter = new AndArtifactFilter(); filter.add(new ScopeArtifactFilter(DefaultArtifact.SCOPE_COMPILE)); filter.add(new TypeArtifactFilter("jar")); for (Artifact artifact : projectArtifacts) { if (filter.include(artifact)) { this.episodeArtifacts.add(artifact); } } } } this.episodeFiles = ArtifactUtils.getFiles(this.episodeArtifacts); }
Example #8
Source File: ArtifactUtils.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
public static Collection<Artifact> resolveTransitively( final ArtifactFactory artifactFactory, final ArtifactResolver artifactResolver, final ArtifactRepository localRepository, final ArtifactMetadataSource artifactMetadataSource, final Dependency[] dependencies, final MavenProject project) throws InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException { if (dependencies == null) { return Collections.emptyList(); } @SuppressWarnings("unchecked") final Set<Artifact> artifacts = MavenMetadataSource.createArtifacts( artifactFactory, Arrays.asList(dependencies), "runtime", null, project); final ArtifactResolutionResult artifactResolutionResult = artifactResolver .resolveTransitively(artifacts, project.getArtifact(), project.getRemoteArtifactRepositories(), localRepository, artifactMetadataSource); @SuppressWarnings("unchecked") final Set<Artifact> resolvedArtifacts = artifactResolutionResult .getArtifacts(); return resolvedArtifacts; }
Example #9
Source File: SCoveragePreCompileMojo.java From scoverage-maven-plugin with Apache License 2.0 | 5 votes |
private Artifact getResolvedArtifact( String groupId, String artifactId, String version ) throws ArtifactNotFoundException, ArtifactResolutionException { Artifact artifact = factory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, "jar" ); resolver.resolve( artifact, remoteRepos, localRepo ); return artifact; }
Example #10
Source File: SCoveragePreCompileMojo.java From scoverage-maven-plugin with Apache License 2.0 | 5 votes |
private Artifact getScalaScoveragePluginArtifact( String scalaMainVersion ) throws ArtifactNotFoundException, ArtifactResolutionException { Artifact result = null; String resolvedScalacPluginVersion = scalacPluginVersion; if ( resolvedScalacPluginVersion == null || "".equals( resolvedScalacPluginVersion ) ) { for ( Artifact artifact : pluginArtifacts ) { if ( "org.scoverage".equals( artifact.getGroupId() ) && "scalac-scoverage-plugin_2.12".equals( artifact.getArtifactId() ) ) { if ( "2.12".equals( scalaMainVersion ) ) { return artifact; // shortcut, use the same artifact plugin uses } resolvedScalacPluginVersion = artifact.getVersion(); break; } } } result = getResolvedArtifact( "org.scoverage", "scalac-scoverage-plugin_" + scalaMainVersion, resolvedScalacPluginVersion ); return result; }
Example #11
Source File: AbstractManagementMojo.java From portals-pluto with Apache License 2.0 | 5 votes |
private File getPortalApplication() throws ArtifactNotFoundException, ArtifactResolutionException { InstallationDependency dep = InstallationDependency.PORTAL; Artifact artifact = artifactFactory.createBuildArtifact( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getType() ); artifactResolver.resolve(artifact, remoteRepositories, artifactRepository); return artifact.getFile(); }
Example #12
Source File: AbstractManagementMojo.java From portals-pluto with Apache License 2.0 | 5 votes |
protected InstallationConfig createInstallationConfig() throws ArtifactNotFoundException, ArtifactResolutionException { InstallationConfig config = new InstallationConfig(); config.setInstallationDirectory(installationDirectory); config.setPortalContextPath(portalContext); config.setPortalApplication(getPortalApplication()); config.setPortletApplications(getPortletApplications()); config.setEndorsedDependencies(getEndorsedDependencies()); config.setSharedDependencies(getSharedDependencies()); config.setServerConfig(getServerConfig()); return config; }
Example #13
Source File: RawXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
protected void resolveXJCPluginArtifacts() throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException { this.xjcPluginArtifacts = ArtifactUtils.resolveTransitively(getArtifactFactory(), getArtifactResolver(), getLocalRepository(), getArtifactMetadataSource(), getPlugins(), getProject()); this.xjcPluginFiles = ArtifactUtils.getFiles(this.xjcPluginArtifacts); this.xjcPluginURLs = CollectionUtils.apply(this.xjcPluginFiles, IOUtils.GET_URL); }
Example #14
Source File: RawXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
protected void resolveArtifacts() throws MojoExecutionException { try { resolveXJCPluginArtifacts(); resolveEpisodeArtifacts(); } catch (ArtifactResolutionException arex) { throw new MojoExecutionException("Could not resolve the artifact.", arex); } catch (ArtifactNotFoundException anfex) { throw new MojoExecutionException("Artifact not found.", anfex); } catch (InvalidDependencyVersionException idvex) { throw new MojoExecutionException("Invalid dependency version.", idvex); } }
Example #15
Source File: NarMojo.java From nifi-maven with Apache License 2.0 | 5 votes |
protected Artifact getResolvedPomArtifact(Artifact artifact) { Artifact pomArtifact = this.factory.createArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), "", "pom"); // Resolve the pom artifact using repos try { this.resolver.resolve(pomArtifact, this.remoteRepos, this.local); } catch (ArtifactResolutionException | ArtifactNotFoundException e) { getLog().info(e.getMessage()); } return pomArtifact; }
Example #16
Source File: AbstractCheckMojo.java From forbidden-apis with Apache License 2.0 | 5 votes |
private File resolveSignaturesArtifact(SignaturesArtifact signaturesArtifact) throws ArtifactResolutionException, ArtifactNotFoundException { final Artifact artifact = signaturesArtifact.createArtifact(artifactFactory); artifactResolver.resolve(artifact, this.remoteRepositories, this.localRepository); final File f = artifact.getFile(); // Can this ever be false? Be sure. Found the null check also in other Maven code, so be safe! if (f == null) { throw new ArtifactNotFoundException("Artifact does not resolve to a file.", artifact); } return f; }
Example #17
Source File: MavenEmbedder.java From netbeans with Apache License 2.0 | 5 votes |
/** * * @param sources * @param remoteRepositories - these instances need to be properly mirrored and proxied. Either by creating via EmbedderFactory.createRemoteRepository() * or by using instances from MavenProject * @param localRepository * @throws ArtifactResolutionException * @throws ArtifactNotFoundException */ public void resolve(Artifact sources, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException { setUpLegacySupport(); ArtifactResolutionRequest req = new ArtifactResolutionRequest(); req.setLocalRepository(localRepository); req.setRemoteRepositories(remoteRepositories); req.setArtifact(sources); req.setOffline(isOffline()); ArtifactResolutionResult result = repositorySystem.resolve(req); normalizePath(sources); // XXX check result for exceptions and throw them now? for (Exception ex : result.getExceptions()) { LOG.log(Level.FINE, null, ex); } }
Example #18
Source File: Archetype.java From netbeans with Apache License 2.0 | 5 votes |
/** * resolve the artifacts associated with the archetype (ideally downloads them to the local repository) * @param hndl * @throws ArtifactResolutionException * @throws ArtifactNotFoundException */ public void resolveArtifacts(AggregateProgressHandle hndl) throws ArtifactResolutionException, ArtifactNotFoundException { MavenEmbedder online = EmbedderFactory.getOnlineEmbedder(); List<ArtifactRepository> repos; if (getRepository() == null) { repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID)); } else { repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(), "custom-repo"));//NOI18N for (RepositoryInfo info : RepositoryPreferences.getInstance().getRepositoryInfos()) { if (getRepository().equals(info.getRepositoryUrl())) { repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(), info.getId()));//NOI18N break; } } } try { ProgressTransferListener.setAggregateHandle(hndl); hndl.start(); //TODO how to rewrite to track progress? // try { // WagonManager wagon = online.getPlexusContainer().lookup(WagonManager.class); // wagon.setDownloadMonitor(new ProgressTransferListener()); // } catch (ComponentLookupException ex) { // Exceptions.printStackTrace(ex); // } online.resolve(getPomArtifact(), repos, online.getLocalRepository()); online.resolve(getArtifact(), repos, online.getLocalRepository()); } catch (ThreadDeath d) { // download interrupted } catch (IllegalStateException ise) { //download interrupted in dependent thread. #213812 if (!(ise.getCause() instanceof ThreadDeath)) { throw ise; } } finally { ProgressTransferListener.clearAggregateHandle(); hndl.finish(); } }
Example #19
Source File: TarsBuildMojo.java From TarsJava with BSD 3-Clause "New" or "Revised" License | 4 votes |
private ArtifactRepository getArtifactRepository(final String outputDirectory) throws ArtifactNotFoundException, MojoFailureException { return artifactRepositoryFactory.createDeploymentArtifactRepository("tars", "file://" + outputDirectory, getArtifactRepositoryLayout(), false); }
Example #20
Source File: AbstractManagementMojo.java From portals-pluto with Apache License 2.0 | 4 votes |
protected List<File> getSharedDependencies() throws ArtifactNotFoundException, ArtifactResolutionException { return getDependencies(InstallationDependency.getSharedDependencies()); }
Example #21
Source File: AbstractManagementMojo.java From portals-pluto with Apache License 2.0 | 4 votes |
protected List<File> getEndorsedDependencies() throws ArtifactNotFoundException, ArtifactResolutionException { return getDependencies(InstallationDependency.getEndorsedDependencies()); }
Example #22
Source File: DefaultVersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException { List remoteRepositories = usePluginRepositories ? remotePluginRepositories : remoteArtifactRepositories; artifactResolver.resolve( artifact, remoteRepositories, localRepository ); }
Example #23
Source File: AbstractTomEEMojo.java From tomee with Apache License 2.0 | 4 votes |
private FileWithMavenMeta resolve(final String group, final String artifact, final String version, final String classifier, final String type) throws ArtifactResolutionException, ArtifactNotFoundException { final Artifact dependencyArtifact = factory.createDependencyArtifact(group, artifact, createFromVersion(version), type, classifier, SCOPE_COMPILE); resolver.resolve(dependencyArtifact, remoteRepos, local); return new FileWithMavenMeta(group, artifact, version, classifier, type, dependencyArtifact.getFile()); }
Example #24
Source File: MavenModelProblemsProvider.java From netbeans with Apache License 2.0 | 4 votes |
@NbBundle.Messages({ "TXT_Artifact_Resolution_problem=Artifact Resolution problem", "TXT_Artifact_Not_Found=Artifact Not Found", "TXT_Cannot_Load_Project=Unable to properly load project", "TXT_Cannot_read_model=Error reading project model", "TXT_NoMsg=Exception thrown while loading maven project at {0}. See messages.log for more information." }) private Collection<ProjectProblem> reportExceptions(MavenExecutionResult res) { List<ProjectProblem> toRet = new ArrayList<ProjectProblem>(); for (Throwable e : res.getExceptions()) { LOG.log(Level.FINE, "Error on loading project " + project.getProjectDirectory(), e); if (e instanceof ArtifactResolutionException) { // XXX when does this occur? toRet.add(ProjectProblem.createError(TXT_Artifact_Resolution_problem(), getDescriptionText(e))); problemReporter.addMissingArtifact(((ArtifactResolutionException) e).getArtifact()); } else if (e instanceof ArtifactNotFoundException) { // XXX when does this occur? toRet.add(ProjectProblem.createError(TXT_Artifact_Not_Found(), getDescriptionText(e))); problemReporter.addMissingArtifact(((ArtifactNotFoundException) e).getArtifact()); } else if (e instanceof ProjectBuildingException) { toRet.add(ProjectProblem.createError(TXT_Cannot_Load_Project(), getDescriptionText(e), new SanityBuildAction(project))); if (e.getCause() instanceof ModelBuildingException) { ModelBuildingException mbe = (ModelBuildingException) e.getCause(); for (ModelProblem mp : mbe.getProblems()) { LOG.log(Level.FINE, mp.toString(), mp.getException()); if (mp.getException() instanceof UnresolvableModelException) { // Probably obsoleted by ProblemReporterImpl.checkParent, but just in case: UnresolvableModelException ume = (UnresolvableModelException) mp.getException(); problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createProjectArtifact(ume.getGroupId(), ume.getArtifactId(), ume.getVersion())); } else if (mp.getException() instanceof PluginResolutionException) { Plugin plugin = ((PluginResolutionException) mp.getException()).getPlugin(); // XXX this is not actually accurate; should rather pick out the ArtifactResolutionException & ArtifactNotFoundException inside problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createArtifact(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), "jar")); } else if (mp.getException() instanceof PluginManagerException) { PluginManagerException ex = (PluginManagerException) mp.getException(); problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createArtifact(ex.getPluginGroupId(), ex.getPluginArtifactId(), ex.getPluginVersion(), "jar")); } } } } else { String msg = e.getMessage(); if(msg != null) { LOG.log(Level.INFO, "Exception thrown while loading maven project at " + project.getProjectDirectory(), e); //NOI18N toRet.add(ProjectProblem.createError(TXT_Cannot_read_model(), msg)); } else { String path = project.getProjectDirectory().getPath(); toRet.add(ProjectProblem.createError(TXT_Cannot_read_model(), TXT_NoMsg(path))); LOG.log(Level.WARNING, "Exception thrown while loading maven project at " + path, e); //NOI18N } } } return toRet; }
Example #25
Source File: MavenUtil.java From Decca with MIT License | 4 votes |
public void resolve(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException { mojo.resolver.resolve(artifact, mojo.remoteRepositories, mojo.localRepository); }
Example #26
Source File: VersionsHelper.java From versions-maven-plugin with Apache License 2.0 | 2 votes |
/** * Attempts to resolve the artifact. * * @param artifact The artifact to resolve. * @param usePluginRepositories whether to resolve from the plugin repositories or the regular repositories. * @throws ArtifactResolutionException if something goes wrong. * @throws ArtifactNotFoundException if something goes wrong. * @since 1.3 */ void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException;