当前位置: 首页>>代码示例>>Java>>正文


Java UnresolvableModelException类代码示例

本文整理汇总了Java中org.apache.maven.model.resolution.UnresolvableModelException的典型用法代码示例。如果您正苦于以下问题:Java UnresolvableModelException类的具体用法?Java UnresolvableModelException怎么用?Java UnresolvableModelException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnresolvableModelException类属于org.apache.maven.model.resolution包,在下文中一共展示了UnresolvableModelException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveArtifact

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
/** Resolves an artifact as a root of a dependency graph. */
public void resolveArtifact(String artifactCoord) {
  Artifact artifact;
  ModelSource modelSource;
  try {
    artifact = ArtifactBuilder.fromCoords(artifactCoord);
    modelSource = modelResolver.resolveModel(artifact);
  } catch (UnresolvableModelException | InvalidArtifactCoordinateException e) {
    logger.warning(e.getMessage());
    return;
  }

  Rule rule = new Rule(artifact);
  rule.setRepository(modelSource.getLocation());
  rule.setSha1(downloadSha1(rule));
  deps.put(rule.name(), rule); // add the artifact rule to the workspace
  Model model = modelResolver.getEffectiveModel(modelSource);
  if (model != null) {
    traverseDeps(model, Sets.newHashSet(), Sets.newHashSet(), rule);
  }
}
 
开发者ID:bazelbuild,项目名称:migration-tooling,代码行数:22,代码来源:Resolver.java

示例2: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
        throws UnresolvableModelException {
    Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);

    try {
        ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
        pomArtifact = system.resolveArtifact(session, request).getArtifact();
    } catch (org.eclipse.aether.resolution.ArtifactResolutionException ex) {
        throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId, version, ex);
    } 

    File pomFile = pomArtifact.getFile();

    return new FileModelSource(pomFile);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:17,代码来源:SimpleModelResolver.java

