-
Notifications
You must be signed in to change notification settings - Fork 8
Batch File Usage
The Snapshere Khan batch files use an easy command language to automate large versioning tasks. It is a plain text format and the files contain one operation per line. Technically, the extension of the batch files is irrelevant, but if you want them to be recognized by the Eclipse plugin, you need to set the extension as .versiontool.
This is a small example:
# sample.versiontool
# Add projects to universe
project /home/me/workspace/com.inventage.project.plugin
project /home/me/workspace/com.inventage.project.depending_plugin1
project /home/me/workspace/com.inventage.project.depending_plugin2
# Release plugin, dependencies get updated automatically
release com.inventage.project.plugin
As you can observe, we use the hash ('#') as comment prefix. In the example above three projects are added to the (implicit) universe while we assume that 'depending_plugin1' and 'depending_plugin2' have dependencies on the 'plugin'. We then release the 'plugin' by calling the respective command, followed by the artifact id. Since we added the depending projects to the universe, all references to the 'plugin' get updated as well.
This is a presentation of the available commands. They can be used in batch files as well as in the interactive mode. You can also get a list of them by typing help in the interactive mode.
Adds the project at the provided file system path to the ad hoc universe. Every instance of the Snapshere Khan forms its own universe.
Example
project /home/me/workspace/com.inventage.project.plugin
Updates the version in the projects matching the provided id pattern (use '*' as wildcard) to the provided one. Also updates all dependencies in the universe. The version has to be of the OSGI version format: n[.n[.n]][-SNAPSHOT].
Example
project /home/me/workspace/com.inventage.project.plugin
version com.inventage.project.* 1.2.3-SNAPSHOT
Updates the version in the projects matching the provided id pattern (use '*' as wildcard) to the next major snapshot. Also updates all dependencies in the universe.
Example
project /home/me/workspace/com.inventage.project.plugin
incrementMajor com.inventage.project.plugin
Updates the version in the projects matching the provided id pattern (use '*' as wildcard) to the next minor snapshot. Also updates all dependencies in the universe.
Example
project /home/me/workspace/com.inventage.project.plugin
incrementMinor com.inventage.project.plugin
Updates the version in the projects matching the provided id pattern (use '*' as wildcard) to the next bugfix snapshot. Also updates all dependencies in the universe.
Example
project /home/me/workspace/com.inventage.project.plugin
incrementBugfix com.inventage.project.plugin
Updates the version in the projects matching the provided id pattern (use '*' as wildcard) to the release, that is, removing any snapshot qualifiers. Also updates all dependencies in the universe.
Example
project /home/me/workspace/com.inventage.project.plugin
release com.inventage.project.plugin
Updates the version in the projects matching the provided id pattern (use '*' as wildcard) to the snapshot, that is, adding snapshot qualifiers, if needed. Also updates all dependencies in the universe.
Example
project /home/me/workspace/com.inventage.project.plugin
snapshot com.inventage.project.plugin
Searches in the universe for occurrences of the stated project (or, projects if there are more than one matches). If the occurrences match the current version of the stated project, their reference versions are updated to the provided version.
Example
project /home/me/workspace/com.inventage.project.plugin
project /home/me/workspace/com.inventage.project.depending_plugin1
project /home/me/workspace/com.inventage.project.depending_plugin2
updateReferences com.inventage.project.plugin 1.2.3
Includes the batch file found at the provided path and executes it in the context of the current batch file.
Example
Contents of release.versiontool:
project /home/me/workspace/com.inventage.project.plugin
Contents of another file:
include /home/me/workspace/tools/release.versiontool
snapshot com.inventage.project.plugin
Writes a property into the POM file of the provided project. Besides arbitrary strings for the key and value you may also use the following variables which wrap properties of other projects in the universe.
The version of an artifact in the Maven format:
${version:my.artifact.id}
The version of an artifact in the OSGI format:
${osgiVersion:my.artifact.id}
Examples
project /home/me/workspace/com.inventage.project.plugin
property com.inventage.project.plugin myProperty myContent
The (simplified) POM file of the artifact has the following contents afterwards:
<project>
<artifactId>com.inventage.project.plugin</artifactId>
<version>1.2.3-SNAPSHOT</version>
<properties>
<myProperty>myContent</myProperty>
</properties>
</project>
The use of the internal variables are demonstrated with this simple example:
project /home/me/workspace/com.inventage.project.other_plugin
version com.inventage.project.other_plugin 0.0.3
project /home/me/workspace/com.inventage.project.plugin
property com.inventage.project.plugin otherPluginVersion ${version:com.inventage.project.other_plugin}
The (simplified) POM file of the artifact has the following contents afterwards:
<project>
<artifactId>com.inventage.project.plugin</artifactId>
<version>1.2.3-SNAPSHOT</version>
<properties>
<otherPluginVersion>0.0.3</otherPluginVersion>
</properties>
</project>
The following sample uses a project scenario which needs to release and snapshot from time to time. The respective commands are placed in two distinct .versiontool files which can be called on demand.
Contents of the file projects.versiontool:
project ./../service/my.plugin1
project ./../service/my.plugin2
project ./../server/my.plugin3
project ./../server/my.plugin4
project ./../server/my.plugin5
project ./../client/my.plugin6
project ./../client/my.plugin7
# ...
Contents of the file release.versiontool:
my.plugin1 release
my.plugin2 release
my.plugin3 release
my.plugin4 release
my.plugin5 release
my.plugin6 release
my.plugin7 release
# ...
Contents of the file snapshot.versiontool:
my.plugin1 snapshot
my.plugin2 snapshot
my.plugin3 snapshot
my.plugin4 snapshot
my.plugin5 snapshot
my.plugin6 snapshot
my.plugin7 snapshot
# ...
To release, you now can call the following command from a project directory:
$ java -jar snapshere-khan-cli.jar release.versiontool
Analogous, call the following for snapshotting the project:
$ java -jar snapshere-khan-cli.jar snapshot.versiontool