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

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

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

Project.getParent介绍

暂无

代码示例

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

private static boolean isAncestorOf(Project target, Project child) {
  Project p = child;
  while (p != null) {
    if (p == target) {
      return true;
    }
    p = p.getParent();
  }
  return false;
}

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

public static void requireRootProject(final Project project, final Class<?> clazz, final String explanation) {
    if (project.getParent() != null) {
      throw new GradleException("Plugin '" + clazz.getSimpleName() + "' is intended to be applied only root project.\n" +
        (explanation != null ? explanation + "\n" : "" ) +
        "Please apply this plugin to the root project instead of '" + project.getPath() + "'.");
    }
  }
}

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

public static void requireRootProject(final Project project, final Class<?> clazz, final String explanation) {
    if (project.getParent() != null) {
      throw new GradleException("Plugin '" + clazz.getSimpleName() + "' is intended to be applied only root project.\n" +
        (explanation != null ? explanation + "\n" : "" ) +
        "Please apply this plugin to the root project instead of '" + project.getPath() + "'.");
    }
  }
}

代码示例来源:origin: gradle.plugin.com.prezi.pride/gradle-pride-plugin

private static Project findRelativeProjectInternal(Project parent, String path) {
  if (path.isEmpty()) {
    return parent;
  }
  if (path.startsWith(":")) {
    return findRelativeProjectInternal(parent.getParent(), path.substring(1));
  }
  return parent.findProject(path);
}

代码示例来源:origin: prezi/pride

private static Project findRelativeProjectInternal(Project parent, String path) {
  if (path.isEmpty()) {
    return parent;
  }
  if (path.startsWith(":")) {
    return findRelativeProjectInternal(parent.getParent(), path.substring(1));
  }
  return parent.findProject(path);
}

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

