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


Java FileModelSource类代码示例

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


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

示例1: resolvePomDependencies

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
/**
 * Given a local path to a Maven project, this attempts to find the transitive dependencies of the
 * project.
 *
 * @param projectPath The path to search for Maven projects.
 * @param scopes The scopes to look up dependencies in.
 */
public String resolvePomDependencies(String projectPath, Set<String> scopes) {
  DefaultModelProcessor processor = new DefaultModelProcessor();
  processor.setModelLocator(new DefaultModelLocator());
  processor.setModelReader(new DefaultModelReader());
  File pom = processor.locatePom(new File(projectPath));
  FileModelSource pomSource = new FileModelSource(pom);
  // First resolve the model source locations.
  resolveSourceLocations(pomSource);
  // Next, fully resolve the models.
  Model model = modelResolver.getEffectiveModel(pomSource);
  if (model != null) {
    traverseDeps(model, scopes, Sets.newHashSet(), null);
  }
  return pom.getAbsolutePath();
}
 
开发者ID:bazelbuild,项目名称:migration-tooling,代码行数:23,代码来源:Resolver.java

示例2: resolveModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的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.building.FileModelSource; //导入依赖的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.building.FileModelSource; //导入依赖的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

示例5: resolveModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的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

示例6: resolveModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的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

示例7: resolveSourceLocations

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
/** Find the POM files for a given pom's parent(s) and submodules. */
private void resolveSourceLocations(FileModelSource fileModelSource) {
  Model model = modelResolver.getRawModel(fileModelSource);
  if (model == null) {
    return;
  }

  // Self.
  Parent parent = model.getParent();
  if (model.getGroupId() == null) {
    model.setGroupId(parent.getGroupId());
  }
  if (!modelResolver.putModelSource(model.getGroupId(), model.getArtifactId(), fileModelSource)) {
    return;
  }

  // Parent.
  File pomDirectory = new File(fileModelSource.getLocation()).getParentFile();
  if (parent != null && !parent.getArtifactId().equals(model.getArtifactId())) {
    File parentPom;
    try {
      parentPom = new File(pomDirectory, parent.getRelativePath()).getCanonicalFile();
    } catch (IOException e) {
      logger.warning(
          "Unable to get canonical path of " + pomDirectory + " and " + parent.getRelativePath());
      return;
    }
    if (parentPom.exists()) {
      resolveSourceLocations(new FileModelSource(parentPom));
    }
  }

  // Submodules.
  for (String module : model.getModules()) {
    resolveSourceLocations(new FileModelSource(new File(pomDirectory, module + "/pom.xml")));
  }
}
 
开发者ID:bazelbuild,项目名称:migration-tooling,代码行数:38,代码来源:Resolver.java

示例8: resolveModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public ModelSource resolveModel( String groupId, String artifactId, String version )
{
    File pomFile = reactorModelPool.find(groupId, artifactId, version);
    if ( pomFile == null )
    {
        Artifact pomArtifact = this.artifactFactory.createProjectArtifact( groupId, artifactId, version );
        pomArtifact = this.localRepository.find( pomArtifact );
        pomFile = pomArtifact.getFile();
    }

    return new FileModelSource( pomFile );
}
 
开发者ID:mojohaus,项目名称:flatten-maven-plugin,代码行数:16,代码来源:FlattenModelResolver.java

示例9: resolveModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的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

示例10: buildModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
public ModelBuildingResult buildModel(File pomFile) {
    ModelBuildingResult result = null;

    DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(modelBuildingRequestTemplate);
    request.setPomFile(pomFile);
    request.setModelSource(new FileModelSource(pomFile));
    try {
        result = modelBuilder.build(request);
    } catch (ModelBuildingException e) {
        result = null;
    }
    
    return result;
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:15,代码来源:ValidatorSupport.java

示例11: validate

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
private void validate(ValidatorContext ctx, File pomFile) {
    DefaultModelBuildingRequest request = new DefaultModelBuildingRequest(modelBuildingRequestTemplate);
    request.setPomFile(pomFile);
    request.setModelSource(new FileModelSource(pomFile));
    request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);
    try {
        modelBuilder.build(request);
    } catch (ModelBuildingException e) {
        ctx.addError(this, pomFile, e);
    }
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:12,代码来源:ModelValidator.java

示例12: resolveModel

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version) throws UnresolvableModelException
{
	Artifact artifact = new DefaultArtifact(groupId + ":" + artifactId + ":" + version);
	return new FileModelSource(Maven.getMetadata(system, session, artifact).getFile());
}
 
开发者ID:bnavetta,项目名称:tycho-gen,代码行数:7,代码来源:RepoModelResolver.java

示例13: build

import org.apache.maven.model.building.FileModelSource; //导入依赖的package包/类
public ProjectBuildingResult build( File pomFile, ProjectBuildingRequest request )
    throws ProjectBuildingException
{
    return build( pomFile, new FileModelSource( pomFile ), new InternalConfig( request, null ) );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:6,代码来源:DefaultProjectBuilder.java


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