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

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

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

Project.allprojects介绍

暂无

代码示例

代码示例来源:origin: org.gradle/gradle-core

public void execute(Project project) {
    project.allprojects(action);
  }
});

代码示例来源:origin: gradle.plugin.org.itsallcode/openfasttrace-gradle

@Override
public void apply(Project rootProject)
{
  LOG.info("Initializing OpenFastTrack plugin for project '{}'", rootProject);
  rootProject.allprojects(this::createConfigDsl);
  createTasks(rootProject);
}

代码示例来源:origin: org.sonarsource.scanner.gradle/sonarqube-gradle-plugin

private void addExtensions(Project project) {
 project.allprojects(p -> {
  LOGGER.debug("Adding " + SonarQubeExtension.SONARQUBE_EXTENSION_NAME + " extension to " + p);
  ActionBroadcast<SonarQubeProperties> actionBroadcast = addBroadcaster(p);
  p.getExtensions().create(SonarQubeExtension.SONARQUBE_EXTENSION_NAME, SonarQubeExtension.class, actionBroadcast);
 });
}

代码示例来源:origin: SonarSource/sonar-scanner-gradle

private void addExtensions(Project project) {
 project.allprojects(p -> {
  LOGGER.debug("Adding " + SonarQubeExtension.SONARQUBE_EXTENSION_NAME + " extension to " + p);
  ActionBroadcast<SonarQubeProperties> actionBroadcast = addBroadcaster(p);
  p.getExtensions().create(SonarQubeExtension.SONARQUBE_EXTENSION_NAME, SonarQubeExtension.class, actionBroadcast);
 });
}

代码示例来源:origin: gradle.plugin.net.karlmartens.gitversion/gitversion-plugin

@Override
public void apply(Project project) {
  project.allprojects(p -> {
    final Optional<VersionInfo> versionInfo = gitVersion(p);
    Optional<String> version = versionInfo.map(v -> {
      final BranchInfo branchInfo = gitBranch(p).orElse(DEFAULT_BRANCH);
      return versionString(v, branchInfo);
    });
    version.ifPresent(p::setVersion);
    boolean isRelease = versionInfo.map(v -> v.isRelease).orElse(false);
    p.getExtensions().getExtraProperties().set("isRelease", isRelease);
  });
}

代码示例来源: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: palantir/gradle-baseline

private void configurePluginsForArtifacts(Project project) {
  String circleArtifactsDir = System.getenv("CIRCLE_ARTIFACTS");
  if (circleArtifactsDir == null) {
    project.getLogger().info("$CIRCLE_ARTIFACTS variable is not set, not configuring junit/profiling reports");
    return;
  }
  try {
    Files.createDirectories(Paths.get(circleArtifactsDir), PERMS_ATTRIBUTE);
  } catch (IOException e) {
    throw new RuntimeException("failed to create CIRCLE_ARTIFACTS directory", e);
  }
  project.getRootProject().allprojects(proj ->
      proj.getTasks().withType(Test.class, test -> {
        test.getReports().getHtml().setEnabled(true);
        test.getReports().getHtml().setDestination(junitPath(circleArtifactsDir, test.getPath()));
      }));
}

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

@Override
protected void afterDecomp(final boolean isDecomp, final boolean useLocalCache, final String mcConfig)
{
  // add MC repo to all projects
  project.allprojects(new Action<Project>() {
    @Override
    public void execute(Project proj)
    {
      String cleanRoot = CLEAN_ROOT + getJarName() + "/" + REPLACE_MC_VERSION + "/" + MCP_INSERT;
      addFlatRepo(proj, "VanillaMcRepo", delayedFile(useLocalCache ? DIR_LOCAL_CACHE : cleanRoot).call());
    }
  });
  // add the Mc dep
  String group = "net.minecraft";
  String artifact = getJarName() + (isDecomp ? "Src" : "Bin");
  String version = delayedString(REPLACE_MC_VERSION).call() + (useLocalCache ? "-PROJECT(" + project.getName() + ")" : "");
  project.getDependencies().add(CONFIG_MC, ImmutableMap.of("group", group, "name", artifact, "version", version));
}

代码示例来源:origin: org.shipkit/shipkit

@Override
  public void apply(final Project project) {
    project.getPlugins().apply(GitHubContributorsPlugin.class);
    final Task fetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS);

    project.allprojects(subproject ->
      subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> {
        //Because maven-publish plugin uses new configuration model, we cannot get the task directly
        //So we use 'matching' technique.
        subproject.getTasks().matching(withName(POM_TASK)).all(t -> t.mustRunAfter(fetcher));

        //Pom task needs data from fetcher hence 'mustRunAfter' above.
        //We don't use 'dependsOn' because we want the fetcher to be included only when we are publishing to Bintray
        Task upload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK);
        upload.dependsOn(fetcher);
      }));
  }
}

