use of org.shipkit.gradle.init.InitTravisTask in project shipkit by mockito.
the class InitPlugin method apply.
@Override
public void apply(final Project project) {
project.getPlugins().apply(VersioningPlugin.class);
project.getPlugins().apply(ShipkitConfigurationPlugin.class);
final GitOriginPlugin gitOriginPlugin = project.getRootProject().getPlugins().apply(GitOriginPlugin.class);
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"));
}
});
final BumpVersionFileTask bump = (BumpVersionFileTask) project.getTasks().getByName(VersioningPlugin.BUMP_VERSION_FILE_TASK);
TaskMaker.task(project, INIT_VERSIONING_TASK, InitVersioningTask.class, new Action<InitVersioningTask>() {
@Override
public void execute(InitVersioningTask t) {
t.setDescription("Creates version.properties file if it doesn't exist");
t.setVersionFile(bump.getVersionFile());
}
});
TaskMaker.task(project, INIT_SHIPKIT_FILE_TASK, InitShipkitFileTask.class, new Action<InitShipkitFileTask>() {
@Override
public void execute(final InitShipkitFileTask t) {
final File shipkitFile = ShipkitConfigurationPlugin.getShipkitFile(project);
t.setDescription("Creates Shipkit configuration file unless it already exists");
t.setShipkitFile(shipkitFile);
gitOriginPlugin.provideOriginRepo(t, new Action<String>() {
public void execute(String originRepo) {
t.setOriginRepoName(originRepo);
}
});
}
});
TaskMaker.task(project, INIT_SHIPKIT_TASK, new Action<Task>() {
public void execute(Task t) {
t.setDescription("Initializes Shipkit");
t.dependsOn(INIT_TRAVIS_TASK, INIT_VERSIONING_TASK, INIT_SHIPKIT_FILE_TASK);
t.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
LOG.lifecycle(" Initialization complete. Thank you for using Shipkit!\n" + " Please review generated files before checking them in.\n" + " Guide: https://github.com/mockito/shipkit/blob/master/docs/getting-started.md");
}
});
}
});
// 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");
}
}
});
}
Aggregations