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

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(158)

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

Task.getProject介绍

暂无

代码示例

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

@Override
public void execute(Task task) {
  Project project = task.getProject();
  project.delete(destinationDir);
}

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

@Override
  public void graphPopulated(TaskExecutionGraph graph) {
    Set<Project> seen = Sets.newHashSet();
    for (Task task : graph.getAllTasks()) {
      if (seen.add(task.getProject())) {
        ProjectInternal projectInternal = (ProjectInternal) task.getProject();
        projectInternal.bindAllModelRules();
      }
    }
  }
}

代码示例来源:origin: gradle.plugin.me.bhop.autoversion/gradle-plugin

public void nextMajor(Task task) {
  try {
    System.out.println("Moving project to next major version.");
    AutoVersionExtension ext = task.getProject().getExtensions().getByType(AutoVersionExtension.class);
    URL url = new URL(ext.getBaseUrl() + "projects/" + ext.getProjectId() + "/nextMajor/");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    conn.getResponseMessage();
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

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

public Set<? extends Task> getDependencies(Task task) {
    Set<Task> tasks = Sets.newHashSetWithExpectedSize(taskDependencyNames.size());
    for (String dependedOnTaskName : taskDependencyNames) {
      Task dependency = task.getProject().getTasks().findByName(dependedOnTaskName);
      if (dependency == null) {
        throw new UnknownTaskException(String.format("Imported Ant target '%s' depends on target or task '%s' which does not exist", task.getName(), dependedOnTaskName));
      }
      tasks.add(dependency);
    }
    return tasks;
  }
}

代码示例来源:origin: gradle.plugin.com.github.mazzeb/auto-version

private void nextMajor(Task task) {
  logger.info("updating major version");
  version = version.nextMajor();
  updateVersion(task.getProject(), version);
}

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

@Override public void execute(Task task)
  {
    DeobfuscateJar binDeobf = (DeobfuscateJar) task.getProject().getTasks().getByName(TASK_DEOBF_BIN);
    DeobfuscateJar decompDeobf = (DeobfuscateJar) task.getProject().getTasks().getByName(TASK_DEOBF);
    for (File file : task.getProject().fileTree(delayedFile(DIR_DEP_ATS)))
    {
      binDeobf.addAt(file);
      decompDeobf.addAt(file);
    }
  }
});

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

public static void registerChangesForCommitIfApplied(final List<File> changedFiles,
                             final String changeDescription, final Task changingTask) {
    final Project project = changingTask.getProject();
    project.getPlugins().withType(GitPlugin.class, new Action<GitPlugin>() {
      @Override
      public void execute(GitPlugin gitPushPlugin) {
        GitCommitTask gitCommitTask = (GitCommitTask) project.getTasks().findByName(GitPlugin.GIT_COMMIT_TASK);
        gitCommitTask.addChange(changedFiles, changeDescription, changingTask);
      }
    });
  }
}

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

public static void registerChangesForCommitIfApplied(final List<File> changedFiles,
                             final String changeDescription, final Task changingTask) {
    final Project project = changingTask.getProject();
    project.getPlugins().withType(GitPlugin.class, new Action<GitPlugin>() {
      @Override
      public void execute(GitPlugin gitPushPlugin) {
        GitCommitTask gitCommitTask = (GitCommitTask) project.getTasks().findByName(GitPlugin.GIT_COMMIT_TASK);
        gitCommitTask.addChange(changedFiles, changeDescription, changingTask);
      }
    });
  }
}

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

@Override
public void beforeExecute(Task task) {
  if (task.getProject().getGradle() == rootGradle) {
    logger.beforeExecute();
  }
}

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

@Override
public int compareTo(Task otherTask) {
  int depthCompare = project.compareTo(otherTask.getProject());
  if (depthCompare == 0) {
    return getPath().compareTo(otherTask.getPath());
  } else {
    return depthCompare;
  }
}

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

/**
 * Forces lazy configuration to be triggered for given task
 */
@ExposedForTesting
public static void forceConfiguration(Task task) {
  for (Runnable r : getConfigurer(task.getProject()).actions.get(task)) {
    r.run();
  }
}

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

/**
 * Forces lazy configuration to be triggered for given task
 */
@ExposedForTesting
public static void forceConfiguration(Task task) {
  for (Runnable r : getConfigurer(task.getProject()).actions.get(task)) {
    r.run();
  }
}

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

/**
 * Forces lazy configuration to be triggered for given task
 */
@ExposedForTesting
public static void forceConfiguration(Task task) {
  for (Runnable r : getConfigurer(task.getProject()).actions.get(task)) {
    r.run();
  }
}

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

static boolean configureTask(Task snapshotTask, List<String> taskNames) {
  boolean isSnapshot = taskNames.contains(SNAPSHOT_TASK);
  if (isSnapshot) {
    snapshotTask.getProject().getTasks().matching(withName("javadoc", "groovydoc")).all(doc -> {
      LOG.info("{} - disabled to speed up the 'snapshot' build", snapshotTask.getPath());
      doc.setEnabled(false);
    });
  }
  return isSnapshot;
}

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

static boolean configureTask(Task snapshotTask, List<String> taskNames) {
  boolean isSnapshot = taskNames.contains(SNAPSHOT_TASK);
  if (isSnapshot) {
    snapshotTask.getProject().getTasks().matching(withName("javadoc", "groovydoc")).all(doc -> {
      LOG.info("{} - disabled to speed up the 'snapshot' build", snapshotTask.getPath());
      doc.setEnabled(false);
    });
  }
  return isSnapshot;
}

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

@Override
public void prepareForExecution(Task task) {
  assert task.getProject() == project;
  if (modelNode.hasLink(task.getName())) {
    realizeTask(MODEL_PATH.child(task.getName()), ModelNode.State.GraphClosed);
  }
}

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

public void beforeExecute(Task task) {
  long now = clock.getCurrentTime();
  Project project = task.getProject();
  ProjectProfile projectProfile = buildProfile.getProjectProfile(project.getPath());
  projectProfile.getTaskProfile(task.getPath()).setStart(now);
}

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

public void afterExecute(Task task, TaskState state) {
  long now = clock.getCurrentTime();
  Project project = task.getProject();
  ProjectProfile projectProfile = buildProfile.getProjectProfile(project.getPath());
  TaskExecution taskExecution = projectProfile.getTaskProfile(task.getPath());
  taskExecution.setFinish(now);
  taskExecution.completed(state);
}

相关文章