代码示例来源:origin: mockito/shipkit

@Override
  public void apply(final Project project) {
    project.getPlugins().apply(GitHubContributorsPlugin.class);
    final Task fetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS);

    project.allprojects(subproject ->
      subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> {
        //Because maven-publish plugin uses new configuration model, we cannot get the task directly
        //So we use 'matching' technique.
        subproject.getTasks().matching(withName(POM_TASK)).all(t -> t.mustRunAfter(fetcher));

        //Pom task needs data from fetcher hence 'mustRunAfter' above.
        //We don't use 'dependsOn' because we want the fetcher to be included only when we are publishing to Bintray
        Task upload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK);
        upload.dependsOn(fetcher);
      }));
  }
}

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

@Override
protected void afterDecomp(final boolean isDecomp, final boolean useLocalCache, final String mcConfig)
{
  // add MC repo to all projects
  project.allprojects(new Action<Project>() {
    @Override
    public void execute(Project proj)
    {
      addFlatRepo(proj, "TweakerMcRepo", delayedFile(useLocalCache ? DIR_LOCAL_CACHE : DIR_API_JAR_BASE).call());
    }
  });
  // add the Mc dep
  T exten = getExtension();
  String group = getApiGroup(exten);
  String artifact = getApiName(exten) + (isDecomp ? "Src" : "Bin");
  String version = getApiVersion(exten) + (useLocalCache ? "-PROJECT(" + project.getName() + ")" : "");
  project.getDependencies().add(CONFIG_MC, ImmutableMap.of("group", group, "name", artifact, "version", version));
}

代码示例来源:origin: org.shipkit/shipkit

public void apply(final Project project) {
    ProjectUtil.requireRootProject(project, this.getClass());
    project.getPlugins().apply(ShipkitBasePlugin.class);
    project.getPlugins().apply(PomContributorsPlugin.class);

    project.allprojects(subproject -> subproject.getPlugins().withId("java", plugin -> {
      subproject.getPlugins().apply(JavaBintrayPlugin.class);
    }));
  }
}

代码示例来源:origin: mockito/shipkit

public void apply(final Project project) {
    ProjectUtil.requireRootProject(project, this.getClass());
    project.getPlugins().apply(ShipkitBasePlugin.class);
    project.getPlugins().apply(PomContributorsPlugin.class);

    project.allprojects(subproject -> subproject.getPlugins().withId("java", plugin -> {
      subproject.getPlugins().apply(JavaBintrayPlugin.class);
    }));
  }
}

代码示例来源:origin: org.shipkit/shipkit

public void apply(final Project project) {
  LocalSnapshotPlugin snapshotPlugin = project.getPlugins().apply(LocalSnapshotPlugin.class);
  final File versionFile = project.file(VERSION_FILE_NAME);
  final VersionInfo versionInfo = new VersionInfoFactory().createVersionInfo(versionFile,
    project.getVersion(), snapshotPlugin.isSnapshot());
  project.getExtensions().add(VersionInfo.class.getName(), versionInfo);
  final String version = versionInfo.getVersion();
  project.allprojects(project1 -> project1.setVersion(version));
  TaskMaker.task(project, BUMP_VERSION_FILE_TASK, BumpVersionFileTask.class, t -> {
    t.setDescription("Increments version number in " + versionFile.getName());
    t.setVersionFile(versionFile);
    String versionChangeMessage = formatVersionInformationInCommitMessage(version, versionInfo.getPreviousVersion());
    GitPlugin.registerChangesForCommitIfApplied(singletonList(versionFile), versionChangeMessage, t);
  });
}

代码示例来源:origin: mockito/shipkit

public void apply(final Project project) {
  LocalSnapshotPlugin snapshotPlugin = project.getPlugins().apply(LocalSnapshotPlugin.class);
  final File versionFile = project.file(VERSION_FILE_NAME);
  final VersionInfo versionInfo = new VersionInfoFactory().createVersionInfo(versionFile,
    project.getVersion(), snapshotPlugin.isSnapshot());
  project.getExtensions().add(VersionInfo.class.getName(), versionInfo);
  final String version = versionInfo.getVersion();
  project.allprojects(project1 -> project1.setVersion(version));
  TaskMaker.task(project, BUMP_VERSION_FILE_TASK, BumpVersionFileTask.class, t -> {
    t.setDescription("Increments version number in " + versionFile.getName());
    t.setVersionFile(versionFile);
    String versionChangeMessage = formatVersionInformationInCommitMessage(version, versionInfo.getPreviousVersion());
    GitPlugin.registerChangesForCommitIfApplied(singletonList(versionFile), versionChangeMessage, t);
  });
}

代码示例来源:origin: palantir/gradle-baseline

