readd assertReleaseNeeded task
@@ -34,21 +34,32 @@ import org.shipkit.internal.gradle.util.TaskMaker;
* Adds following tasks:
*
* <ul>
+ * <li>assertReleaseNeeded - {@link ReleaseNeededTask}
+ * - checks if release is needed and fails the build if not needed. Used in release process.</li>
* <li>releaseNeeded - {@link ReleaseNeededTask}
* - prints information if the release is needed. Useful for testing.</li>
* </ul>
*/
public class ReleaseNeededPlugin implements Plugin<Project> {
+ public final static String ASSERT_RELEASE_NEEDED_TASK = "assertReleaseNeeded";
public final static String RELEASE_NEEDED = "releaseNeeded";
@Override
public void apply(Project project) {
final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
+ //Task that throws an exception when release is not needed is very useful for CI workflows
+ //Travis CI job will stop executing further commands if assertReleaseNeeded fails.
+ //See the example projects how we have set up the 'assertReleaseNeeded' task in CI pipeline.
+ releaseNeededTask(project, ASSERT_RELEASE_NEEDED_TASK, conf)
+ .setExplosive(true)
+ .setDescription("Asserts that criteria for the release are met and throws exception if release is not needed.");
+
//Below task is useful for testing. It will not throw an exception but will run the code that check is release is needed
//and it will print the information to the console.
releaseNeededTask(project, RELEASE_NEEDED, conf)
+ .setExplosive(false)
.setDescription("Checks and prints to the console if criteria for the release are met.");
}
@@ -57,6 +68,7 @@ public class ReleaseNeededPlugin implements Plugin<Project> {
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.");
+ t.setExplosive(true);
project.allprojects(new Action<Project>() {
public void execute(final Project subproject) {