public boolean isSatisfiedBy(Task element) {
    if (!element.getName().equals(taskName)) {
      return true;
    }
    for (Project current = element.getProject(); current != null; current = current.getParent()) {
      if (current.equals(targetProject)) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: gradle.plugin.com.shopify.rocky/rocky-plugin

private String getSupportFilesDirForModuleName(PropertyState<String> moduleName) {
  System.out.println(getProject().getParent().getPath());
  StringBuilder builder = new StringBuilder();
  builder.append(getProject().getProjectDir().getParent()).append("/").append(moduleName.get()).append("/build/generated/source/rocky/src/com/shopify/foundation/rockysupport");
  return builder.toString();
}

代码示例来源:origin: gradle.plugin.org.hibernate.build/database-profile-plugin

private void processParentProfiles(Project project, Map<String, ProfileSelector> map) {
  final Project parent = project.getParent();
  if ( parent == null ) {
    return;
  }
  // top-down
  processParentProfiles( parent, map );
  processProjectProfiles( parent, map );
}

代码示例来源:origin: com.netflix.nebula/nebula-dependency-recommender

/**
   * Look for recommended versions in a project and each of its ancestors in order until one is found or the root is reached
   *
   * @param project    the gradle <code>Project</code>
   * @param mvSelector the module to lookup
   * @return the recommended version or <code>null</code>
   */
  protected String getRecommendedVersionRecursive(Project project, ModuleVersionSelector mvSelector) {
    String version = project.getExtensions().getByType(RecommendationProviderContainer.class)
        .getRecommendedVersion(mvSelector.getGroup(), mvSelector.getName());
    if (version != null)
      return version;
    if (project.getParent() != null)
      return getRecommendedVersionRecursive(project.getParent(), mvSelector);
    return null;
  }
}

代码示例来源:origin: gradle.plugin.org.hibernate.build.gradle/hibernate-matrix-testing

private DatabaseProfile findSelectedProfileInParents(Project project) {
  if ( project == null ) {
    return null;
  }
  final DatabaseProfile profileToUseFromParent = findSelectedProfileInParents( project.getParent() );
  final DatabaseProfilesExtension parentExtension = project.getExtensions().findByType( DatabaseProfilesExtension.class );
  if ( parentExtension == null ) {
    return null;
  }
  parentExtension.resolve();
  return parentExtension.getSelectedProfile();
}

代码示例来源:origin: gradle.plugin.com.github.frankfarrell.blastradius/blast-radius

if(project.getParent() == null){
  return Collections.emptySet();

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

@Override
public boolean isSatisfiedBy(Task task) {
  Project project = task.getProject();
  Gradle gradle = project.getGradle();
  TaskExecutionGraph taskExecutionGraph = gradle.getTaskGraph();
  Project parentProject = project;
  while ((parentProject = parentProject.getParent()) != null) {
    TaskContainer parentProjectTaskContainer =
      parentProject.getTasks();
    Task parentProjectTask =
      parentProjectTaskContainer.findByName(task.getName());
    if ((parentProjectTask != null) &&
      taskExecutionGraph.hasTask(parentProjectTask)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: com.liferay/com.liferay.gradle.plugins.node

(project.getParent() == null)) {

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

(project.getParent() == null)) {

代码示例来源:origin: gradle.plugin.org.hibernate.build.gradle/hibernate-matrix-testing

void resolve() {
  if ( isResolved() ) {
    return;
  }
  resolved = true;
  if ( !isEnabled() ) {
    return;
  }
  DatabaseProfile parentProfile = findSelectedProfileInParents( project.getParent() );
  DatabaseProfile localProfile = null;
  if ( getProfileToUse() != null ) {
    localProfile = searchSearchDirectories();
  }
  if ( localProfile != null && parentProfile != null) {
    if ( ! localProfile.getName().equals( parentProfile.getName() ) ) {
      parentProfile = null;
    }
  }
  if ( localProfile != null && parentProfile != null) {
    selectedProfile = MergedDatabaseProfile.merge( localProfile, parentProfile );
  }
  else if ( localProfile != null ) {
    selectedProfile = localProfile;
  }
  else {
    selectedProfile = parentProfile;
  }
}

代码示例来源:origin: com.android.tools.build/gradle-core

@Nullable
private String getJacocoVersion() {
  Project candidateProject = project;
  boolean shouldFailWithException = false;
  while (candidateProject != null) {
    Set<ResolvedArtifact> resolvedArtifacts =
        candidateProject.getBuildscript().getConfigurations().getByName("classpath")
            .getResolvedConfiguration().getResolvedArtifacts();
    for (ResolvedArtifact artifact : resolvedArtifacts) {
      ModuleVersionIdentifier moduleVersion = artifact.getModuleVersion().getId();
      if ("org.jacoco.core".equals(moduleVersion.getName())) {
        return moduleVersion.getVersion();
      }
    }
    if (!resolvedArtifacts.isEmpty()) {
      // not in the DSL test case, where nothing will have been resolved.
      shouldFailWithException = true;
    }
    candidateProject = candidateProject.getParent();
  }
  if (shouldFailWithException) {
    throw new IllegalStateException(
        "Could not find project build script dependency on org.jacoco.core");
  }
  project.getLogger().error(
      "No resolved dependencies found when searching for the jacoco version.");
  return DEFAULT_JACOCO_VERSION;
}

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

public void apply(final Project project) {
  if (project.getParent() == null) {
    //root project, add the extension
    project.getPlugins().apply(InitPlugin.class);
    project.getPlugins().apply(VersioningPlugin.class);
    VersionInfo info = project.getExtensions().getByType(VersionInfo.class);
    conf = project.getRootProject().getExtensions()
        .create("shipkit", ShipkitConfiguration.class);
    loadConfigFromFile(project.getRootProject(), getShipkitFile(project), conf);
    if (project.hasProperty(DRY_RUN_PROPERTY)) {
      conf.setDryRun(true);
      //TODO (maybe) we can actually implement it so that we automatically preconfigure everything by command line parameters
      //e.g. shipkit.gitHub.repository is also a property
    }
    conf.setPreviousReleaseVersion(info.getPreviousVersion());
  } else {
    //not root project, get extension from root project
    conf = project.getRootProject().getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
  }
}

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

public void apply(final Project project) {
  if (project.getParent() == null) {
    //root project, add the extension
    project.getPlugins().apply(InitPlugin.class);
    project.getPlugins().apply(VersioningPlugin.class);
    VersionInfo info = project.getExtensions().getByType(VersionInfo.class);
    configuration = project.getRootProject().getExtensions()
        .create("shipkit", ReleaseConfiguration.class);
    final File configFile = project.file(CONFIG_FILE_RELATIVE_PATH);
    loadConfigFromFile(project.getRootProject(), configFile);
    if (project.hasProperty("shipkit.dryRun")) {
      Object value = project.getProperties().get("shipkit.dryRun");
      configuration.setDryRun(!"false".equals(value));
      //TODO we can actually implement it so that we automatically preconfigure everything by command line parameters
      //e.g. shipkit.gitHub.repository is also a property
    }
    configuration.setPreviousReleaseVersion(info.getPreviousVersion());
    TaskMaker.task(project, INIT_CONFIG_FILE_TASK, InitConfigFileTask.class, new Action<InitConfigFileTask>() {
      @Override
      public void execute(InitConfigFileTask t) {
        t.setDescription("Creates Shipkit configuration file unless it already exists");
        t.setConfigFile(configFile);
        project.getTasks().getByName(InitPlugin.INIT_SHIPKIT_TASK).dependsOn(t);
      }
    });
  } else {
    //not root project, get extension from root project
    configuration = project.getRootProject().getPlugins().apply(ReleaseConfigurationPlugin.class).getConfiguration();
  }
}

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

public void apply(final Project project) {
  if (project.getParent() == null) {
    //root project, add the extension
    project.getPlugins().apply(InitPlugin.class);
    project.getPlugins().apply(VersioningPlugin.class);
    VersionInfo info = project.getExtensions().getByType(VersionInfo.class);
    conf = project.getRootProject().getExtensions()
        .create("shipkit", ShipkitConfiguration.class);
    loadConfigFromFile(project.getRootProject(), getShipkitFile(project), conf);
    if (project.hasProperty(DRY_RUN_PROPERTY)) {
      conf.setDryRun(true);
      //TODO (maybe) we can actually implement it so that we automatically preconfigure everything by command line parameters
      //e.g. shipkit.gitHub.repository is also a property
    }
    conf.setPreviousReleaseVersion(info.getPreviousVersion());
  } else {
    //not root project, get extension from root project
    conf = project.getRootProject().getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
  }
}

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

parent = parent.getParent();

相关文章