示例3: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource2 resolveModel(
    final String groupId, final String artifactId, final String version)
    throws UnresolvableModelException {
  final Config config = Config.load();
  final String localRepository = config.getMavenLocalRepository();
  final String parent = ClassNameUtils.replace(groupId, ".", File.separator);
  final String path =
      Joiner.on(File.separator).join(localRepository, parent, artifactId, version);
  final String file = artifactId + '-' + version + ".pom";
  final File pom = new File(path, file);
  final boolean exists = pom.exists();

  if (!loaded.contains(pom)) {
    loaded.add(pom);
  }
  if (exists) {
    return new FileModelSource(pom);
  }
  return null;
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:22,代码来源:POMParser.java

示例4: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
		throws UnresolvableModelException {
	Map<String, String> dependency = new HashMap<String, String>();
	dependency.put("group", groupId);
	dependency.put("module", artifactId);
	dependency.put("version", version);
	dependency.put("type", "pom");
	try {
		return new UrlModelSource(
				Grape.getInstance().resolve(null, dependency)[0].toURL());
	}
	catch (MalformedURLException e) {
		throw new UnresolvableModelException(e.getMessage(), groupId, artifactId,
				version);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:DependencyManagementBomTransformation.java

示例5: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(Parent parent) throws UnresolvableModelException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Processing parent model {}", parent.getRelativePath());
    }
    Artifact artifact = new DefaultArtifact(parent.getGroupId(),
            parent.getArtifactId(),
            StringUtils.EMPTY,
            POM,
            parent.getVersion());

    VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact, repositories, null);

    try {
        VersionRangeResult versionRangeResult = repositorySystem.resolveVersionRange(repositorySystemSession,
                versionRangeRequest);
        parent.setVersion(versionRangeResult.getHighestVersion().toString());
    } catch (VersionRangeResolutionException e) {
        throw new UnresolvableModelException(e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
                parent.getVersion(), e);

    }

    return resolveModel(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
}
 
开发者ID:sourcegraph,项目名称:srclib-java,代码行数:26,代码来源:MavenProject.java

示例6: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
         throws UnresolvableModelException
{
   Artifact pomArtifact = new DefaultArtifact(groupId, artifactId, "", "pom", version);
   try
   {
      final ArtifactRequest request = new ArtifactRequest(pomArtifact, repositories, null);
      pomArtifact = system.resolveArtifact(session, request).getArtifact();

   }
   catch (ArtifactResolutionException e)
   {
      throw new UnresolvableModelException("Failed to resolve POM for " + groupId + ":" + artifactId + ":"
               + version + " due to " + e.getMessage(), groupId, artifactId, version, e);
   }

   final File pomFile = pomArtifact.getFile();

   return new FileModelSource(pomFile);

}
 
开发者ID:forge,项目名称:furnace,代码行数:23,代码来源:MavenModelResolver.java

示例7: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
public ModelSource resolveModel( String groupId, String artifactId, String version )
    throws UnresolvableModelException
{
    Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );

    try
    {
        ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
        request.setTrace( trace );
        pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
    }
    catch ( ArtifactResolutionException e )
    {
        throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource( pomFile );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:DefaultModelResolver.java

示例8: hasMissingParentPom

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
private ModelProblem hasMissingParentPom( ProjectBuildingException e )
{
    if ( e.getCause() instanceof ModelBuildingException )
    {
        ModelBuildingException mbe = (ModelBuildingException) e.getCause();
        for ( ModelProblem problem : mbe.getProblems() )
        {
            if ( problem.getException() instanceof UnresolvableModelException )
            {
                return problem;
            }
        }

    }
    return null;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:MavenMetadataSource.java

示例9: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version) throws UnresolvableModelException {
    LocalRepository localRepo = repositorySystemSession.getLocalRepository();
    File localRepoDir = localRepo.getBasedir();

    StringBuilder pomPath = new StringBuilder();
    pomPath.append(groupId.replace('.', File.separatorChar));
    pomPath.append(File.separatorChar);
    pomPath.append(artifactId);
    pomPath.append(File.separatorChar);
    pomPath.append(version);
    pomPath.append(File.separatorChar);
    pomPath.append(artifactId);
    pomPath.append('-');
    pomPath.append(version);
    pomPath.append(".pom");

    File pomFile = new File(localRepoDir, pomPath.toString());
    if (pomFile.exists()) {
        return new FileModelSource(pomFile);
    } else {
        throw new UnresolvableModelException("POM does not exist in local repository: " + pomFile, groupId, artifactId, version);
    }
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:25,代码来源:LocalRepositoryModelResolver.java

示例10: runMavenValidation

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
private static void runMavenValidation(final POMModel model, final List<ErrorDescription> err) {
    File pom = model.getModelSource().getLookup().lookup(File.class);
    if (pom == null) {
        return;
    }
    
    List<ModelProblem> problems = runMavenValidationImpl(pom);
    for (ModelProblem problem : problems) {
        if (!problem.getSource().equals(pom.getAbsolutePath())) {
            LOG.log(Level.FINE, "found problem not in {0}: {1}", new Object[] {pom, problem.getSource()});
            continue;
        }
        int line = problem.getLineNumber();
        if (line <= 0) { // probably from a parent POM
            /* probably more irritating than helpful:
            line = 1; // fallback
            Parent parent = model.getProject().getPomParent();
            if (parent != null) {
                Line l = NbEditorUtilities.getLine(model.getBaseDocument(), parent.findPosition(), false);
                if (l != null) {
                    line = l.getLineNumber() + 1;
                }
            }
            */
            continue;
        }
        if (problem.getException() instanceof UnresolvableModelException) {
            // If a <parent> reference cannot be followed because e.g. no projects are opened (so no repos registered), just ignore it.
            continue;
        }
        try {
            err.add(ErrorDescriptionFactory.createErrorDescription(problem.getSeverity() == ModelProblem.Severity.WARNING ? Severity.WARNING : Severity.ERROR, problem.getMessage(), model.getBaseDocument(), line));
        } catch (IndexOutOfBoundsException x) {
            LOG.log(Level.WARNING, "improper line number: {0}", problem);
        }
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:StatusProvider.java

示例11: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
    throws UnresolvableModelException {
  String ruleName = Rule.name(groupId, artifactId);
  if (ruleNameToModelSource.containsKey(ruleName)) {
    return ruleNameToModelSource.get(ruleName);
  }
  for (Repository repository : repositories) {
    UrlModelSource modelSource =
        getModelSource(repository.getUrl(), groupId, artifactId, version);
    if (modelSource != null) {
      return modelSource;
    }
  }

  List<String> attemptedUrls = repositories.stream().map(Repository::getUrl).collect(toList());
  throw new UnresolvableModelException(
      "Could not find any repositories that knew how to "
          + "resolve "
          + groupId
          + ":"
          + artifactId
          + ":"
          + version
          + " (checked "
          + Joiner.on(", ").join(attemptedUrls)
          + ")",
      groupId,
      artifactId,
      version);
}
 
开发者ID:bazelbuild,项目名称:migration-tooling,代码行数:32,代码来源:DefaultModelResolver.java

示例12: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
/**
 * Resolves the POM for the specified parent.
 *
 * @param parent the parent coordinates to resolve, must not be {@code null}
 * @return The source of the requested POM, never {@code null}
 * @since Apache-Maven-3.2.2 (MNG-5639)
 */
public ModelSource resolveModel( Parent parent )
        throws UnresolvableModelException {

    Dependency parentDependency = new Dependency();
    parentDependency.setGroupId(parent.getGroupId());
    parentDependency.setArtifactId(parent.getArtifactId());
    parentDependency.setVersion(parent.getVersion());
    parentDependency.setClassifier("");
    parentDependency.setType("pom");

    Artifact parentArtifact = null;
    try
    {
        Iterable<ArtifactResult> artifactResults = depencencyResolver.resolveDependencies(
                projectBuildingRequest, singleton(parentDependency), null, null );
        Iterator<ArtifactResult> iterator = artifactResults.iterator();
        if (iterator.hasNext()) {
            parentArtifact = iterator.next().getArtifact();
        }
    } catch (DependencyResolverException e) {
        throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
                parent.getVersion(), e );
    }

    return resolveModel( parentArtifact.getGroupId(), parentArtifact.getArtifactId(), parentArtifact.getVersion() );
}
 
开发者ID:mojohaus,项目名称:flatten-maven-plugin,代码行数:34,代码来源:FlattenModelResolver.java

示例13: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
public ModelSource resolveModel( String groupId, String artifactId, String version )
    throws UnresolvableModelException
{
    File pomFile = null;

    if ( modelPool != null )
    {
        pomFile = modelPool.get( groupId, artifactId, version );
    }

    if ( pomFile == null )
    {
        Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );

        try
        {
            ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
            request.setTrace( trace );
            pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
        }
        catch ( ArtifactResolutionException e )
        {
            throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
        }

        pomFile = pomArtifact.getFile();
    }

    return new FileModelSource( pomFile );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:31,代码来源:ProjectModelResolver.java

示例14: reportExceptions

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:MavenModelProblemsProvider.java

示例15: resolveModel

import org.apache.maven.model.resolution.UnresolvableModelException; //导入依赖的package包/类
@Override
public ModelSource resolveModel(Parent parent) throws UnresolvableModelException {
    return resolveModel(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:NBRepositoryModelResolver.java


注:本文中的org.apache.maven.model.resolution.UnresolvableModelException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。