org.gradle.api.Project.getRepositories()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(170)

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

Project.getRepositories介绍

暂无

代码示例

代码示例来源:origin: uber/okbuck

private static void addRepositories(Project project, LinkedHashMap<String, String> repositories) {
  project
    .getRepositories()
    .stream()
    .filter(repository -> repository instanceof MavenArtifactRepository)
    .forEach(
      repository -> {
       MavenArtifactRepository mavenRepository = (MavenArtifactRepository) repository;
       String name = mavenRepository.getName().toLowerCase();
       String url = mavenRepository.getUrl().toString();

       repositories.put(name, url);
      });
 }
}

代码示例来源:origin: uber/okbuck

public void setupBuckBinary() {
 OkBuckExtension okbuckExt = ProjectUtil.getOkBuckExtension(rootProject);
 // Create dependency cache for buck binary if needed
 if (okbuckExt.buckBinary != null) {
  Configuration buckConfig =
    rootProject.getConfigurations().maybeCreate(BUCK_BINARY_CONFIGURATION);
  rootProject
    .getRepositories()
    .maven(mavenArtifactRepository -> mavenArtifactRepository.setUrl(JITPACK_URL));
  rootProject.getDependencies().add(BUCK_BINARY_CONFIGURATION, okbuckExt.buckBinary);
  Set<File> resolvedFiles = buckConfig.getResolvedConfiguration().getFiles();
  Preconditions.checkArgument(resolvedFiles.size() == 1);
  realBuckBinaryPath = resolvedFiles.iterator().next().toPath();
 }
}

代码示例来源:origin: diffplug/spotless

/**
 * Creates a Provisioner for the given repositories.
 *
 * The first time a project is created, there are ~7 seconds of configuration
 * which will go away for all subsequent runs.
 *
 * Every call to resolve will take about 1 second, even when all artifacts are resolved.
 */
private static Supplier<Provisioner> createLazyWithRepositories(Consumer<RepositoryHandler> repoConfig) {
  // Running this takes ~3 seconds the first time it is called. Probably because of classloading.
  return Suppliers.memoize(() -> {
    Project project = ProjectBuilder.builder().build();
    repoConfig.accept(project.getRepositories());
    return (withTransitives, mavenCoords) -> {
      Dependency[] deps = mavenCoords.stream()
          .map(project.getDependencies()::create)
          .toArray(Dependency[]::new);
      Configuration config = project.getConfigurations().detachedConfiguration(deps);
      config.setTransitive(withTransitives);
      config.setDescription(mavenCoords.toString());
      try {
        return config.resolve();
      } catch (ResolveException e) {
        /* Provide Maven coordinates in exception message instead of static string 'detachedConfiguration' */
        throw new ResolveException(config.getDescription(), e);
      }
    };
  });
}

代码示例来源:origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm

public GradleArtifactResolvingHelper(Project project) {
  this.project = project;
  this.project.getRepositories().maven(new Action<MavenArtifactRepository>() {
    @Override
    public void execute(MavenArtifactRepository repo) {
      repo.setName("jboss-public");
      repo.setUrl("http://repository.jboss.org/nexus/content/groups/public/");
    }
  });
}

代码示例来源:origin: MinecraftForge/ForgeGradle

public MavenArtifactRepository addMavenRepo(Project proj, final String name, final String url)
{
  return proj.getRepositories().maven(new Action<MavenArtifactRepository>() {
    @Override
    public void execute(MavenArtifactRepository repo)
    {
      repo.setName(name);
      repo.setUrl(url);
    }
  });
}

代码示例来源:origin: purplejs/purplejs

private void addRepositories()
{
  this.project.getRepositories().jcenter();
}

代码示例来源:origin: MinecraftForge/ForgeGradle

public FlatDirectoryArtifactRepository addFlatRepo(Project proj, final String name, final Object... dirs)
{
  return proj.getRepositories().flatDir(new Action<FlatDirectoryArtifactRepository>() {
    @Override
    public void execute(FlatDirectoryArtifactRepository repo)
    {
      repo.setName(name);
      repo.dirs(dirs);
    }
  });
}

代码示例来源:origin: gradle.plugin.de.acetous/gradle-require-dependency-compliance-plugin

/**
 * Get all repositories of this project and it's subprojects.
 *
 * @return The repositories.
 */
protected Set<RepositoryIdentifier> resolveRepositories() {
  return getProject().getAllprojects().stream() //
      .flatMap(project -> project.getRepositories().stream()) //
      .map(RepositoryIdentifier::new) //
      .filter(this::filterMavenLocal) //
      .collect(Collectors.toSet());
}

