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

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

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

Project.getAllprojects介绍

暂无

代码示例

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

@Override
public void apply(Project project)
{
  this.logger = project.getLogger();
  project.getAllprojects().forEach(this::applyForProject);
}

代码示例来源:origin: gradle.plugin.com.liferay/gradle-plugins-deployment-helper

@Override
public List<Jar> call() throws Exception {
  List<Jar> jarTasks = new ArrayList<>();
  for (Project curProject : project.getAllprojects()) {
    TaskContainer taskContainer = curProject.getTasks();
    Task task = taskContainer.findByName(
      JavaPlugin.JAR_TASK_NAME);
    if (task instanceof Jar) {
      jarTasks.add((Jar)task);
    }
  }
  return jarTasks;
}

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

static Set<String> getAllProjectsResolvedModuleIdentifiers(Project project) {
  return project.getRootProject().getAllprojects()
      .stream()
      .flatMap(project2 -> getResolvedModuleIdentifiers(project2).stream())
      .collect(Collectors.toSet());
}

代码示例来源:origin: spring-gradle-plugins/dependency-management-plugin

private Set<String> getAllLocalProjectNames(Project rootProject) {
  Set<String> names = new HashSet<String>();
  for (Project localProject: rootProject.getAllprojects()) {
    names.add(localProject.getGroup() + ":" + localProject.getName());
  }
  return names;
}

代码示例来源:origin: gradle.plugin.life.expert/archidoc

/**
 * For all projects
 * Retrieve classpaths from dependencies jar and main source set
 *
 * @param project
 *     root project
 *
 * @return the url [ ] of all artifacts for classloader
 */
public static URL[] retrieveClasspathForAllProjects( Project project )
  {
  if( project == null )
    {
    return new URL[0];
    }
  
  Set< URL > s = project.getAllprojects().stream().flatMap( p -> retrieveClasspath( p ).stream() ).collect( toSet() );
  
  return s.toArray( new URL[0] );
  }

代码示例来源: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: org.gradle/gradle-core

@Override
public void projectsLoaded(Gradle gradle) {
  if (gradle == this.rootGradle) {
    logger.projectsLoaded(gradle.getRootProject().getAllprojects().size());
  }
}

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

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

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

private CollectTask createCollectTask(Project rootProject)
{
  final CollectTask collectTask = createTask(rootProject, "collectRequirements",
      CollectTask.class);
  collectTask.setGroup(TASK_GROUP_NAME);
  collectTask.setDescription("Collect requirements and generate specobject file");
  collectTask.outputFile.set(new File(rootProject.getBuildDir(), "reports/requirements.xml"));
  collectTask.inputDirectories = () -> getAllInputDirectories(rootProject.getAllprojects());
  collectTask.pathConfig = () -> getPathConfig(rootProject.getAllprojects());
  return collectTask;
}

代码示例来源:origin: net.corda.plugins/api-scanner

@InputFiles
public FileCollection getSources() {
  return getProject().files(getProject().getAllprojects().stream()
    .flatMap(project -> project.getTasks()
           .withType(ScanApi.class)
           .matching(ScanApi::isEnabled)
           .stream())
    .flatMap(scanTask -> scanTask.getTargets().getFiles().stream())
    .sorted(comparing(File::getName))
    .collect(toList())
  );
}

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

/**
 * Resolve all buildscript dependencies of this project and it's subprojects.
 *
 * @return All resolved buildscript dependencies.
 */
protected List<DependencyIdentifier> resolveBuildDependencies() {
  return getProject().getAllprojects().stream() //
      .map(project -> project.getBuildscript().getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION).getResolvedConfiguration()) //
      .flatMap(confguration -> confguration.getResolvedArtifacts().stream()) //
      .map(resolvedArtifact -> resolvedArtifact.getModuleVersion().getId()) //
      .map(DependencyIdentifier::new) //
      .distinct() //
      .filter(this::filterIgnoredDependencies) //
      .sorted(new DependencyIdentifierComparator()) //
      .collect(Collectors.toList());
}

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

/**
 * Resolve all dependencies of all configurations of this project and it's subprojects.
 *
 * @return All resolved dependencies.
 */
