/** * Creates task with preconfigured defaults */ public static Task task(Project project, String name, Action<Task> configure) { Task task = project.getTasks().create(name); return configure(configure, task); }
@Override public void apply(Project project) { TaskMaker.task(project, IDENTIFY_GIT_BRANCH, IdentifyGitBranchTask.class, new Action<IdentifyGitBranchTask>() { public void execute(final IdentifyGitBranchTask t) { t.setDescription("Identifies current git branch."); } }); }
TaskMaker.task(project, GIT_COMMIT_TASK, GitCommitTask.class, new Action<GitCommitTask>() { public void execute(final GitCommitTask t) { t.setDescription("Commits all changed files using generic --author and aggregated commit message"); TaskMaker.execTask(project, GIT_TAG_TASK, new Action<Exec>() { public void execute(final Exec t) { t.mustRunAfter(GIT_COMMIT_TASK); TaskMaker.task(project, GIT_PUSH_TASK, GitPushTask.class, new Action<GitPushTask>() { public void execute(final GitPushTask t) { t.setDescription("Pushes automatically created commits to remote repo."); final Task performPush = TaskMaker.task(project, PERFORM_GIT_PUSH_TASK, Task.class, new Action<Task>() { public void execute(final Task t) { t.setDescription("Performs gitCommit, gitTag and gitPush tasks and all tasks dependent on them."); TaskMaker.task(project, PERFORM_GIT_COMMIT_CLEANUP_TASK, Task.class, new Action<Task>() { public void execute(final Task t) { t.setDescription("Performs " + SOFT_RESET_COMMIT_TASK + " and " + GIT_STASH_TASK + " tasks."); TaskMaker.execTask(project, GIT_STASH_TASK, new Action<Exec>() { public void execute(final Exec t) { t.setDescription("Stashes current changes"); TaskMaker.execTask(project, SOFT_RESET_COMMIT_TASK, new Action<Exec>() { public void execute(final Exec t) { t.setDescription("Removes last commit, using 'reset --soft HEAD~'"); TaskMaker.execTask(project, TAG_CLEANUP_TASK, new Action<Exec>() {
@Override public void apply(Project project) { TaskMaker.task(project, IDENTIFY_GIT_BRANCH, IdentifyGitBranchTask.class, new Action<IdentifyGitBranchTask>() { public void execute(final IdentifyGitBranchTask t) { t.setDescription("Identifies current git branch."); } }); }
/** * Creates task of specific type with preconfigured defaults */ public static <T extends Task> T task(Project project, String name, Class<T> taskType, Action<T> configure) { T task = project.getTasks().create(name, taskType); return configure(configure, task); }
final ReleaseConfiguration conf = project.getPlugins().apply(ReleaseConfigurationPlugin.class).getConfiguration(); TaskMaker.execTask(project, UNSHALLOW_TASK, new Action<Exec>() { public void execute(final Exec t) { TaskMaker.task(project, CHECKOUT_BRANCH_TASK, GitCheckOutTask.class, new Action<GitCheckOutTask>() { public void execute(final GitCheckOutTask t) { t.setDescription("Checks out the branch that can be committed. CI systems often check out revision that is not committable."); TaskMaker.execTask(project, SET_USER_TASK, new Action<Exec>() { public void execute(final Exec t) { t.setDescription("Overwrites local git 'user.name' with a generic name. Intended for CI."); TaskMaker.execTask(project, SET_EMAIL_TASK, new Action<Exec>() { public void execute(final Exec t) { t.setDescription("Overwrites local git 'user.email' with a generic email. Intended for CI."); TaskMaker.task(project, CI_RELEASE_PREPARE_TASK, new Action<Task>() { public void execute(Task t) { t.setDescription("Prepares the working copy for releasing from CI build");
@Override public void apply(Project project) { TaskMaker.task(project, IDENTIFY_GIT_BRANCH, IdentifyGitBranchTask.class, new Action<IdentifyGitBranchTask>() { public void execute(final IdentifyGitBranchTask t) { t.setDescription("Identifies current git branch."); } }); }
/** * Creates task of specific type with preconfigured defaults */ public static <T extends Task> T task(Project project, String name, Class<T> taskType, Action<T> configure) { T task = project.getTasks().create(name, taskType); return configure(configure, task); }
private static ReleaseNeededTask releaseNeededTask(final Project project, String taskName, final ReleaseConfiguration conf) { return TaskMaker.task(project, taskName, ReleaseNeededTask.class, new Action<ReleaseNeededTask>() { public void execute(final ReleaseNeededTask t) { t.setDescription("Asserts that criteria for the release are met and throws exception if release not needed.");
/** * Creates task of specific type with preconfigured defaults */ public static <T extends Task> T task(Project project, String name, Class<T> taskType, Action<T> configure) { T task = project.getTasks().create(name, taskType); return configure(configure, task); }
private static ReleaseNeededTask releaseNeededTask(final Project project, String taskName, final ShipkitConfiguration conf) { return TaskMaker.task(project, taskName, ReleaseNeededTask.class, new Action<ReleaseNeededTask>() { public void execute(final ReleaseNeededTask t) { t.setDescription("Asserts that criteria for the release are met and throws exception if release not needed.");
/** * Creates task with preconfigured defaults */ public static Task task(Project project, String name, Action<Task> configure) { Task task = project.getTasks().create(name); return configure(configure, task); }
private static ReleaseNeededTask releaseNeededTask(final Project project, String taskName, final ShipkitConfiguration conf) { return TaskMaker.task(project, taskName, ReleaseNeededTask.class, new Action<ReleaseNeededTask>() { public void execute(final ReleaseNeededTask t) { t.setDescription("Asserts that criteria for the release are met and throws exception if release not needed.");
/** * Creates task with preconfigured defaults */ public static Task task(Project project, String name, Action<Task> configure) { Task task = project.getTasks().create(name); return configure(configure, task); }
private Task createProduceUpgradeTask(final Project project, final String consumerRepository) { return TaskMaker.task(project, "upgrade" + repositoryNameToCapitalizedCamelCase(consumerRepository), ShipkitExecTask.class, new Action<ShipkitExecTask>() { @Override public void execute(final ShipkitExecTask task) { task.setDescription("Performs dependency upgrade in " + consumerRepository); task.execCommand(ExecCommandFactory.execCommand("Upgrading dependency", CloneGitRepositoryTaskFactory.getConsumerRepoCloneDir(project, consumerRepository), GradleWrapper.getWrapperCommand(), "performVersionUpgrade", getDependencyProperty(project))); } }); }
/** * 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); }
private Task createProduceUpgradeTask(final Project project, final String consumerRepository) { return TaskMaker.task(project, "upgrade" + repositoryNameToCapitalizedCamelCase(consumerRepository), ShipkitExecTask.class, new Action<ShipkitExecTask>() { @Override public void execute(final ShipkitExecTask task) { task.setDescription("Performs dependency upgrade in " + consumerRepository); task.execCommand(ExecCommandFactory.execCommand("Upgrading dependency", CloneGitRepositoryTaskFactory.getConsumerRepoCloneDir(project, consumerRepository), GradleWrapper.getWrapperCommand(), "performVersionUpgrade", getDependencyProperty(project))); } }); }
@Override public void apply(final Project project) { TaskMaker.task(project, INIT_TRAVIS_TASK, InitTravisTask.class, new Action<InitTravisTask>() { public void execute(InitTravisTask t) { t.setDescription("Creates '.travis.yml' file if not already present."); t.setOutputFile(new File(project.getRootDir(), ".travis.yml")); } }); TaskMaker.task(project, INIT_SHIPKIT_TASK, new Action<Task>() { public void execute(Task t) { t.setDescription("Initializes Shipkit"); t.dependsOn(INIT_TRAVIS_TASK); } }); //The user might configure the 'group' later, after the plugin is applied DeferredConfiguration.deferredConfiguration(project, new Runnable() { @Override public void run() { if (project.getGroup() == null) { LOG.info(" Gradle project does not have 'group' property configured yet." + "\n Shipkit is setting the group to 'org.shipkit.bootstrap' so that it has a reasonable default." + "\n It is recommended that you configure the 'group' to your choice."); project.setGroup("org.shipkit.bootstrap"); } } }); } }
private static void releaseNotesTasks(final Project project, final ReleaseConfiguration conf) { final ReleaseNotesFetcherTask releaseNotesFetcher = TaskMaker.task(project, FETCH_NOTES_TASK, ReleaseNotesFetcherTask.class, new Action<ReleaseNotesFetcherTask>() { public void execute(final ReleaseNotesFetcherTask t) { t.setDescription("Fetches release notes data from Git and GitHub and serializes them to a file"); t.setOutputFile(new File(project.getBuildDir(), "detailed-release-notes.ser")); t.setGitHubApiUrl(conf.getGitHub().getApiUrl()); t.setGitHubReadOnlyAuthToken(conf.getGitHub().getReadOnlyAuthToken()); t.setGitHubRepository(conf.getGitHub().getRepository()); t.setPreviousVersion(conf.getPreviousReleaseVersion()); t.setIgnoreCommitsContaining(conf.getReleaseNotes().getIgnoreCommitsContaining()); } }); final AllContributorsFetcherTask contributorsFetcher = (AllContributorsFetcherTask) project.getTasks().getByName(ContributorsPlugin.FETCH_ALL_CONTRIBUTORS_TASK); TaskMaker.task(project, UPDATE_NOTES_TASK, UpdateReleaseNotesTask.class, new Action<UpdateReleaseNotesTask>() { public void execute(final UpdateReleaseNotesTask t) { t.setDescription("Updates release notes file. Run with '-Ppreview' if you only want to see the preview."); configureDetailedNotes(t, releaseNotesFetcher, project, conf, contributorsFetcher); boolean previewMode = project.hasProperty(UpdateReleaseNotesTask.PREVIEW_PROJECT_PROPERTY); t.setPreviewMode(previewMode); if(!previewMode){ File releaseNotesFile = project.file(conf.getReleaseNotes().getFile()); GitPlugin.registerChangesForCommitIfApplied( Arrays.asList(releaseNotesFile), "release notes updated", t); t.getOutputs().file(releaseNotesFile); } } }); }
private static void releaseNotesTasks(final Project project, final ShipkitConfiguration conf) { final FetchReleaseNotesTask releaseNotesFetcher = TaskMaker.task(project, FETCH_NOTES_TASK, FetchReleaseNotesTask.class, new Action<FetchReleaseNotesTask>() { public void execute(final FetchReleaseNotesTask t) { t.setDescription("Fetches release notes data from Git and GitHub and serializes them to a file"); t.setOutputFile(new File(project.getBuildDir(), "detailed-release-notes.ser")); t.setGitHubApiUrl(conf.getGitHub().getApiUrl()); t.setGitHubReadOnlyAuthToken(conf.getGitHub().getReadOnlyAuthToken()); t.setGitHubRepository(conf.getGitHub().getRepository()); t.setPreviousVersion(conf.getPreviousReleaseVersion()); t.setTagPrefix(conf.getGit().getTagPrefix()); t.setIgnoreCommitsContaining(conf.getReleaseNotes().getIgnoreCommitsContaining()); t.setIgnoredContributors(conf.getTeam().getIgnoredContributors()); } }); final Task contributorsFetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS); TaskMaker.task(project, UPDATE_NOTES_TASK, UpdateReleaseNotesTask.class, new Action<UpdateReleaseNotesTask>() { public void execute(final UpdateReleaseNotesTask t) { t.setDescription("Updates release notes file. Run with '-Ppreview' if you only want to see the preview."); configureDetailedNotes(t, releaseNotesFetcher, project, conf, contributorsFetcher); boolean previewMode = project.hasProperty(PREVIEW_PROJECT_PROPERTY); t.setPreviewMode(previewMode); if (!previewMode) { File releaseNotesFile = project.file(conf.getReleaseNotes().getFile()); GitPlugin.registerChangesForCommitIfApplied( singletonList(releaseNotesFile), "release notes updated", t); t.getOutputs().file(releaseNotesFile); } } }); }