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

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

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

Project.getRootProject介绍

暂无

代码示例

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

public Target(Project project, String name) {
 this.project = project;
 this.name = name;
 identifier = project.getPath().replaceFirst(":", "");
 path = identifier.replaceAll(":", File.separator);
 rootProject = project.getRootProject();
}

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

public static OkBuckExtension getOkBuckExtension(Project project) {
 return (OkBuckExtension)
   project.getRootProject().getExtensions().getByName(OkBuckGradlePlugin.OKBUCK);
}

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

private static String getTransformConfigRuleForFile(Project project, File config) {
  String relativeConfigPath =
    FileUtil.getRelativePath(project.getRootProject().getProjectDir(), config);
  ProjectUtil.getPlugin(project.getRootProject()).exportedPaths.add(relativeConfigPath);

  if (project.getProjectDir().equals(config.getParentFile())) {
   return ":" + config.getName();
  } else {
   String configTarget = BuckRuleComposer.fileRule(relativeConfigPath);
   Preconditions.checkNotNull(configTarget);
   return configTarget;
  }
 }
}

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

public static OkBuckGradlePlugin getPlugin(Project project) {
 return project.getRootProject().getPlugins().getPlugin(OkBuckGradlePlugin.class);
}

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

/** Write the buck file for the java_annotation_processor rules. */
public void finalizeProcessors() {
 buckFileManager.writeToBuckFile(
   JavaAnnotationProcessorRuleComposer.compose(dependencyToScopeMap.values()),
   project.getRootProject().file(processorBuckFile));
}

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

private LinkedHashMap<String, String> repositoryMap(boolean downloadInBuck) {
 LinkedHashMap<String, String> rawRepositories = new LinkedHashMap<>();
 if (!downloadInBuck) {
  return rawRepositories;
 }
 addRepositories(getProject().getRootProject(), rawRepositories);
 getProject()
   .getRootProject()
   .getSubprojects()
   .forEach(
     subProject -> {
      addRepositories(subProject, rawRepositories);
     });
 LinkedHashMap<String, String> filteredRepositories = new LinkedHashMap<>();
 rawRepositories.forEach(
   (key, value) -> {
    if (!filteredRepositories.values().contains(value)) {
     // Skip adding any `file:` repositories since the path would be absolute
     // and will prevent from checking in the generated buckconfig file.
     if (!value.startsWith("file:")) {
      filteredRepositories.put(key, value);
     }
    }
   });
 return filteredRepositories;
}

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

project ->
  project
    .getRootProject()
    .getProjectDir()
    .toPath()

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

public DependencyCache(
  Project project,
  DependencyManager dependencyManager,
  boolean skipPrebuilt,
  @Nullable String forcedConfiguration) {
 this.rootProject = project.getRootProject();
 this.dependencyManager = dependencyManager;
 this.skipPrebuilt = skipPrebuilt;
 if (forcedConfiguration != null) {
  Scope.builder(project)
    .configuration(forcedConfiguration)
    .build()
    .getExternal()
    .forEach(
      dependency -> {
       get(dependency);
       forcedDeps.put(dependency.getVersionless(), dependency);
      });
 }
}

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

"-Xfriend-paths="
  + Paths.get("buck-out/gen")
    .resolve(getProject().getRootProject().relativePath(getProject().getProjectDir()))
    .resolve(String.format("lib__%s__output", composedTargetName))
    .resolve(composedTargetName + ".jar")

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

public DependencyCache getLintDepsCache() {
 if (lintDepCache == null) {
  lintDepCache = new DependencyCache(project, ProjectUtil.getDependencyManager(project));
  dependencies =
    lintDepCache.build(
      project.getRootProject().getConfigurations().getByName(LINT_DEPS_CONFIG));
 }
 return lintDepCache;
}

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