@Override
public void apply(Project project) {
  if (project != project.getRootProject()) {
    project.getLogger().warn(
        "com.palantir.baseline-circleci should be applied to the root project only, not '{}'",
        project.getName());
  }
  // the `./gradlew resolveConfigurations` task is used on CI to download all jars for convenient caching
  project.getRootProject().allprojects(p -> p.getPluginManager().apply(ConfigurationResolverPlugin.class));
  configurePluginsForReports(project);
  configurePluginsForArtifacts(project);
}

代码示例来源:origin: gradle.plugin.org.shipkit/shipkit

public void execute(final ReleaseNeededTask t) {
    t.setDescription("Asserts that criteria for the release are met and throws exception if release not needed.");
    t.setExplosive(true);
    project.allprojects(new Action<Project>() {
      public void execute(final Project subproject) {
        subproject.getPlugins().withType(PublicationsComparatorPlugin.class, new Action<PublicationsComparatorPlugin>() {
          public void execute(PublicationsComparatorPlugin p) {
            // make this task depend on all comparePublications tasks
            Task task = subproject.getTasks().getByName(PublicationsComparatorPlugin.COMPARE_PUBLICATIONS_TASK);
            t.addPublicationsComparator((PublicationsComparatorTask) task);
          }
        });
      }
    });
    t.setReleasableBranchRegex(conf.getGit().getReleasableBranchRegex());
    project.getPlugins().apply(GitBranchPlugin.class)
        .provideBranchTo(t, new Action<String>() {
          public void execute(String branch) {
            t.setBranch(branch);
          }
        });
  }
});

代码示例来源:origin: org.shipkit/shipkit

public void execute(final ReleaseNeededTask t) {
    t.setDescription("Asserts that criteria for the release are met and throws exception if release not needed.");
    t.setExplosive(true);
    project.allprojects(new Action<Project>() {
      public void execute(final Project subproject) {
        subproject.getPlugins().withType(ComparePublicationsPlugin.class, new Action<ComparePublicationsPlugin>() {
          public void execute(ComparePublicationsPlugin p) {
            // make this task depend on all comparePublications tasks
            ComparePublicationsTask task = (ComparePublicationsTask) subproject.getTasks().getByName(ComparePublicationsPlugin.COMPARE_PUBLICATIONS_TASK);
            t.dependsOn(task);
            t.getComparisonResults().add(task.getComparisonResult());
          }
        });
      }
    });
    t.setReleasableBranchRegex(conf.getGit().getReleasableBranchRegex());
    project.getPlugins().apply(GitBranchPlugin.class)
        .provideBranchTo(t, new Action<String>() {
          public void execute(String branch) {
            t.setBranch(branch);
          }
        });
  }
});

代码示例来源:origin: mockito/shipkit

public void execute(final ReleaseNeededTask t) {
    t.setDescription("Asserts that criteria for the release are met and throws exception if release not needed.");
    t.setExplosive(true);
    project.allprojects(new Action<Project>() {
      public void execute(final Project subproject) {
        subproject.getPlugins().withType(ComparePublicationsPlugin.class, new Action<ComparePublicationsPlugin>() {
          public void execute(ComparePublicationsPlugin p) {
            // make this task depend on all comparePublications tasks
            ComparePublicationsTask task = (ComparePublicationsTask) subproject.getTasks().getByName(ComparePublicationsPlugin.COMPARE_PUBLICATIONS_TASK);
            t.dependsOn(task);
            t.getComparisonResults().add(task.getComparisonResult());
          }
        });
      }
    });
    t.setReleasableBranchRegex(conf.getGit().getReleasableBranchRegex());
    project.getPlugins().apply(GitBranchPlugin.class)
        .provideBranchTo(t, new Action<String>() {
          public void execute(String branch) {
            t.setBranch(branch);
          }
        });
  }
});

代码示例来源:origin: palantir/gradle-baseline

@Override
public void apply(Project project) {
  Project rootProject = project.getRootProject();
  if (!project.equals(rootProject)) {
    project.getLogger().warn(
        "com.palantir.baseline should be applied to the root project only, not '{}'",
        project.getName());
  }
  rootProject.getPluginManager().apply(BaselineConfig.class);
  rootProject.getPluginManager().apply(BaselineCircleCi.class);
  rootProject.allprojects(proj -> {
    proj.getPluginManager().apply(BaselineCheckstyle.class);
    proj.getPluginManager().apply(BaselineScalastyle.class);
    proj.getPluginManager().apply(BaselineEclipse.class);
    proj.getPluginManager().apply(BaselineIdea.class);
    proj.getPluginManager().apply(BaselineErrorProne.class);
    proj.getPluginManager().apply(BaselineVersions.class);
    proj.getPluginManager().apply(BaselineFormat.class);
    // TODO(dfox): enable this when it has been validated on a few real projects
    // proj.getPluginManager().apply(BaselineClassUniquenessPlugin.class);
  });
}

相关文章