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

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

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

Project.getGradle介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

private void configureJoobyRun(final Project project) {
 project.getTasks()
   .withType(JoobyTask.class, joobyRun -> {
    ConventionMapping mapping = joobyRun.getConventionMapping();
    mapping.map("classpath", () -> new JoobyProject(project).classpath());
    mapping.map("src", () -> new JoobyProject(project).sources());
    mapping.map("mainClassName", () -> project.getProperties().get("mainClassName"));
    mapping.map("srcExtensions", () -> Arrays.asList(".java", ".conf", ".properties", ".kt"));
    mapping.map("compiler", () -> {
     File eclipseClasspath = new File(project.getProjectDir(), ".classpath");
     return eclipseClasspath.exists() ? "off" : "on";
    });
    Gradle gradle = project.getGradle();
    mapping.map("block", () -> !gradle.getStartParameter().isContinuous());
    mapping.map("logLevel", () -> gradle.getStartParameter().getLogLevel().name());
   });
 Map<String, Object> options = new HashMap<>();
 options.put(Task.TASK_TYPE, JoobyTask.class);
 options.put(Task.TASK_DEPENDS_ON, "classes");
 options.put(Task.TASK_NAME, "joobyRun");
 options.put(Task.TASK_DESCRIPTION, "Run, debug and hot reload applications");
 options.put(Task.TASK_GROUP, "jooby");
 project.getTasks().create(options);
}

代码示例来源:origin: jooby-project/jooby

.useInstallation(project.getGradle().getGradleHomeDir())
   .forProjectDirectory(project.getRootDir())
   .connect();
String[] args = project.getGradle().getStartParameter().getProjectProperties()
  .entrySet().stream().map(Object::toString).collect(Collectors.toList())
  .toArray(new String[0]);

代码示例来源:origin: ManbangGroup/Phantom

private Set<String> getCompileArtifactsForAgp31x() {
  ImmutableMap<String, String> buildMapping = ModelBuilder.computeBuildMapping(project.getGradle());
  final Set<ArtifactDependencyGraph.HashableResolvedArtifactResult> allArtifacts =
      ArtifactDependencyGraph.getAllArtifacts(
          applicationVariant.getVariantData().getScope(),
          AndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH,
          null,
          buildMapping);
  return getMavenArtifacts(allArtifacts);
}

代码示例来源:origin: alipay/sofa-boot