FileUtil.getRelativePath(project.getRootProject().getProjectDir(), configFile);
ProjectUtil.getPlugin(project.getRootProject()).exportedPaths.add(relativeConfigPath);
 rulesBuilder.build(), project.getRootProject().file(JETIFIER_BUCK_FILE));

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

external.add(externalDependency);
} else {
 String rootProjectPath = project.getRootProject().getProjectDir().getAbsolutePath();
 String artifactPath = artifact.getFile().getAbsolutePath();
         + "outside the project can cause hard to reproduce builds"
         + ". Please move dependency: %s inside %s",
       artifact.getFile(), project.getRootProject().getProjectDir()));

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

rulesBuilder.build(), project.getRootProject().file(lintBuckFile));

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

public static Provisioner fromProject(Project project) {
  Objects.requireNonNull(project);
  return (withTransitives, mavenCoords) -> {
    try {
      Dependency[] deps = mavenCoords.stream()
          .map(project.getBuildscript().getDependencies()::create)
          .toArray(Dependency[]::new);
      Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration(deps);
      config.setDescription(mavenCoords.toString());
      config.setTransitive(withTransitives);
      return config.resolve();
    } catch (Exception e) {
      logger.log(Level.SEVERE,
          StringPrinter.buildStringFromLines("You probably need to add a repository containing the '" + mavenCoords + "' artifact in the 'build.gradle' of your root project.",
              "E.g.: 'buildscript { repositories { mavenCentral() }}'",
              "Note that included buildscripts (using 'apply from') do not share their buildscript repositories with the underlying project.",
              "You have to specify the missing repository explicitly in the buildscript of the root project."),
          e);
      throw e;
    }
  };
}

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

if (getProject() == getProject().getRootProject()) {
  excludes.add(".gradle");

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

@Override
  public void apply(Project project) {
    project.getRootProject().getPlugins().apply(CiReleasePlugin.class);
    project.getPlugins().apply(UpgradeDownstreamPlugin.class);

    ShipkitExecTask ciPerformReleaseTask = (ShipkitExecTask) project.getRootProject().getTasks().findByName(CiReleasePlugin.CI_PERFORM_RELEASE_TASK);

    ciPerformReleaseTask.getExecCommands().add(execCommand(
        "Upgrading downstream projects", asList(GradleWrapper.getWrapperCommand(), UpgradeDownstreamPlugin.UPGRADE_DOWNSTREAM_TASK)));
  }
}

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

private boolean isDependencyOnLocalProject(Project project,
                      DependencyResolveDetails details) {
  return getAllLocalProjectNames(project.getRootProject()).contains(details.getRequested()
      .getGroup() + ":" + details.getRequested().getName());
}

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

public void initVersioning(InitVersioningTask task) {
  File file = task.getVersionFile();
  if (file.exists()) {
    String relativePath = task.getProject().getRootProject().relativePath(file);
    InitMessages.skipping(relativePath);
  } else {
    createVersionPropertiesFile(task.getProject(), file);
  }
}

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

public void initShipkitFile(InitShipkitFileTask task) {
  File shipkitFile = task.getShipkitFile();
  String originRepoName = task.getOriginRepoName();
  String relativePath = task.getProject().getRootProject().relativePath(shipkitFile);
  initShipkitFile(shipkitFile, relativePath, originRepoName);
}

代码示例来源:origin: io.freefair.gradle/android-gradle-plugins

private Provider<Directory> determineConfigurationDirectory() {
  return project.provider(() -> {
    if (usesSubprojectCheckstyleConfiguration()) {
      DeprecationLogger.nagUserWithDeprecatedIndirectUserCodeCause("Setting the Checkstyle configuration file under 'config/checkstyle' of a sub project", "Use the root project's 'config/checkstyle' directory instead.");
      return project.getLayout().getProjectDirectory().dir(CONFIG_DIR_NAME);
    }
    return project.getRootProject().getLayout().getProjectDirectory().dir(CONFIG_DIR_NAME);
  });
}

相关文章