Refactoring
Prepared the plugin for better reusability
@@ -18,10 +18,9 @@ public class DefaultVersioningPlugin implements VersioningPlugin {
private static Logger LOG = Logging.getLogger(DefaultVersioningPlugin.class);
public void apply(Project project) {
- File versionFile = project.file("version.properties");
- final String version;
-
+ final File versionFile = getVersionFile(project);
ExtraPropertiesExtension ext = project.getExtensions().getExtraProperties();
+ final String version;
if (ext.has("release_version")) {
version = ext.get("release_version").toString();
LOG.lifecycle(" Using version '{}' supplied via 'release_version' project property.", version);
@@ -37,9 +36,17 @@ public class DefaultVersioningPlugin implements VersioningPlugin {
}
});
- BumpVersionFileTask task = project.getTasks().create("bumpVersionFile", DefaultBumpVersionFileTask.class);
- task.setVersionFile(versionFile);
- task.setDescription("Increments version number in the properties file that contains the version.");
- task.setGroup(TASK_GROUP);
+ project.getTasks().create("bumpVersionFile", DefaultBumpVersionFileTask.class, new Action<DefaultBumpVersionFileTask>() {
+ public void execute(DefaultBumpVersionFileTask t) {
+ t.setVersionFile(versionFile);
+ t.setDescription("Increments version number in " + versionFile.getName());
+ t.setGroup(TASK_GROUP);
+ }
+ });
+ }
+
+ public static File getVersionFile(Project project) {
+ //TODO should add singleton extension object to root project with version object
+ return new File(project.getRootDir(), "version.properties");
}
}
\ No newline at end of file
