public void execute(final Exec t) { //Travis default clone is shallow which will prevent correct release notes generation for repos with lots of commits t.commandLine("git", "fetch", "--unshallow"); t.setDescription("Ensures good chunk of recent commits is available for release notes automation. Runs: " + t.getCommandLine()); t.setIgnoreExitValue(true); t.doLast(new Action<Task>() { public void execute(Task task) { if (t.getExecResult().getExitValue() != 0) { LOG.lifecycle(" Following git command failed and will be ignored:" + "\n " + StringUtil.join(t.getCommandLine(), " ") + "\n Most likely the repository already contains all history."); } } }); } });
public void execute(final Exec t) { t.setDescription("Overwrites local git 'user.email' with a generic email. Intended for CI."); t.doFirst(new Action<Task>() { public void execute(Task task) { //using doFirst() so that we request and validate presence of env var only during execution time //TODO consider adding 'lazyExec' task or method that automatically uses do first t.commandLine("git", "config", "--local", "user.email", conf.getGit().getEmail()); } }); } });
public void execute(final Exec t) { t.setDescription("Stashes current changes"); t.commandLine("git", "stash"); t.mustRunAfter(SOFT_RESET_COMMIT_TASK); } });
public void execute(final Exec t) { t.setDescription("Removes last commit, using 'reset --soft HEAD~'"); t.commandLine("git", "reset", "--soft", "HEAD~"); } });
task.commandLine("npm", "install", "--no-package-lock"); task.workingDir(srcDirectory); task.dependsOn(compileConjureTypeScript); task.getInputs().file(new File(srcDirectory, "package.json")); task.getOutputs().dir(new File(srcDirectory, "node_modules")); }); Task compileTypeScript = project.getTasks().create("compileTypeScript", Exec.class, task -> { task.setDescription( "Runs `npm tsc` to compile generated TypeScript files into JavaScript files."); task.setGroup(TASK_GROUP); task.commandLine("npm", "run-script", "build"); task.workingDir(srcDirectory); task.dependsOn(installTypeScriptDependencies); }); Task publishTypeScript = project.getTasks().create("publishTypeScript", Exec.class, task -> { task.setDescription("Runs `npm publish` to publish a TypeScript package " + "generated from your Conjure definitions."); task.setGroup(TASK_GROUP); task.commandLine("npm", "publish"); task.workingDir(srcDirectory); task.dependsOn(compileConjureTypeScript); task.dependsOn(compileTypeScript); }); subproj.afterEvaluate(p -> subproj.getTasks().maybeCreate("publish").dependsOn(publishTypeScript));
}); project.getTasks().create("buildWheel", Exec.class, task -> { task.setDescription("Runs `python setup.py sdist bdist_wheel --universal` to build a python wheel " + "generated from your Conjure definitions."); task.setGroup(TASK_GROUP); task.commandLine("python", "setup.py", "build", "--build-base", buildDir, "egg_info", "--egg-base", buildDir, "sdist", "--dist-dir", distDir, "bdist_wheel", "--universal", "--dist-dir", distDir); task.workingDir(subproj.file("python")); task.dependsOn(compileConjurePython); Task cleanTask = project.getTasks().findByName(TASK_CLEAN); cleanTask.dependsOn(project.getTasks().findByName("cleanCompileConjurePython"));
@Override public void apply(Project project) { project.getPlugins().apply(NodePlugin.class); NodeExtension node = project.getExtensions().getByType(NodeExtension.class); node.setDownload(true); node.setVersion("8.11.4"); node.setNodeModulesDir(project.file(new File(project.getBuildDir(), "/modules"))); NpmTask downloadAntoraCli = project.getTasks() .create("downloadAntoraCli", NpmTask.class); downloadAntoraCli.setArgs(Arrays.asList("install", "@antora/cli")); NpmTask downloadAntoraSiteGenerator = project.getTasks() .create("downloadAntoraSiteGenerator", NpmTask.class); downloadAntoraSiteGenerator.setArgs(Arrays.asList("install", "@antora/site-generator-default")); Task downloadAntora = project.getTasks().create("downloadAntora"); downloadAntora.dependsOn(downloadAntoraCli, downloadAntoraSiteGenerator); Exec antora = project.getTasks().create("antora", Exec.class); antora.setGroup("Docs"); antora.setDescription("Installs and runs antora site.yml"); antora.dependsOn(downloadAntora); antora.setCommandLine("build/modules/node_modules/@antora/cli/bin/antora", "site.yml"); } }
private Exec createExecuteModelsGeneratorTask(Project project, Task dependencyTask) { return project.getTasks().create("executeModelGeneratorScript", Exec.class, exec -> { exec.dependsOn(dependencyTask); exec.workingDir(createFileFromPath(generatorScriptDir.get())); exec.commandLine(createFileFromPath(generatorScriptFile.get())).setArgs(getScriptArguments()); exec.execute(); }); }
@Override protected void exec() { setCommandLine("git", "push", "origin", version.get()); super.exec(); } }
public void execute(final Exec t) { t.mustRunAfter(GIT_COMMIT_TASK); final String tag = GitUtil.getTag(conf, project); t.setDescription("Creates new version tag '" + tag + "'"); deferredConfiguration(project, new Runnable() { @Override public void run() { t.commandLine("git", "tag", "-a", tag, "-m", GitUtil.getCommitMessage(conf, "Created new tag " + tag)); } }); } });
/** * Creates exec task with preconfigured defaults */ public static Exec execTask(Project project, String name, Action<Exec> configure) { final Exec exec = project.getTasks().create(name, Exec.class); exec.doFirst(new Action<Task>() { public void execute(Task task) { LOG.lifecycle(" Running:\n {}", join(exec.getCommandLine(), " ")); } }); return configure(configure, exec); }
@Override public void apply(Project project) { if (!project.getPlugins().hasPlugin(AppPlugin.class)) { throw new RuntimeException("should be declared after 'com.android.application'"); } AppExtension ext = project.getExtensions().getByType(AppExtension.class); ext.getApplicationVariants().all(v -> { String taskName = "open"+capitalize(v.getName()); DefaultTask parentTask = v.getInstall(); File adb = ext.getAdbExe(); if (v.isSigningReady()) { String packageId = v.getApplicationId(); HashMap variantAction = new HashMap(); variantAction.put("dependsOn", parentTask); variantAction.put("description", "Installs and opens " + v.getDescription()); variantAction.put("type", Exec.class); variantAction.put("group", "Open"); Exec t = (Exec) project.task(variantAction, taskName); t.setCommandLine(adb, "shell", "monkey", "-p", packageId, "-c", "android.intent.category.LAUNCHER", "1"); } }); }
public void execute(final Exec t) { t.setDescription("Deletes version tag '" + getTag(conf, project) + "'"); t.commandLine("git", "tag", "-d", getTag(conf, project)); t.mustRunAfter(performPush); } });
super.exec(); } finally { LOG.info("Done with exec");
public void execute(final Exec t) { t.setDescription("Overwrites local git 'user.name' with a generic name. Intended for CI."); //TODO replace all doFirst in this class with LazyConfiguration t.doFirst(new Action<Task>() { public void execute(Task task) { //using doFirst() so that we request and validate presence of env var only during execution time t.commandLine("git", "config", "--local", "user.name", conf.getGit().getUser()); } }); } });
@Override protected void exec() { if (keyId.isPresent() && keyId.get().length() > 0) { setCommandLine("git", "tag", "--local-user=" + keyId.get(), "-m " + COMMIT_MESSAGE, version.get()); } else { getLogger().info("No gpg key has been specified, not signing tag."); setCommandLine("git", "tag", "-m " + COMMIT_MESSAGE, version.get()); } super.exec(); }