private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
  UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
  project.getConfigurations().all((configuration) -> {
    ResolvableDependencies incoming = configuration.getIncoming();
    incoming.afterResolve((resolvableDependencies) -> {
      if (incoming.equals(resolvableDependencies)) {
        unresolvedDependenciesAnalyzer.analyze(configuration
            .getResolvedConfiguration().getLenientConfiguration()
            .getUnresolvedModuleDependencies());
      }
    });
  });
  project.getGradle().buildFinished(
      (buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
}

代码示例来源:origin: BolexLiu/AutoEx

@Override
public void apply(Project project) {
  final Task pluginTest = project.task("autoExTest");
  pluginTest.setGroup("autoEx");
  pluginTest.doLast(new Action<Task>() {
    @Override
    public void execute(Task task) {
      System.out.println("Test测试");
      DoHandleService.search("Test测试",5);
    }
  });
  project.getGradle().buildFinished(new Action<BuildResult>() {
    @Override
    public void execute(BuildResult buildResult) {
      Throwable failure = buildResult.getFailure();
      if (failure != null) {
        DoHandleService.search(failure.getCause().getCause().getMessage(),5);
      } else {
        System.out.println("没有异常,这很棒!");
      }
    }
  });
}

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

project.getGradle().getTaskGraph().whenReady(new Closure(null) {
  private static final long serialVersionUID = 1L;

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

private static void checkGradleVersion(Project project) {
  Pattern versionPattern = Pattern.compile("(\\d+(?:\\.\\d+)+).*");
  String gradleVersion = project.getGradle().getGradleVersion();
  Matcher versionMatcher = versionPattern.matcher(gradleVersion);
  if (!versionMatcher.matches()) {
    throw new GradleException("Invalid Gradle version: " + gradleVersion);
  }
  if (compareVersions(versionMatcher.group(1), MINIMUM_GRADLE_VERSION) < 0) {
    throw new GradleException("Pride requires Gradle version " + MINIMUM_GRADLE_VERSION + " or later. " +
        "If you want to use an earlier Gradle version, try Pride 0.10.");
  }
}

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

private boolean shouldConfigurePublications(Project project) {
    //Sanity system property. Semi-internal.
    boolean workaroundTurnedOff = "false".equals(System.getProperty("org.shipkit.publications-bug-workaround"));
    if (workaroundTurnedOff) {
      return true;
    }
    //Workaround for bintray plugin/Gradle bug (https://github.com/bintray/gradle-bintray-plugin/issues/159)
    return !project.getGradle().getStartParameter().getTaskNames().contains("tasks");
  }
}

代码示例来源:origin: gradle.plugin.de.qaware.seu.as.code/seuac-credentials-plugin

private static File credentialsFile(Project project, CredentialsExtension extension) {
  String propertyFile = extension.getPropertyFile();
  return (propertyFile != null) ? new File(propertyFile) :
      new File(project.getGradle().getGradleUserHomeDir(), DEFAULT_FILENAME);
}

代码示例来源:origin: classmethod/gradle-aws-plugin

public List<Output> getStackOutputs(String stackName) {
  if (getProject().getGradle().getStartParameter().isOffline() == false) {
    Optional<Stack> stack = getStack(stackName);
    return stack.map(Stack::getOutputs).orElse(Collections.emptyList());
  }
  logger.info("offline mode: return empty outputs");
  return Collections.emptyList();
}

代码示例来源:origin: classmethod/gradle-aws-plugin

public List<Parameter> getStackParameters(String stackName) {
  if (getProject().getGradle().getStartParameter().isOffline() == false) {
    Optional<Stack> stack = getStack(stackName);
    return stack.map(Stack::getParameters).orElse(Collections.emptyList());
  }
  logger.info("offline mode: return empty parameters");
  return Collections.emptyList();
}

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

@Override
public void beforeEvaluate(Project project) {
  if (project.getGradle() == rootGradle) {
    logger.beforeEvaluate(project.getPath());
  }
}

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

@Override
public void afterEvaluate(Project project, ProjectState state) {
  if (project.getGradle() == rootGradle) {
    logger.afterEvaluate(project.getPath());
  }
}

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

/** Adds an eclipse project from the given included build. */
public void addIncludedProject(String includedBuild, String projectPath) {
  IncludedBuild included = project.getGradle().includedBuild(includedBuild);
  File projectDir = new File(included.getProjectDir(), projectPath.substring(1).replace(':', '/'));
  Preconditions.checkArgument(addProjectIfExists(included, projectDir, Specs.satisfyAll()));
}

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

public void apply(final Project project) {
  //main release task
  project.getTasks().create("release");
  final ReleaseWorkflowExtension ext = project.getExtensions().create("releaseWorkflow", ReleaseWorkflowExtension.class, project);
  //setup listener, so that the postSteps are only executed if one of the main tasks fail
  project.getGradle().addListener(new PostStepTaskEnabler(ext));
  //TODO very implicit, it needs to go to some tools for release, for example, "releaseTools.git"
  GitTool gitTool = Git.gitTool(Exec.getProcessRunner(project.getProjectDir()));
  project.getExtensions().getExtraProperties().set("gitTool", gitTool);
}

代码示例来源:origin: com.carecon.fabric3.gradle/fabric3-plugin-core

public static void checkGradleVersion(Project project, String gradleMinVersion, String gradlePluginName) {
    String projectGradleVersion = project.getGradle().getGradleVersion();
    if (new VersionComparator().compare(gradleMinVersion, projectGradleVersion) > 0) {
      throw new BuildException(String.format(
          "Detected Gradle version %s, but %s requires Gradle version %s or higher.",
          projectGradleVersion, gradlePluginName, gradleMinVersion), null);
    }
  }
}

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

private ResourceLock getOrCreateProjectLock(Project project) {
  String gradlePath = ((GradleInternal) project.getGradle()).getIdentityPath().toString();
  String projectPath = ((ProjectInternal) project).getIdentityPath().toString();
  return workerLeaseService.getProjectLock(gradlePath, projectPath);
}

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

@Override
public void afterExecute(Task task, TaskState state) {
  if (task.getProject().getGradle() == rootGradle) {
    logger.afterExecute(state.getFailure() != null);
  } else {
    logger.afterNestedExecute(state.getFailure() != null);
  }
}

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

@Override
public void apply(Project project) {
  Task snapshotTask = TaskMaker.task(project, SNAPSHOT_TASK, t -> {
    t.setDescription("Depends on specific tasks that create local snapshot files.");
  });
  this.isSnapshot = configureTask(snapshotTask, project.getGradle().getStartParameter().getTaskNames());
}

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

@Override
public void apply(Project project) {
  Task snapshotTask = TaskMaker.task(project, SNAPSHOT_TASK, t -> {
    t.setDescription("Depends on specific tasks that create local snapshot files.");
  });
  this.isSnapshot = configureTask(snapshotTask, project.getGradle().getStartParameter().getTaskNames());
}

相关文章