use of org.shipkit.gradle.version.BumpVersionFileTask 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");
}
}
});
}
use of org.shipkit.gradle.version.BumpVersionFileTask in project shipkit by mockito.
the class VersioningPlugin method apply.
public void apply(final Project project) {
final File versionFile = project.file(VERSION_FILE_NAME);
final VersionInfo versionInfo;
if (versionFile.isFile()) {
versionInfo = Version.versionInfo(versionFile);
LOG.lifecycle(" Building version '{}' (value loaded from '{}' file).", versionInfo.getVersion(), versionFile.getName());
} else {
versionInfo = Version.defaultVersionInfo(versionFile, project.getVersion().toString());
LOG.lifecycle(" Building version '{}'.", versionInfo.getVersion());
}
project.getExtensions().add(VersionInfo.class.getName(), versionInfo);
final String version = versionInfo.getVersion();
project.allprojects(new Action<Project>() {
@Override
public void execute(Project project) {
project.setVersion(version);
}
});
TaskMaker.task(project, BUMP_VERSION_FILE_TASK, BumpVersionFileTask.class, new Action<BumpVersionFileTask>() {
public void execute(final BumpVersionFileTask t) {
t.setDescription("Increments version number in " + versionFile.getName());
t.setVersionFile(versionFile);
String versionChangeMessage = formatVersionInformationInCommitMessage(version, versionInfo.getPreviousVersion());
GitPlugin.registerChangesForCommitIfApplied(singletonList(versionFile), versionChangeMessage, t);
}
});
}
Aggregations