Skip to content

Commit 06765bf

Browse files
committed
Merge pull request scala#271 from jsuereth/2.9.x-version-fixin
2.9.x version fixin
2 parents 125b503 + 243c629 commit 06765bf

File tree

11 files changed

+206
-55
lines changed

11 files changed

+206
-55
lines changed

build.number

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#Tue Sep 11 19:21:09 CEST 2007
2+
version.major=2
23
version.minor=9
34
version.patch=2
4-
version.suffix=alpha
5-
version.major=2
5+
# This is the -N part of a version. if it's 0, it's dropped from maven versions.
6+
version.bnum=0
7+
8+
# Note: To build a release run ant with -Dbuild.release=true
9+
# To build an RC, run ant with -Dmaven.version.suffix=-RCN

build.xml

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ PROPERTIES
154154

155155
<!-- Loads custom properties definitions -->
156156
<property file="${basedir}/build.properties"/>
157+
<!-- Generating version number -->
158+
<property file="${basedir}/build.number"/>
157159

158160
<!-- Additional command line arguments for scalac. They are added to all build targets -->
159161
<property name="scalac.args" value=""/>
@@ -211,7 +213,30 @@ INITIALISATION
211213
<exec osfamily="windows" vmlauncher="false" executable="pull-binary-libs.sh" failifexecutionfails="true" />
212214
</target>
213215

214-
<target name="init" depends="init.starr">
216+
<!-- Determines OSGi string + maven extension. -->
217+
<target name="init.hasbuildnum">
218+
<condition property="version.hasbuildnum">
219+
<not><equals arg1="${version.bnum}" arg2="0"/></not>
220+
</condition>
221+
</target>
222+
<target name="init.build.snapshot" unless="build.release">
223+
<property name="maven.version.suffix" value="-SNAPSHOT"/>
224+
</target>
225+
<target name="init.build.release" if="build.release" depends="init.hasbuildnum, init.build.snapshot">
226+
<property name="maven.version.suffix" value=""/>
227+
</target>
228+
<target name="init.build.nopatch.release" unless="version.hasbuildnum" depends="init.hasbuildnum">
229+
<property name="version.suffix" value=""/>
230+
</target>
231+
<!-- funny thing, ant is. Can only specify *one* property in if check. Guaranteed that both are true here,
232+
since properties are immutable. -->
233+
<target name="init.build.patch.release" if="version.hasbuildnum" depends="init.build.nopatch.release">
234+
<property name="version.suffix" value="-${version.bnum}"/>
235+
</target>
236+
237+
<target name="init.build.suffix.done" depends="init.build.release, init.build.patch.release"/>
238+
239+
<target name="init" depends="init.starr, init.build.suffix.done">
215240
<!-- scalac.args.optimise is selectively overridden in certain antcall tasks. -->
216241
<property name="scalac.args.optimise" value=""/>
217242
<!-- scalac.args.quickonly are added to quick.* targets but not others (particularly, locker.)
@@ -231,20 +256,28 @@ INITIALISATION
231256
<os family="windows"/>
232257
</condition>
233258

234-
<exec osfamily="unix" executable="tools/get-scala-revision" outputproperty="git.describe" failifexecutionfails="false" />
235-
<exec osfamily="windows" executable="tools/get-scala-revision.bat" outputproperty="git.describe" failifexecutionfails="false" />
259+
<exec osfamily="unix" executable="tools/get-scala-commit-sha" outputproperty="git.commit.sha" failifexecutionfails="false" />
260+
<exec osfamily="windows" executable="tools/get-scala-commit-sha.bat" outputproperty="git.commit.sha" failifexecutionfails="false" />
261+
<exec osfamily="unix" executable="tools/get-scala-commit-date" outputproperty="git.commit.date" failifexecutionfails="false" />
262+
<exec osfamily="windows" executable="tools/get-scala-commit-date.bat" outputproperty="git.commit.date" failifexecutionfails="false" />
263+
<exec osfamily="unix" executable="tools/get-scala-commit-drift" outputproperty="git.commit.drift" failifexecutionfails="false" />
264+
<exec osfamily="windows" executable="tools/get-scala-commit-drift.bat" outputproperty="git.commit.drift" failifexecutionfails="false" />
236265
<!-- some default in case something went wrong getting the revision -->
237266
<property name="git.describe" value="-unknown-"/>
238267