protected List<DependencyIdentifier> resolveDependencies() {
  return getProject().getAllprojects().stream() // all projects
      .flatMap(project -> project.getConfigurations().stream()) // get all configurations
      .filter(Configuration::isCanBeResolved) // only if the configuration can be resolved
      .flatMap(configuration -> configuration.getResolvedConfiguration().getResolvedArtifacts().stream()) // get all artifacts
      .filter(resolvedArtifact -> !(resolvedArtifact.getId().getComponentIdentifier() instanceof DefaultProjectComponentIdentifier))
      .map(resolvedArtifact -> resolvedArtifact.getModuleVersion().getId()) // map to ModuleVersionIdentifier
      .map(DependencyIdentifier::new) //
      .distinct() //
      .filter(this::filterIgnoredDependencies) //
      .sorted(new DependencyIdentifierComparator()) //
      .collect(Collectors.toList());
}

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

@Internal
public Provider<Set<EtaDependency>>
  getDefaultDependencyProvider() {
  return project.provider(() -> {
      Set<EtaDependency> allDependencies = new LinkedHashSet<>();
      for (Project p: project.getAllprojects()) {
        for (Configuration c: p.getConfigurations()) {
          final EtaConfiguration etaConfiguration =
            ExtensionHelper.getExtension(c, EtaConfiguration.class);
          if (etaConfiguration != null) {
            allDependencies.addAll(etaConfiguration.getAllDependencies());
          }
        }
      }
      return allDependencies;
    });
}

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

/** Adds all eclipse projects from all gradle projects whose paths meet the given spec. */
public void addAllProjects(Spec<String> include) {
  project.getRootProject().getAllprojects().forEach(p -> {
    // this project is automatically included by logic
    // in OomphIdePlugin
    if (p == project) {
      return;
    }
    // this project depends on all the others
    if (include.isSatisfiedBy(p.getPath())) {
      addDependency(project.evaluationDependsOn(p.getPath()));
    }
  });
}

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

private void configureTask(SonarQubeTask sonarQubeTask, Project project) {
 ConventionMapping conventionMapping = sonarQubeTask.getConventionMapping();
 // this will call the SonarPropertyComputer to populate the properties of the task just before running it
 conventionMapping.map("properties", () -> new SonarPropertyComputer(actionBroadcastMap, project)
  .computeSonarProperties());
 Callable<Iterable<? extends Task>> testTasks = () -> project.getAllprojects().stream()
  .filter(p -> p.getPlugins().hasPlugin(JavaPlugin.class) && !p.getExtensions().getByType(SonarQubeExtension.class).isSkipProject())
  .map(p -> p.getTasks().getByName(JavaPlugin.TEST_TASK_NAME))
  .collect(Collectors.toList());
 sonarQubeTask.dependsOn(testTasks);
 Callable<Iterable<? extends Task>> compileTasks = () -> project.getAllprojects().stream()
  .filter(p -> isAndroidProject(p) && !p.getExtensions().getByType(SonarQubeExtension.class).isSkipProject())
  .map(p -> {
   BaseVariant variant = AndroidUtils.findVariant(p, p.getExtensions().getByType(SonarQubeExtension.class).getAndroidVariant());
   List<Task> allCompileTasks = new ArrayList<>();
   boolean unitTestTaskDepAdded = addTaskByName(p, "compile" + capitalize(variant.getName()) + "UnitTestJavaWithJavac", allCompileTasks);
   boolean androidTestTaskDepAdded = addTaskByName(p, "compile" + capitalize(variant.getName()) + "AndroidTestJavaWithJavac", allCompileTasks);
   // unit test compile and android test compile tasks already depends on main code compile so don't add a useless dependency
   // that would lead to run main compile task several times
   if (!unitTestTaskDepAdded && !androidTestTaskDepAdded) {
    addTaskByName(p, "compile" + capitalize(variant.getName()) + "JavaWithJavac", allCompileTasks);
   }
   return allCompileTasks;
  })
  .flatMap(List::stream)
  .collect(Collectors.toList());
 sonarQubeTask.dependsOn(compileTasks);
}

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

public GradleArtifactFileResolver(Project project, boolean autoAddRepositories) {
  this.project = project;
  this.dependencies = project.getDependencies();
  this.configurations = project.getConfigurations();
  this.knownPublications = extractPublishingExtensions( project.getRootProject().getAllprojects() );
  this.logger = project.getLogger();
  this.autoAddRepositories = autoAddRepositories;
}

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

