org.gradle.api.invocation.Gradle.getStartParameter()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(320)

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

Gradle.getStartParameter介绍

暂无

代码示例

代码示例来源: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

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

代码示例来源:origin: stackoverflow.com

def getCurrentFlavor() {
  Gradle gradle = getGradle()
  String  tskReqStr = gradle.getStartParameter().getTaskRequests().toString()

  Pattern pattern;

  if( tskReqStr.contains( "assemble" ) )
    pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
  else
    pattern = Pattern.compile("generate(\\w+)(Release|Debug)")

  Matcher matcher = pattern.matcher( tskReqStr )

  if( matcher.find() )
    return matcher.group(1).toLowerCase()
  else
  {
    println "NO MATCH FOUND"
    return "";
  }
}

代码示例来源:origin: stackoverflow.com

def betaVersion() {
  Gradle gradle = getGradle()
  String  tskReqStr = gradle.getStartParameter().getTaskRequests().toString()

  if(tskReqStr.contains("Free"))
    return 1;
  else if(tskReqStr.contains("Original"))
    return 3;
}

代码示例来源:origin: stackoverflow.com

Gradle gradle = getGradle()

Pattern pattern = Pattern.compile(":assemble(.*?)(Release|Debug)");
Matcher matcher = pattern.matcher(gradle.getStartParameter().getTaskRequests().toString());
println(matcher.group(1))

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

private boolean shouldConfigurePublications(Project project) {
    //Sanity system property. Semi-internal.
    boolean workaroundTurnedOff = "false".equals(System.getProperty("org.mockito.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: mockito/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: 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: 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: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin

private static boolean isProgressFooterEnabled(Project project) {
 // TODO: Consolidate with MavenProjectProperties?
 if ("plain".equals(System.getProperty(PropertyNames.CONSOLE))) {
  return false;
 }
 switch (project.getGradle().getStartParameter().getConsoleOutput()) {
  case Plain:
   return false;
  case Auto:
   // Enables progress footer when ANSI is supported (Windows or TERM not 'dumb').
   return Os.isFamily(Os.FAMILY_WINDOWS) || !"dumb".equals(System.getenv("TERM"));
  default:
   return true;
 }
}

代码示例来源:origin: gradle.plugin.com.s390x/gogradle

public static boolean isRefreshDependencies() {
  return getInstance(Project.class).getGradle().getStartParameter().isRefreshDependencies()
      || "true".equals(System.getProperty(GOGRADLE_REFRESH));
}

代码示例来源:origin: linkedin/pygradle

public static boolean isPlainOrVerbose(Project project) {
  return project.getLogger().isInfoEnabled() || System.getenv("TERM") == null
    || project.getGradle().getStartParameter().getConsoleOutput() == ConsoleOutput.Plain;
}

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

public static boolean isPlainOrVerbose(Project project) {
  return project.getLogger().isInfoEnabled() || System.getenv("TERM") == null
    || project.getGradle().getStartParameter().getConsoleOutput() == ConsoleOutput.Plain;
}

代码示例来源:origin: gradle.plugin.com.s390x/gogradle

public static boolean isOffline() {
  return getInstance(Project.class).getGradle().getStartParameter().isOffline();
}

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

public void buildStarted(Gradle gradle) {
  long now = clock.getCurrentTime();
  buildProfile = new BuildProfile(gradle.getStartParameter());
  buildProfile.setBuildStarted(now);
  buildProfile.setProfilingStarted(buildStartedTime.getStartTime());
}

代码示例来源: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());
}

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

public void buildStarted(Gradle gradle) {
  StartParameter startParameter = gradle.getStartParameter();
  logger.info("Starting Build");
  if (logger.isDebugEnabled()) {
    logger.debug("Gradle user home: {}", startParameter.getGradleUserHomeDir());
    logger.debug("Current dir: {}", startParameter.getCurrentDir());
    logger.debug("Settings file: {}", startParameter.getSettingsFile());
    logger.debug("Build file: {}", startParameter.getBuildFile());
  }
}

代码示例来源:origin: michel-kraemer/gradle-download-task

/**
   * Test if the task fails we're in offline mode and the file does
   * not exist already
   * @throws Exception if anything goes wrong
   */
  @Test(expected = GradleException.class)
  public void offlineFail() throws Exception {
    Download t = makeProjectAndTask();
    t.getProject().getGradle().getStartParameter().setOffline(true);
    t.src(makeSrc(TEST_FILE_NAME));
    File dst = new File(folder.getRoot(), "offlineFail");
    t.dest(dst);
    t.execute(); // should fail
  }
}

相关文章