239268
<property name="init.avail" value="yes"/>
240269

241-
<!-- Generating version number -->
242-
<property file="${basedir}/build.number"/>
243-
<!-- As of git move, we set the internal version number based on how far from tags we are, which includes a version tag. we keep
244-
major/minor etc. for the maven deploy. -->
270+
<!-- We use the git describe to determine the OSGi modifier for our build. -->
271+
<property
272+
name="maven.version.number"
273+
value="${version.major}.${version.minor}.${version.patch}${version.suffix}${maven.version.suffix}"/>
245274
<property
246275
name="version.number"
247-
value="${git.describe}"/>
276+
value="${maven.version.number}-${git.commit.date}-${git.commit.drift}-${git.commit.sha}"/>
277+
<property
278+
name="osgi.version.number"
279+
value="${version.major}.${version.minor}.${version.patch}.v${git.commit.date}${version.suffix}-${git.commit.sha}"/>
280+
248281

249282
<!-- Local libs (developer use.) -->
250283
<mkdir dir="${lib-extra.dir}"/>
@@ -274,7 +307,9 @@ INITIALISATION
274307
<echo message=" java args: ${env.ANT_OPTS} ${jvm.opts}" />
275308
<echo message=" javac args: ${javac.args}" />
276309
<echo message=" scalac args: ${scalac.args}" />
277-
<echo message=" build number: ${version.number}" />
310+
<echo message=" maven version: ${maven.version.number}"/>
311+
<echo message=" OSGi version: ${osgi.version.number}" />
312+
<echo message="canonical version: ${version.number}" />
278313

279314
<!-- Define tasks that can be run with Starr -->
280315
<path id="starr.classpath">
@@ -341,6 +376,8 @@ LOCAL REFERENCE BUILD (LOCKER)
341376
</scalacfork>
342377
<propertyfile file="${build-locker.dir}/classes/library/library.properties">
343378
<entry key="version.number" value="${version.number}"/>
379+
<entry key="maven.version.number" value="${maven.version.number}"/>
380+
<entry key="osgi.version.number" value="${osgi.version.number}"/>
344381
<entry key="copyright.string" value="${copyright.string}"/>
345382
</propertyfile>
346383
<copy todir="${build-locker.dir}/classes/library">
@@ -380,6 +417,8 @@ LOCAL REFERENCE BUILD (LOCKER)
380417
</scalacfork>
381418
<propertyfile file="${build-locker.dir}/classes/compiler/compiler.properties">
382419
<entry key="version.number" value="${version.number}"/>
420+
<entry key="maven.version.number" value="${maven.version.number}"/>
421+
<entry key="osgi.version.number" value="${osgi.version.number}"/>
383422
<entry key="copyright.string" value="${copyright.string}"/>
384423
</propertyfile>
385424
<copy todir="${build-locker.dir}/classes/compiler">
@@ -536,6 +575,8 @@ QUICK BUILD (QUICK)
536575
</scalacfork>
537576
<propertyfile file="${build-quick.dir}/classes/library/library.properties">
538577
<entry key="version.number" value="${version.number}"/>
578+
<entry key="maven.version.number" value="${maven.version.number}"/>
579+
<entry key="osgi.version.number" value="${osgi.version.number}"/>
539580
<entry key="copyright.string" value="${copyright.string}"/>
540581
</propertyfile>
541582
<copy todir="${build-quick.dir}/classes/library">
@@ -595,6 +636,8 @@ QUICK BUILD (QUICK)
595636
</scalacfork>
596637
<propertyfile file="${build-quick.dir}/classes/compiler/compiler.properties">
597638
<entry key="version.number" value="${version.number}"/>
639+
<entry key="maven.version.number" value="${maven.version.number}"/>
640+
<entry key="osgi.version.number" value="${osgi.version.number}"/>
598641
<entry key="copyright.string" value="${copyright.string}"/>
599642
</propertyfile>
600643
<copy todir="${build-quick.dir}/classes/compiler">
@@ -1069,6 +1112,8 @@ BOOTSTRAPPING BUILD (STRAP)
10691112
</scalacfork>
10701113
<propertyfile file="${build-strap.dir}/classes/library/library.properties">
10711114
<entry key="version.number" value="${version.number}"/>
1115+
<entry key="maven.version.number" value="${maven.version.number}"/>
1116+
<entry key="osgi.version.number" value="${osgi.version.number}"/>
10721117
<entry key="copyright.string" value="${copyright.string}"/>
10731118
</propertyfile>
10741119
<copy todir="${build-strap.dir}/classes/library">
@@ -1108,6 +1153,8 @@ BOOTSTRAPPING BUILD (STRAP)
11081153
</scalacfork>
11091154
<propertyfile file="${build-strap.dir}/classes/compiler/compiler.properties">
11101155
<entry key="version.number" value="${version.number}"/>
1156+
<entry key="maven.version.number" value="${maven.version.number}"/>
1157+
<entry key="osgi.version.number" value="${osgi.version.number}"/>
11111158
<entry key="copyright.string" value="${copyright.string}"/>
11121159
</propertyfile>
11131160
<copy todir="${build-strap.dir}/classes/compiler">

src/build/maven/maven-deploy.xml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
<property name="local.release.repository" value="${user.home}/.m2/repository" />
1717
<property name="repository.credentials.id" value="sonatype-nexus" />
1818
<property name="settings.file" value="${user.home}/.m2/settings.xml" />
19-
19+
<condition property="version.is.snapshot">
20+
<contains string="${maven.version.number}" substring="-SNAPSHOT"/>
21+
</condition>
22+
2023
<echo>Using server[${repository.credentials.id}] for maven repository credentials.
2124
Please make sure that your ~/.m2/settings.xml has the needed username/password for this server id
2225
</echo>
26+
27+
2328
</target>
2429

2530
<target name="init.maven" depends="init.properties">
@@ -241,28 +246,31 @@
241246
</target>
242247

243248
<!-- Local Targets -->
244-
<target name="deploy.snapshot.local" depends="deploy.local.init" description="Deploys the bundled snapshot of the Scala Lanaguage to a local maven repository">
245-
<deploy-local-all version="${maven.snapshot.version.number}" repository="${local.snapshot.repository}" />
249+
<target name="deploy.snapshot.local" depends="deploy.local.init" if="version.is.snapshot" description="Deploys the bundled snapshot of the Scala Lanaguage to a local maven repository">
250+
<deploy-local-all version="${maven.version.number}" repository="${local.snapshot.repository}" />
246251
</target>
247252

248-
<target name="deploy.release.local" depends="deploy.local.init" description="Deploys the bundled files as a release into the local Maven repository">
249-
<deploy-local-all version="${version.number}" repository="${local.release.repository}" />
253+
<target name="deploy.release.local" depends="deploy.local.init" unless="version.is.snapshot" description="Deploys the bundled files as a release into the local Maven repository">
254+
<deploy-local-all version="${maven.version.number}" repository="${local.release.repository}" />
250255
</target>
256+
<target name="deploy.local" depends="deploy.snapshot.local, deploy.release.local" description="Deploys the bundle files to the local maven repo."/>
251257

252-
<!-- Remote Targets -->
253-
<target name="deploy.signed.snapshot" depends="deploy.remote.init" description="Deploys the bundled files as a snapshot into the desired remote Maven repository">
254-
<deploy-remote-signed-all version="${maven.snapshot.version.number}" repository="${remote.snapshot.repository}" />
258+
<!-- Remote Signed Targets -->
259+
<target name="deploy.signed.snapshot" depends="deploy.remote.init" if="version.is.snapshot" description="Deploys the bundled files as a snapshot into the desired remote Maven repository">
260+
<deploy-remote-signed-all version="${maven.version.number}" repository="${remote.snapshot.repository}" />
255261
</target>
256262

257-
<target name="deploy.signed.release" depends="deploy.remote.init" description="Deploys the bundled files as a release into the desired remote Maven repository">
258-
<deploy-remote-signed-all version="${version.number}" repository="${remote.release.repository}" />
263+
<target name="deploy.signed.release" depends="deploy.remote.init" unless="version.is.snapshot" description="Deploys the bundled files as a release into the desired remote Maven repository">
264+
<deploy-remote-signed-all version="${maven.version.number}" repository="${remote.release.repository}" />
259265
</target>
260-
261-
<target name="deploy.snapshot" depends="deploy.remote.init" description="Deploys the bundled files as a snapshot into the desired remote Maven repository">
262-
<deploy-remote-all version="${maven.snapshot.version.number}" repository="${remote.snapshot.repository}" />
266+
<target name="deploy.signed" depends="deploy.signed.release, deploy.signed.snapshot" description="Deploys signed bundles to remote repo"/>
267+
<!-- Remote unsigned targets -->
268+
<target name="deploy.snapshot" depends="deploy.remote.init" if="version.is.snapshot" description="Deploys the bundled files as a snapshot into the desired remote Maven repository">
269+
<deploy-remote-all version="${maven.version.number}" repository="${remote.snapshot.repository}" />
263270
</target>
264271

265-
<target name="deploy.release" depends="deploy.remote.init" description="Deploys the bundled files as a release into the desired remote Maven repository">
266-
<deploy-remote-all version="${version.number}" repository="${remote.release.repository}" />
272+
<target name="deploy.release" depends="deploy.remote.init" unless="version.is.snapshot" description="Deploys the bundled files as a release into the desired remote Maven repository">
273+
<deploy-remote-all version="${maven.version.number}" repository="${remote.release.repository}" />
267274
</target>
275+
<target name="deploy" depends="deploy.snapshot, deploy.release" description="Deploys unsigned artifacts to the maven repo."/>
268276
</project>

src/build/pack.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ MAIN DISTRIBUTION SBAZ
309309
<copy tofile="${dists.dir}/maven/${version.number}/build.xml"
310310
file="${src.dir}/build/maven/maven-deploy.xml"/>
311311
<!-- export properties for use when deploying -->
312-
<property name="maven.snapshot.version.number"
313-
value="${version.major}.${version.minor}.${version.patch}-SNAPSHOT"/>
314312
<echoproperties destfile="${dists.dir}/maven/${version.number}/build.properties"/>
315313
</target>
316314

src/library/scala/util/Properties.scala

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ private[scala] trait PropertiesTrait {
6767
* it is an RC, Beta, etc. or was built from source, or if the version
6868
* cannot be read.
6969
*/
70-
val releaseVersion = scalaPropOrNone("version.number") flatMap { s =>
71-
val segments = s split '.'
72-
if (segments.size == 4 && segments.last == "final") Some(segments take 3 mkString ".") else None
73-
}
70+
val releaseVersion =
71+
for {
72+
v <- scalaPropOrNone("maven.version.number")
73+
if !(v endsWith "-SNAPSHOT")
74+
} yield v
7475

7576
/** The development scala version, if this is not a final release.
7677
* The precise contents are not guaranteed, but it aims to provide a
@@ -80,15 +81,12 @@ private[scala] trait PropertiesTrait {
8081
* @return Some(version) if this is a non-final version, None if this
8182
* is a final release or the version cannot be read.
8283
*/
83-
val developmentVersion = scalaPropOrNone("version.number") flatMap { s =>
84-
val segments = s split '.'
85-
if (segments.isEmpty || segments.last == "final")
86-
None
87-
else if (segments.last startsWith "r")
88-
Some(s takeWhile (ch => ch != '-')) // Cutting e.g. 2.10.0.r24774-b20110417125606 to 2.10.0.r24774
89-
else
90-
Some(s)
91-
}
84+
val developmentVersion =
85+
for {
86+
v <- scalaPropOrNone("maven.version.number")
87+
if v endsWith "-SNAPSHOT"
88+
ov <- scalaPropOrNone("version.number")
89+
} yield ov
9290

9391
/** The version number of the jar this was loaded from plus "version " prefix,
9492
* or "version (unknown)" if it cannot be determined.

tools/get-scala-commit-date

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage: get-scala-commit-date [dir]
4+
# Figures out current commit date of a git clone.
5+
# If no dir is given, current working dir is used.
6+
#
7+
# Example build version string:
8+
# 20120312
9+
#
10+
11+
[[ $# -eq 0 ]] || cd "$1"
12+
13+
lastcommitdate=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 1)
14+
15+
# 20120324
16+
echo "${lastcommitdate//-/}"

tools/get-scala-commit-date.bat

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@echo off
2+
rem
3+
rem Usage: get-scala-revison.bat [dir]
4+
rem Figures out current scala commit date of a git clone.
5+
rem
6+
rem If no dir is given, current working dir is used.
7+
8+
@setlocal
9+
set _DIR=
10+
if "%*"=="" (
11+
for /f "delims=;" %%i in ('cd') do set "_DIR=%%i"
12+
) else (
13+
set "_DIR=%~1"
14+
)
15+
cd %_DIR%
16+
17+
rem TODO - Check with a real windows user that this works!
18+
if exist .git\NUL (
19+
for /f "tokens=1delims= " in ('git log --format="%ci" -1') do set commitdate=%%a
20+
echo %commitdate%
21+
)
22+
23+
:end
24+
@endlocal

tools/get-scala-commit-drift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Usage: get-scala-commit-drift [dir]
4+
# Figures out current commit drift of a git clone.
5+
# If no dir is given, current working dir is used.
6+
#
7+
# Example output string:
8+
# 123
9+
#
10+
# Build drift = # of commits since last tag.
11+
12+
[[ $# -eq 0 ]] || cd "$1"
13+
14+
ensure_tag () {
15+
sha=$1
16+
rev=$2
17+
18+
[[ -n $(git tag -l $rev) ]] || {
19+
git tag -a -m "generated by get-scala-revision" $rev $sha
20+
}
21+
}
22+
23+
# Ensure some baseline tags are present so if this repository's
24+
# tags are screwed up or stale, we should still have a reference
25+
# point for a build string.
26+
ensure_tag 58cb15c40d v2.10.0-M1
27+
ensure_tag 29f3eace1e v2.9.1
28+
ensure_tag b0d78f6b9c v2.8.2
29+
30+
# the closest tag, obtained separately because we have to
31+
# reconstruct the string around the padded distance.
32+
tag=$(git describe --tags --match 'v2*' --abbrev=0)
33+
34+
# printf %016s is not portable for 0-padding, has to be a digit.
35+
# so we're stuck disassembling it.
36+
described=$(git describe --tags --match 'v2*' --abbrev=10)
37+
suffix="${described##${tag}-}"
38+
counter=$(echo $suffix | cut -d - -f 1)
39+
40+
echo "$counter"
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22
rem
3-
rem Usage: get-scala-revison.bat [dir]
4-
rem Figures out current scala revision of a git clone.
3+
rem Usage: get-scala-commit-drift.bat [dir]
4+
rem Figures out current scala commit drift, of a clone.
55
rem
66
rem If no dir is given, current working dir is used.
77

@@ -14,9 +14,8 @@ if "%*"=="" (
1414
)
1515
cd %_DIR%
1616

17-
if exist .git\NUL (
18-
git describe HEAD --abbrev=7 --match dev
19-
)
17+
rem TODO - WRITE THIS
18+
echo "TODO"
2019

2120
:end
2221
@endlocal

tools/get-scala-revision renamed to tools/get-scala-commit-sha

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
22
#
3-
# Usage: get-scala-revision [dir]
4-
# Figures out current scala revision of a git clone.
3+
# Usage: get-scala-commit-sha [dir]
4+
# Figures out current commit sha of a git clone.
55
# If no dir is given, current working dir is used.
66
#
77
# Example build version string:
8-
# v2.10.0-M1-0098-g6f1c486d0b-2012-02-01
8+
# 6f1c486d0ba
99
#
1010

1111
[[ $# -eq 0 ]] || cd "$1"
@@ -34,11 +34,7 @@ tag=$(git describe --tags --match 'v2*' --abbrev=0)
3434
# so we're stuck disassembling it.
3535
described=$(git describe --tags --match 'v2*' --abbrev=10)
3636
suffix="${described##${tag}-}"
37-
counter=$(echo $suffix | cut -d - -f 1)
3837
hash=$(echo $suffix | cut -d - -f 2)
38+
hash=${hash#g}
3939

40-
# remove any alphabetic characters before the version number
41-
tag=$(echo $tag | sed "s/\([a-z_A-Z]*\)\(.*\)/\2/")
42-
43-
# 2.10.0-M1-0098-g6f1c486d0b-2012-02-01
44-
printf "%s-%04d-%s-%s\n" "$tag" "$counter" "$hash" $(date "+%Y-%m-%d")
40+
echo "$hash"

0 commit comments

Comments
 (0)