org.apache.maven.model.Repository类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.apache.maven.model.Repository类的一些代码示例,展示了Repository类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository类的具体详情如下:
包路径:org.apache.maven.model.Repository
类名称:Repository

Repository介绍

[英]A repository contains the information needed for establishing connections with remote repository.
[中]存储库包含与远程存储库建立连接所需的信息。

代码示例

代码示例来源:origin: apache/maven

public static RemoteRepository toRemoteRepository( Repository repository )
{
  RemoteRepository.Builder builder =
    new RemoteRepository.Builder( repository.getId(), repository.getLayout(), repository.getUrl() );
  builder.setSnapshotPolicy( toRepositoryPolicy( repository.getSnapshots() ) );
  builder.setReleasePolicy( toRepositoryPolicy( repository.getReleases() ) );
  return builder.build();
}

代码示例来源:origin: apache/maven

public static org.apache.maven.model.Repository fromSettingsRepository( org.apache.maven.settings.Repository
                                    settingsRepository )
{
  org.apache.maven.model.Repository modelRepository = new org.apache.maven.model.Repository();
  modelRepository.setId( settingsRepository.getId() );
  modelRepository.setLayout( settingsRepository.getLayout() );
  modelRepository.setName( settingsRepository.getName() );
  modelRepository.setUrl( settingsRepository.getUrl() );
  modelRepository.setReleases( fromSettingsRepositoryPolicy( settingsRepository.getReleases() ) );
  modelRepository.setSnapshots( fromSettingsRepositoryPolicy( settingsRepository.getSnapshots() ) );
  return modelRepository;
}

代码示例来源:origin: org.apache.maven/maven-project

public static Repository cloneRepository( Repository src )
{
  if ( src == null )
  {
    return null;
  }
  
  Repository result = new Repository();
  
  result.setReleases( cloneRepositoryPolicy( src.getReleases() ) );
  result.setSnapshots( cloneRepositoryPolicy( src.getSnapshots() ) );
  
  cloneRepositoryBaseFields( src, result );
  
  return result;
}

代码示例来源:origin: apache/maven

protected void mergeRepository_Releases( Repository target, Repository source, boolean sourceDominant,
                     Map<Object, Object> context )
{
  RepositoryPolicy src = source.getReleases();
  if ( src != null )
  {
    RepositoryPolicy tgt = target.getReleases();
    if ( tgt == null )
    {
      tgt = new RepositoryPolicy();
      target.setReleases( tgt );
    }
    mergeRepositoryPolicy( tgt, src, sourceDominant, context );
  }
}

代码示例来源:origin: org.apache.maven/maven-project

private void validateRepositories( final ModelValidationResult result, final List repositories, final String prefix )
{
  for ( Iterator it = repositories.iterator(); it.hasNext(); )
  {
    Repository repository = (Repository) it.next();
    validateStringNotEmpty( prefix + ".id", result, repository.getId() );
    validateStringNotEmpty( prefix + ".url", result, repository.getUrl() );
  }
}

代码示例来源:origin: takari/polyglot-maven

