Skip to content

Commit

Permalink
new increment version ant script
Browse files Browse the repository at this point in the history
without using Javascript and by relying on hardcoded version properties
  • Loading branch information
LorenzoBettini committed Sep 3, 2020
1 parent 727a3d4 commit 8339a61
Showing 1 changed file with 20 additions and 57 deletions.
77 changes: 20 additions & 57 deletions edelta.parent/releng/releasing/increment_versions.ant
Original file line number Diff line number Diff line change
@@ -1,57 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="IncrementVersionsTask" basedir="." default="set-version">

<!-- Make sure this points to the root folder of your project -->
<property name="WORKSPACE" location="${ant.file}/../../../" />

<target name="show-workspace-path">
<echo message="WORKSPACE: ${WORKSPACE}" />
</target>

<target name="stripSnapshot">
<script language="javascript">
<![CDATA[
// getting the value
buildnumber = project.getProperty("project.version");
index = buildnumber.lastIndexOf("-SNAPSHOT");
counter = buildnumber.substring(0, index);
project.setProperty("version.main",counter);
]]>
</script>
</target>

<target name="getMajorMinorVersion">
<script language="javascript">
<![CDATA[
// getting the value
buildnumber = project.getProperty("version.main");
index = buildnumber.lastIndexOf(".");
counter = buildnumber.substring(0, index);
project.setProperty("majorMinorVersion",counter);
]]>
</script>
</target>
<!--Set these properties manually when increasing versions -->
<property name="version.major" value="2" />
<property name="version.minor" value="0" />
<property name="version.patch" value="1" />

<target name="test_stripSnapshot" depends="stripSnapshot">
<echo message="version.main: ${version.main}"/>
</target>
<!-- Compute the version properties -->
<property name="version.main" value="${version.major}.${version.minor}.${version.patch}" />
<property name="version.osgi" value="${version.main}.qualifier"/>
<property name="version.mvn" value="${version.main}-SNAPSHOT"/>
<property name="majorMinorVersion" value="${version.major}.${version.minor}" />

<target name="test_getMajorMinor" depends="getMajorMinorVersion">
<echo message="majorMinorVersion: ${majorMinorVersion}"/>
</target>

<target name="askVersion">
<input message="Please enter the new release version (MAJOR.MINOR.MICRO):" addproperty="version.main" defaultvalue="${version_main}" />
<target name="show-workspace-path">
<echo message="WORKSPACE: ${WORKSPACE}" />
</target>

<target name="retrieveMajorMinor" depends="askVersion,getMajorMinorVersion">
<target name="showVersionProperties" >
<echo message="WORKSPACE : ${WORKSPACE}" />
<echo message="version.main: ${version.main}" />
<echo message="version.osgi: ${version.osgi}" />
<echo message="version.mvn : ${version.mvn}" />
<echo message="majorMinorVersion: ${majorMinorVersion}"/>
</target>

<target name="set-version" description="Modifies artifacts to set a release version"
depends="retrieveMajorMinor" >
<target name="set-version" description="Modifies artifacts to set a release version" >
<property name="version.osgi" value="${version.main}.qualifier"/>
<property name="version.mvn" value="${version.main}-SNAPSHOT"/>

Expand All @@ -65,20 +41,6 @@
<antcall target="-modify-artifacts"/>
</target>

<!-- strip the -SNAPSHOT from the property project.version -->
<target name="set-version-release" depends="stripSnapshot" description="Modifies artifacts to set a release version (without -SNAPSHOT)" >
<property name="version.osgi" value="${version.main}"/>
<property name="version.mvn" value="${version.main}"/>

<echo message="VERSION MAIN: ${version.main}" />
<echo message="VERSION OSGI: ${version.osgi}" />
<echo message="VERSION MVN : ${version.mvn}" />
<echo message="WORKSPACE : ${WORKSPACE}" />
<echo message="" />

<antcall target="-modify-artifacts"/>
</target>

<target name="-modify-artifacts" if="version.main" >
<echo message="VERSION MAIN: ${version.main}" />
<echo message="VERSION OSGI: ${version.osgi}" />
Expand Down Expand Up @@ -106,6 +68,7 @@
</fileset>
</replaceregexp>

<!-- category.xml if major.minor is mentioned -->
<replaceregexp flags="g" byline="true">
<regexp pattern="label=&quot;(\w+)(\s+)(\d+\.\d+)(\.x)" />
<substitution expression="label=&quot;\1\2${majorMinorVersion}\4" />
Expand Down Expand Up @@ -146,7 +109,7 @@
</replaceregexp>

</target>

<target name="set-version-xtext" description="Sets the Xtext version constraints in MANIFEST.MF">
<!-- Read the last entered values for defaults -->
<property file="version.properties" />
Expand Down

0 comments on commit 8339a61

Please sign in to comment.