private void configureTask(SonarQubeTask sonarQubeTask, Project project) {
 ConventionMapping conventionMapping = sonarQubeTask.getConventionMapping();
 // this will call the SonarPropertyComputer to populate the properties of the task just before running it
 conventionMapping.map("properties", () -> new SonarPropertyComputer(actionBroadcastMap, project)
  .computeSonarProperties());
 Callable<Iterable<? extends Task>> testTasks = () -> project.getAllprojects().stream()
  .filter(p -> p.getPlugins().hasPlugin(JavaPlugin.class) && !p.getExtensions().getByType(SonarQubeExtension.class).isSkipProject())
  .map(p -> p.getTasks().getByName(JavaPlugin.TEST_TASK_NAME))
  .collect(Collectors.toList());
 sonarQubeTask.dependsOn(testTasks);
 Callable<Iterable<? extends Task>> compileTasks = () -> project.getAllprojects().stream()
  .filter(p -> isAndroidProject(p) && !p.getExtensions().getByType(SonarQubeExtension.class).isSkipProject())
  .map(p -> {
   BaseVariant variant = AndroidUtils.findVariant(p, p.getExtensions().getByType(SonarQubeExtension.class).getAndroidVariant());
   List<Task> allCompileTasks = new ArrayList<>();
   boolean unitTestTaskDepAdded = addTaskByName(p, "compile" + capitalize(variant.getName()) + "UnitTestJavaWithJavac", allCompileTasks);
   boolean androidTestTaskDepAdded = addTaskByName(p, "compile" + capitalize(variant.getName()) + "AndroidTestJavaWithJavac", allCompileTasks);
   // unit test compile and android test compile tasks already depends on main code compile so don't add a useless dependency
   // that would lead to run main compile task several times
   if (!unitTestTaskDepAdded && !androidTestTaskDepAdded) {
    addTaskByName(p, "compile" + capitalize(variant.getName()) + "JavaWithJavac", allCompileTasks);
   }
   return allCompileTasks;
  })
  .flatMap(List::stream)
  .collect(Collectors.toList());
 sonarQubeTask.dependsOn(compileTasks);
}

代码示例来源:origin: me.seeber.gradle/gradle-workspace-plugin

/**
 * Replace dependencies of a project with local projects
 *
 * @param project Project to replace dependencies
 */
protected void replaceDependencies(Project project) {
  project.getConfigurations().all(c -> {
    Multimap<@NonNull String, @NonNull ExportingConfiguration> exports = getExportingConfigurations(
        project.getRootProject().getAllprojects());
    replaceDependencies(project, c, exports);
  });
}

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

@Override
  public void execute(Task task) {
    if (configuration.getFiles().size() != 1) {
      throw new IllegalArgumentException("Expected to find exactly one config dependency in the "
          + "'baseline' configuration, found: " + configuration.getFiles());
    }
    rootProject.copy(copySpec -> {
      copySpec.from(rootProject.zipTree(configuration.getSingleFile()));
      copySpec.into(BaselineConfig.this.getConfigDir());
      copySpec.exclude("**/scalastyle_config.xml");
      copySpec.setIncludeEmptyDirs(false);
    });
    if (rootProject
        .getAllprojects()
        .stream()
        .anyMatch(p -> p.getPluginManager().hasPlugin("scala") && p
            .getPluginManager()
            .hasPlugin("com.palantir.baseline-scalastyle"))) {
      // Matches intellij scala plugin settings per
      // https://github.com/JetBrains/intellij-scala/blob/baaa7c1dabe5222c4bca7c4dd8d80890ad2a8c6b/scala/scala-impl/src/org/jetbrains/plugins/scala/codeInspection/scalastyle/ScalastyleCodeInspection.scala#L19
      rootProject.copy(copySpec -> {
        copySpec.from(rootProject
            .zipTree(configuration.getSingleFile())
            .filter(file -> file.getName().equals("scalastyle_config.xml")));
        copySpec.into(rootProject.getRootDir().toPath().resolve("project"));
        copySpec.setIncludeEmptyDirs(false);
      });
    }
  }
}

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

private void createTracingTask(Project rootProject, CollectTask collectTask)
{
  final TraceTask traceTask = createTask(rootProject, "traceRequirements", TraceTask.class);
  traceTask.setGroup(TASK_GROUP_NAME);
  traceTask.setDescription("Trace requirements and generate tracing report");
  traceTask.dependsOn(collectTask);
  final TracingConfig config = getConfig(rootProject);
  traceTask.requirementsFile.set(collectTask.outputFile);
  traceTask.outputFile.set(config.reportFile);
  traceTask.reportVerbosity.set(config.reportVerbosity);
  traceTask.reportFormat = () -> config.reportFormat;
  traceTask.importedRequirements = () -> getImportedRequirements(
      rootProject.getAllprojects());
  traceTask.filteredArtifactTypes = () -> getFilteredArtifactTypes(rootProject);
  traceTask.filteredTags = () -> getFilteredTags(rootProject);
  traceTask.filterAcceptsItemsWithoutTag = () -> config.filterAcceptsItemsWithoutTag;
}

相关文章