<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Developers, Developers, Developers! &#187; versioning</title>
	<atom:link href="http://maksim.sorokin.dk/it/tag/versioning/feed/" rel="self" type="application/rss+xml" />
	<link>http://maksim.sorokin.dk/it</link>
	<description>Maksim Sorokin IT Blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:37:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Comparing Maven String Versions</title>
		<link>http://maksim.sorokin.dk/it/2011/04/03/comparing-maven-string-versions/</link>
		<comments>http://maksim.sorokin.dk/it/2011/04/03/comparing-maven-string-versions/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 22:12:28 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[versioning]]></category>
		<category><![CDATA[versions]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=692</guid>
		<description><![CDATA[This posts describes comparint Maven String versions. It is assumed, that you have a Maven-managed project. Add a maven-artifact dependency &#60;dependency&#62; &#60;groupId&#62;org.apache.maven&#60;/groupId&#62; &#60;artifactId&#62;maven-artifact&#60;/artifactId&#62; &#60;version&#62;3.0.3&#60;/version&#62; &#60;/dependency&#62; Then you could write something like this: public int compare(String version1, String version2) { ArtifactVersion mavenVersion1 = new DefaultArtifactVersion(version1); ArtifactVersion mavenVersion2 = new DefaultArtifactVersion(version2); int result = mavenVersion1.compareTo(mavenVersion2); return result; [...]]]></description>
			<content:encoded><![CDATA[<p>This posts describes comparint Maven String versions. It is assumed, that you have a Maven-managed project.</p>
<p>Add a <code>maven-artifact</code> dependency</p>
<pre class="brush: xml; title: ;">
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
  &lt;artifactId&gt;maven-artifact&lt;/artifactId&gt;
  &lt;version&gt;3.0.3&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>Then you could write something like this:</p>
<pre class="brush: java; title: ;">
public int compare(String version1, String version2) {
  ArtifactVersion mavenVersion1 = new DefaultArtifactVersion(version1);
  ArtifactVersion mavenVersion2 = new DefaultArtifactVersion(version2);

  int result = mavenVersion1.compareTo(mavenVersion2);

  return result;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2011/04/03/comparing-maven-string-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manifest Version &#8212; with or without qualifier?</title>
		<link>http://maksim.sorokin.dk/it/2010/12/23/manifest-version-with-or-without-qualifier/</link>
		<comments>http://maksim.sorokin.dk/it/2010/12/23/manifest-version-with-or-without-qualifier/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 08:03:42 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[manifest]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[tycho]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=465</guid>
		<description><![CDATA[Should MANIFEST.MF contain qualifier or not? That depends on what strategy you use in your development cycle. When you change a plugin a lot during development cycle, it is better to add append a qualifier to the end of the version. In this case, everytime you will build a plugin, it will have a timestamp [...]]]></description>
			<content:encoded><![CDATA[<p>Should MANIFEST.MF contain <code>qualifier</code> or not? That depends on what strategy you use in your development cycle. When you change a plugin a lot during development cycle, it is better to add append a <code>qualifier</code> to the end of the version. In this case, everytime you will build a plugin, it will have a timestamp added to the end of the filename, for example:</p>
<pre class="brush: plain; title: ;">
dk.sorokin.maksim.model_1.0.0.201012220948.jar
</pre>
<p>If you will not have a <code>qualifier</code>, it will always be the same jar name:</p>
<pre class="brush: plain; title: ;">
dk.sorokin.maksim.model_1.0.0.jar
</pre>
<p>In this case you may have some troubles. For example, when you run <a href="http://maksim.sorokin.dk/it/2010/11/26/creating-a-p2-repository-from-features-and-plugins/">FeaturesAndBundlesPublisher</a> with <code>-append</code> option. Since old and new bundle version have the same version (without added timestamp), old version will be preserved. In this case make sure to change the version of your MANIFEST.MF, when you make changes to the project without <code>qualifier</code>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/12/23/manifest-version-with-or-without-qualifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Providing Build Information Automatically for Every Maven Project</title>
		<link>http://maksim.sorokin.dk/it/2010/08/18/providing-build-information-automatically-for-every-maven-project/</link>
		<comments>http://maksim.sorokin.dk/it/2010/08/18/providing-build-information-automatically-for-every-maven-project/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 16:27:53 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=331</guid>
		<description><![CDATA[This article describes a possibility to automatically inject properties file with build information into any Maven module. Sometimes you need to provide version and build information in "About" dialog of the application. You can easily create a simple properties file in your resources folder and apply filtering on it, where build version and timestamp would [...]]]></description>
			<content:encoded><![CDATA[<p>This article describes a possibility to automatically inject properties file with build information into any Maven module.</p>
<p>Sometimes you need to provide version and build information in "About" dialog of the application. You can easily create a simple properties file in your resources folder and apply <a href="http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html">filtering</a> on it, where build version and timestamp would be automatically replaced on each maven build. But what to do when you have dozen of such project? Is there a way to do this automatically? Indeed, there is.</p>
<p>The idea is simple. We start by creating a Maven "template" project which would just hold a general build properties file. Then we create a parent project which would know how to intervene into a build cycle and inject build properties file. Then we simply inherit this parent project in all other projects which require such automatic build numbering injection.</p>
<p>As an example we will only<span id="more-331"></span> cover project version filtering. Build timestamp can be added easily.</p>
<p>We start by creating the Maven "template" project, which would hold the build properties file. We create a following <code>build.properties</code> file in <code>src/main/resources</code>:</p>
<pre class="brush: plain; title: ;">
project.version=${project.version}
</pre>
<p>Now, we need to create a parent project, which would know how to intervene into a build lifecycle. But first we need to find out when the resource are being filtered in Maven lifecycle. In <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">Official Maven Documentation</a> in "Default Lifecycle" section we see, that this is happening during <code>process-sources</code> goal. So we need to inject <code>build.properties</code> just before that.</p>
<p>In our parent project pom we define the following:</p>
<pre class="brush: xml; title: ;">
...
  &lt;build&gt;
    ...
    &lt;plugins&gt;
      ...

      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;unpack&lt;/id&gt;
            &lt;phase&gt;generate-resources&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;unpack&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
              &lt;artifactItems&gt;
                &lt;artifactItem&gt;
                  &lt;groupId&gt;company&lt;/groupId&gt;
                  &lt;artifactId&gt;TEMPLATE-PROJECT-ARTIFACT-NAME&lt;/artifactId&gt;
                  &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
                  &lt;includes&gt;build.properties&lt;/includes&gt;
                  &lt;outputDirectory&gt;${project.build.directory}/buildInfo&lt;/outputDirectory&gt;
                &lt;/artifactItem&gt;
              &lt;/artifactItems&gt;
            &lt;/configuration&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;

    &lt;resources&gt;
	  ...
      &lt;resource&gt;
        &lt;directory&gt;target/buildInfo&lt;/directory&gt;
        &lt;filtering&gt;true&lt;/filtering&gt;
      &lt;/resource&gt;
	  ...
    &lt;/resources&gt;
  &lt;/build&gt;
...
</pre>
<p>What it does, is intervenes into build lifecycle in <code>generate-resources</code> phase, just before when resources are filtered. It extracts <code>build.properties</code> file from Maven "template" project into <code>buildInfo</code> folder. Then this <code>build.properties</code> file is being filtered and<br />
included into deliverable.<br />
That is it! If this parent project is inherited in other projects, <code>build.properties</code> file will be automatically filtered and added during Maven build.</p>
<p>Furthermore, we can create another project, which would know how to parse this build file. And include this parsing project as a dependency where it is needed. So we would not need to write the same build properties file parsing logic again and again.</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/08/18/providing-build-information-automatically-for-every-maven-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven Versioning Problems Having Different Purpose Modules Under One Parent</title>
		<link>http://maksim.sorokin.dk/it/2010/08/14/maven-versioning-problems-having-different-purpose-modules-under-one-parent/</link>
		<comments>http://maksim.sorokin.dk/it/2010/08/14/maven-versioning-problems-having-different-purpose-modules-under-one-parent/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 17:57:15 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=319</guid>
		<description><![CDATA[If you have modules with different purpose, you eventually hit the versioning problem. When you change only one module and want to make a release, usually you go for parent project release, since otherwise there will be a mess having modules with different numbers. But another module was not changed! But the versioning number was [...]]]></description>
			<content:encoded><![CDATA[<p>If you have modules with different purpose, you eventually hit the versioning problem.</p>
<p>When you change only one module and want to make a release, usually you go for parent project release, since otherwise there will be a mess having modules with different numbers. But another module was not changed! But the versioning number was increased.</p>
<p>Here is live example. You have a maven project. Then, you introduce an<span id="more-319"></span> installer for it, which is also built with maven. You make this installer module a part of your application. But application installer and application itself serve for different purposes. When you fix a problem in the installer and release it, the versioning number of your application is also increased (if you go for the same versioning in the project).</p>
<p>The solution is simple. If you have modules which have different purposes, they should be contained in different parent projects. Or, as an alternavitve, if you are not afraid of different numbering of modules, you still can have different purpose modules under one parent.</p>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/08/14/maven-versioning-problems-having-different-purpose-modules-under-one-parent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Product Versioning With Maven</title>
		<link>http://maksim.sorokin.dk/it/2010/02/07/product-versioning-with-maven/</link>
		<comments>http://maksim.sorokin.dk/it/2010/02/07/product-versioning-with-maven/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 16:17:23 +0000</pubDate>
		<dc:creator>Maksim Sorokin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://maksim.sorokin.dk/it/?p=32</guid>
		<description><![CDATA[Each mavenized project has its own version. Sometimes it is useful to have access to the project version from the code. For instance, display project version in the about box or on the info page. Here is the way to do that. Under src/main/resources create project.properties file: version=${project.version} In the pom.xml enable filtering: &#60;build&#62; ... [...]]]></description>
			<content:encoded><![CDATA[<p>Each mavenized project has its own version. Sometimes it is useful to have access to the project version from the code. For instance, display project version in the about box or on the info page.</p>
<p>Here is the way to do that.<span id="more-32"></span></p>
<p>Under <code>src/main/resources</code> create <code>project.properties</code> file:</p>
<pre class="brush: plain; title: ;">version=${project.version}</pre>
<p>In the <code>pom.xml</code> enable filtering:</p>
<pre class="brush: xml; title: ;">&lt;build&gt;
  ...
  &lt;resources&gt;
    &lt;resource&gt;
      &lt;directory&gt;src/main/resources&lt;/directory&gt;
      &lt;filtering&gt;true&lt;/filtering&gt;
    &lt;/resource&gt;
  &lt;/resources&gt;
  ...
&lt;/build&gt;
</pre>
<p>And all you have to do is access <code>project.properties</code> file from your code.</p>
<p>Moreover, you can add other properties such as project name and build time.<br />
To add name of the project add following to <code>project.properties</code>:</p>
<pre class="brush: plain; title: ;">name=${project.name}</pre>
<p>To add build time in the <code>pom.xml</code> add:</p>
<pre class="brush: xml; title: ;">
&lt;project&gt;
  ...
  &lt;properties&gt;
    &lt;maven.build.timestamp.format&gt;yyyy MMM dd HH:mm&lt;/maven.build.timestamp.format&gt;
    &lt;buildTimestamp&gt;${maven.build.timestamp}&lt;/buildTimestamp&gt;
  &lt;/properties&gt;
  ...
&lt;/project&gt;
</pre>
<p>And in the <code>project.properties</code> add:</p>
<pre class="brush: plain; title: ;">buildTimestamp=${buildTimestamp}</pre>
]]></content:encoded>
			<wfw:commentRss>http://maksim.sorokin.dk/it/2010/02/07/product-versioning-with-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