代码示例来源:origin: gradle.plugin.com.xenoterracide.gradle/pluginbundle

@Override
  public void apply( Project project ) {
    String uri = System.getenv( ENV );
    log.info( ENV + "={}", uri );
    RepositoryHandler repoHandler = project.getRepositories();
    if ( StringUtils.isNotBlank( uri ) ) {
      repoHandler.maven( repo -> repo.setUrl( URI.create( uri ) ) );
    }
    repoHandler.mavenCentral();
  }
}

代码示例来源:origin: gradle.plugin.com.enonic.gradle/xp-gradle-plugin

public MavenArtifactRepository enonicRepo( final String name )
  {
    return this.project.getRepositories().maven( repo -> repo.setUrl( "https://repo.enonic.com/" + name ) );
  }
}

代码示例来源:origin: gradle.plugin.com.enonic.xp/xp-gradle-plugin

public MavenArtifactRepository enonicRepo( final String name )
  {
    return this.project.getRepositories().maven( repo -> repo.setUrl( "https://repo.enonic.com/" + name ) );
  }
}

代码示例来源:origin: gradle.plugin.com.s390x/gogradle

private void customizeProjectInternalServices(Project project) {
  bindCustomizedService(project.getRepositories(), injector.getInstance(GolangRepositoryHandler.class));
  bindCustomizedService(project.getDependencies(), injector.getInstance(GolangDependencyHandler.class));
}

代码示例来源:origin: com.github.rodm/gradle-teamcity-dsl-plugin

private void configureRepositories(Project project) {
  RepositoryHandler handler = project.getRepositories();
  handler.mavenCentral();
  handler.maven(repository -> repository.setUrl(JETBRAINS_MAVEN_REPOSITORY));
}

代码示例来源:origin: MinecraftForge/ForgeGradle

public void execute(Project proj)
  {
    addMavenRepo(proj, "forge", URL_FORGE_MAVEN);
    proj.getRepositories().mavenCentral();
    addMavenRepo(proj, "minecraft", URL_LIBRARY);
  }
});

代码示例来源:origin: gradle.plugin.de.uni-passau.fim.prog1pa/GradlePlugin

/**
 * Configures the dependencies. Adds a dependency for JUnit using MavenCentral.
 *
 * @param project
 *         the {@link Project} that the {@link Plugin} is applied to
 */
private void configureDependencies(Project project) {
  project.getRepositories().mavenCentral();
  project.getDependencies().add("testCompile", "junit:junit:4.12");
}

代码示例来源:origin: gradle.plugin.com.github.kaklakariada/awsm-credentials-gradle

public void applyForProject(Project project)
{
  project.afterEvaluate(p -> {
    project.getRepositories().all(this::repositoryAdded);
    final PublishingExtension publishingExtension = project.getExtensions().findByType(PublishingExtension.class);
    if (publishingExtension != null)
    {
      publishingExtension.getRepositories().all(this::repositoryAdded);
    }
  });
}

代码示例来源:origin: diffplug/goomph

@Override
protected void applyOnce(Project project) {
  extension = project.getExtensions().create(AsMavenExtension.NAME, AsMavenExtension.class, project);
  project.afterEvaluate(proj -> {
    // reload
    Errors.rethrow().run(extension::run);
    // set maven repo
    project.getRepositories().maven(maven -> {
      maven.setUrl(extension.mavenDir(proj));
    });
  });
}

代码示例来源:origin: typelead/gradle-eta

private void addEtlasMavenRepository() {
  if (isRootProject()) {
    project.allprojects(p -> {
        p.getRepositories().maven
          (repo -> {
            repo.setName("EtlasMaven");
            repo.setUrl(mavenRepository.getDirectory().toURI());
          });
      });
  }
}

代码示例来源:origin: gradle.plugin.org.wildfly.build/wildfly-gradle-tools

private void addDefaultRepositories(String artifactLabel) {
  logger.warn( "Error fetching WildFly component '{}' from configured repositories; check your repository configurations to prevent this problem.\nAttempting to resolve this by enabling additional repositories automatically! Adding: [mavenLocal(), mavenCentral() and {}]", artifactLabel, JBOSS_REPOSITORY );
  final RepositoryHandler repositories = project.getRepositories();
  repositories.mavenLocal();
  repositories.mavenCentral();
  repositories.maven( mavenArtifactRepository -> {
    mavenArtifactRepository.setUrl( JBOSS_REPOSITORY );
  } );
}

代码示例来源:origin: joinfaces/joinfaces

@BeforeEach
void setUp() {
  this.project = ProjectBuilder.builder().build();
  this.project.getRepositories().add(this.project.getRepositories().mavenCentral());
}

相关文章