public Model toMavenModel() {
 Model model = new Model();
 model.setBuild(new Build());
 model.setDescription(description);
 model.setUrl(url);
 model.setName(projectId.getArtifact());
   Repository repository = new Repository();
   repository.setId(Integer.toString(repoUrl.hashCode()));
   repository.setUrl(repoUrl);
   model.addRepository(repository);

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend

assertThat(original.getPackaging()).isEqualToIgnoringCase("jar");
assertThat(original.getBuild().getPlugins()).hasSize(1);
assertThat(original.getDependencies()).hasSize(3);
assertThat(original.getRepositories()).hasSize(2);
assertThat(original.getPluginRepositories()).hasSize(1);
List<org.apache.maven.model.Repository> repos = original.getRepositories();
for(org.apache.maven.model.Repository repo : repos){
  if(repo.getId().equals("guvnor-m2-repo")){
    assertThat(repo.getUrl()).isEqualToIgnoringCase("http://localhost:8080/business-central/maven2/");
  if(repo.getId().equals("productization-repository")){
    assertThat(repo.getUrl()).isEqualToIgnoringCase("http://download.lab.bos.redhat.com/brewroot/repos/jb-ip-6.1-build/latest/maven/");
List<org.apache.maven.model.Repository> reposUpdated = modelUpdated.getRepositories();
for(org.apache.maven.model.Repository repo : reposUpdated){
  if(repo.getId().equals("guvnor-m2-repo")){
    assertThat(repo.getUrl()).isEqualToIgnoringCase("http://127.0.0.1:8080/business-central/maven3/");
  if(repo.getId().equals("productization-repository")){
    throw new AssertionError("repositories not removed");

代码示例来源:origin: org.codehaus.mevenide/nb-project

return null;
for (Object rr : mdl.getRepositories()) {
  Repository r = (Repository)rr;
  if (url.equals(r.getUrl())) {
  while (it.hasNext()) {
    Repository re = (Repository)it.next();
    if (url.equals(re.getUrl())) {
      prjret = re;
      break;
  reps = mdl.getRepositories();
  if (reps != null) {
    Iterator it = reps.iterator();
    while (it.hasNext()) {
      Repository re = (Repository)it.next();
      if (re.getId().equals(prjret.getId())) {
        ret = re;
        break;
  ret = new Repository();
  ret.setUrl(url);
  ret.setId(url);
  mdl.addRepository(ret);

代码示例来源:origin: org.guvnor/guvnor-project-backend

private Repository fromClientModelToPom(final org.guvnor.common.services.project.model.Repository from) {
  Repository to = new Repository();
  to.setId(from.getId());
  to.setName(from.getName());
  to.setUrl(from.getUrl());
  return to;
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

private MavenRepository fromPomModelToClientModel(final Repository from) {
  MavenRepository to = new MavenRepository();
  to.setId(from.getId());
  to.setName(from.getName());
  to.setUrl(from.getUrl());
  return to;
}

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public List<DependencyRepository> getRepositories()
{
 List<DependencyRepository> results = new ArrayList<>();
 MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
 Model pom = maven.getModel();
 List<Repository> repos = pom.getRepositories();
 for (Repository repo : repos)
 {
   results.add(new DependencyRepository(repo.getId(), repo.getUrl()));
 }
 return Collections.unmodifiableList(results);
}

代码示例来源:origin: takari/polyglot-maven

private void repositories(PrintWriter pw, Model model) {
 List<Repository> repositories = model.getRepositories();
 if (!repositories.isEmpty()) {
  pw.print("repositories << \"");
  for (int i = 0; i < repositories.size(); i++) {
   pw.print(repositories.get(i).getUrl());
   if (i + 1 != repositories.size()) {
    pw.print(",");
   }
  }
  pw.println("\"");
  pw.println();
 }
}

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public List<DependencyRepository> getPluginRepositories()
{
 List<DependencyRepository> results = new ArrayList<>();
 MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
 Model pom = maven.getModel();
 List<Repository> repos = pom.getPluginRepositories();
 if (repos != null)
 {
   for (Repository repo : repos)
   {
    results.add(new DependencyRepository(repo.getId(), repo.getUrl()));
   }
 }
 return Collections.unmodifiableList(results);
}

代码示例来源:origin: opensourceBIM/BIMserver

for (org.apache.maven.model.Dependency dependency : model.getDependencies()) {
  if (dependency.getGroupId().equals("org.opensourcebim") && (dependency.getArtifactId().equals("shared") || dependency.getArtifactId().equals("pluginbase"))) {
        throw new Exception("Required dependency " + pluginBundleIdentifier + " is not installed");
      } else {
        MavenPluginLocation mavenPluginLocation = mavenPluginRepository.getPluginLocation(model.getRepositories().get(0).getUrl(), dependency.getGroupId(), dependency.getArtifactId());

代码示例来源:origin: rickardoberg/neomvn

RepositoryModelResolver( File repository, String mavenRepository )
{
  this.repository = repository;
  this.mavenRepository = mavenRepository;
  Repository mainRepo = new Repository();
  mainRepo.setUrl( mavenRepository );
  mainRepo.setId( "central" );
  repositories.add(mainRepo);
}

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public void addPluginRepository(String id, String url, org.jboss.forge.addon.maven.profiles.Profile profileParam)
{
 if (profileParam == null)
   addPluginRepository(id, url);
 else
 {
   if (!hasPluginRepository(url, profileParam))
   {
    MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
    Model pom = maven.getModel();
    Profile profile = getProfile(pom, profileParam);
    if (profile == null)
    {
      profile = profileParam.getAsMavenProfile();
      pom.getProfiles().add(profile);
    }
    Repository repo = new Repository();
    repo.setId(id);
    repo.setUrl(url);
    profile.addPluginRepository(repo);
    maven.setModel(pom);
   }
 }
}

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public void addRepository(final String name, final String url)
{
 if (!hasRepository(url))
 {
   MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
   Model pom = maven.getModel();
   Repository repo = new Repository();
   repo.setId(name);
   repo.setUrl(url);
   pom.getRepositories().add(repo);
   maven.setModel(pom);
 }
}

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public List<DependencyRepository> getPluginRepositories(org.jboss.forge.addon.maven.profiles.Profile profileParam)
{
 if (profileParam == null)
   return getPluginRepositories();
 else
 {
   List<DependencyRepository> results = new ArrayList<>();
   MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
   Model pom = maven.getModel();
   Profile profile = getProfile(pom, profileParam);
   if (profile != null)
   {
    for (Repository repo : profile.getPluginRepositories())
    {
      results.add(new DependencyRepository(repo.getId(), repo.getUrl()));
    }
   }
   return Collections.unmodifiableList(results);
 }
}

代码示例来源:origin: takari/polyglot-maven

private void writeRepositories() throws IOException {
  if (model.getRepositories() != null && !model.getRepositories().isEmpty()) {			
    out.write("        " + "repositories(" + br);
    for (Repository repository : model.getRepositories()) {
      if (repository.getUrl() != null) {
        out.write("url -> \"" + repository.getUrl() + "\"");
      if (repository.getName() != null) {
        out.write(", name -> \"" + repository.getName() + "\"");
      if (repository.getId() != null) {
        out.write(", id -> \"" + repository.getId() + "\"");

代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects

@Override
public void addPluginRepository(final String id, final String url)
{
 if (!hasPluginRepository(url))
 {
   MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
   Model pom = maven.getModel();
   Repository repo = new Repository();
   repo.setId(id);
   repo.setUrl(url);
   pom.getPluginRepositories().add(repo);
   maven.setModel(pom);
 }
}

相关文章