Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relational-rags
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
relational-rags
Commits
543f9c59
Commit
543f9c59
authored
5 years ago
by
René Schöne
Committed by
Johannes Mey
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Create script to include commit in version string"
parent
d01f774d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.gradle
+41
-0
41 additions, 0 deletions
build.gradle
src/main/java/org/jastadd/relast/compiler/Compiler.java
+22
-5
22 additions, 5 deletions
src/main/java/org/jastadd/relast/compiler/Compiler.java
src/main/resources/.gitignore
+1
-0
1 addition, 0 deletions
src/main/resources/.gitignore
with
64 additions
and
5 deletions
build.gradle
+
41
−
0
View file @
543f9c59
...
...
@@ -110,6 +110,47 @@ jastadd {
jastaddOptions
=
[
"--lineColumnNumbers"
,
"--safeLazy"
,
"--visitCheck=true"
,
"--rewrite=cnta"
,
"--cache=all"
]
}
def
versionFile
=
'src/main/resources/RelASTVersion.properties'
task
updateVersion
{
/* version string handling adapted from https://bitbucket.org/extendj/extendj/src/master/build.gradle
written by Jesper Öqvist <jesper.oqvist@cs.lth.se> */
group
'build'
description
'Updates the version file for RelAST'
doLast
{
def
oldProps
=
new
Properties
()
String
oldFullVersion
,
fullVersion
try
{
file
(
versionFile
).
withInputStream
{
stream
->
oldProps
.
load
(
stream
)
}
oldFullVersion
=
oldProps
[
'version'
]
}
catch
(
ignored
)
{
oldFullVersion
=
"???"
}
try
{
def
proc
=
'git describe'
.
execute
(
null
,
rootDir
)
if
(
proc
.
waitFor
()
==
0
)
{
fullVersion
=
proc
.
text
.
trim
()
if
(
hasProperty
(
'withNewVersion'
))
{
// Trim to get latest tag:
version
=
(
fullVersion
=~
/-\d+\-g.+$/
).
replaceAll
(
''
)
}
if
(
oldFullVersion
!=
fullVersion
)
{
def
props
=
new
Properties
()
props
[
'version'
]
=
fullVersion
props
.
store
(
file
(
versionFile
).
newWriter
(),
null
)
}
}
else
{
logger
.
warn
(
'No git tags found.'
)
}
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Failded to run git describe (${e.getMessage()})."
)
}
}
}
processResources
.
dependsOn
updateVersion
task
preprocessRelationTest
(
type:
JavaExec
,
group:
'verification'
)
{
doFirst
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/jastadd/relast/compiler/Compiler.java
+
22
−
5
View file @
543f9c59
...
...
@@ -8,14 +8,11 @@ import org.jastadd.relast.parser.RelAstParser;
import
org.jastadd.relast.scanner.RelAstScanner
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.List
;
public
class
Compiler
{
private
static
final
String
VERSION
=
"0.2.4"
;
private
ArrayList
<
Option
<?>>
options
;
private
FlagOption
optionWriteToFile
;
private
FlagOption
optionPrintAST
;
...
...
@@ -35,7 +32,7 @@ public class Compiler {
commandLine
=
new
CommandLine
(
options
);
commandLine
.
parse
(
args
);
printMessage
(
"Running RelAST "
+
VERSION
);
printMessage
(
"Running RelAST "
+
readVersion
()
);
if
(
commandLine
.
getArguments
().
size
()
<
1
)
{
error
(
"specify at least one input file"
);
...
...
@@ -126,6 +123,26 @@ public class Compiler {
}
}
/**
* Reads the version string.
*
* The version string is read from the property file
* src/main/resources/Version.properties. This
* file should be generated during the build process. If it is missing
* then there is some problem in the build script.
*
* @author Jesper Öqvist <jesper.oqvist@cs.lth.se>
* @return the read version string, or <code>version ?</code>
*/
private
String
readVersion
()
{
try
{
ResourceBundle
resources
=
ResourceBundle
.
getBundle
(
"Version"
);
return
resources
.
getString
(
"version"
);
}
catch
(
MissingResourceException
e
)
{
return
"version ?"
;
}
}
public
static
void
main
(
String
[]
args
)
{
try
{
new
Compiler
(
args
);
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/.gitignore
0 → 100644
+
1
−
0
View file @
543f9c59
RelASTVersion.properties
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment