Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
relast-preprocessor
Commits
56ced9b5
Commit
56ced9b5
authored
Feb 06, 2021
by
Johannes Mey
Browse files
Feature/versioning
parent
bfa206ad
Changes
5
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
56ced9b5
plugins
{
id
'java-library'
id
'application'
id
'org.jastadd'
id
'java'
id
'idea'
...
...
@@ -7,11 +8,18 @@ plugins {
id
'com.github.ben-manes.versions'
version
'0.34.0'
}
ext
{
mainClassName
=
'org.jastadd.relast.compiler.RelastSourceToSourceCompiler'
}
// set the main class name for `gradle run`
application
.
mainClassName
=
"${mainClassName}"
sourceCompatibility
=
1.8
targetCompatibility
=
1.8
repositories
{
jcenter
()
mavenCentral
()
}
sourceSets
{
...
...
@@ -25,6 +33,7 @@ sourceSets {
task
modelJar
(
type:
Jar
)
{
group
=
"build"
archiveBaseName
=
'model'
archiveVersion
=
''
from
sourceSets
.
model
.
output
}
...
...
@@ -37,7 +46,7 @@ dependencies {
modelImplementation
group:
'org.jastadd'
,
name:
'jastadd'
,
version:
'2.3.4'
modelImplementation
group:
'net.sf.beaver'
,
name:
'beaver-rt'
,
version:
'0.9.11'
co
mp
i
le
Only
files
(
modelJar
.
archiveFile
.
get
())
i
mple
mentation
files
(
modelJar
.
archiveFile
.
get
())
api
group:
'org.jastadd'
,
name:
'jastadd'
,
version:
'2.3.4'
api
group:
'net.sf.beaver'
,
name:
'beaver-rt'
,
version:
'0.9.11'
implementation
group:
'com.github.jknack'
,
name:
'handlebars'
,
version:
'4.2.0'
...
...
@@ -56,6 +65,27 @@ dependencies {
testFixturesApi
group:
'commons-io'
,
name:
'commons-io'
,
version:
'2.8.0'
}
def
versionFile
=
'src/main/resources/preprocessor.properties'
def
versionProps
=
new
Properties
()
try
{
file
(
versionFile
).
withInputStream
{
stream
->
versionProps
.
load
(
stream
)
}
version
=
versionProps
[
'version'
]
}
catch
(
e
)
{
// this happens, if either the properties file is not present, or cannot be read from
throw
new
GradleException
(
"File ${versionFile} not found or unreadable. Aborting."
,
e
)
}
jar
{
manifest
{
attributes
"Main-Class"
:
"${mainClassName}"
}
from
{
configurations
.
runtimeClasspath
.
collect
{
it
.
isDirectory
()
?
it
:
zipTree
(
it
)
}
}
}
test
{
useJUnitPlatform
()
...
...
src/main/java/org/jastadd/PreprocessorConfiguration.java
View file @
56ced9b5
...
...
@@ -28,6 +28,7 @@
package
org.jastadd
;
import
org.jastadd.option.ArgumentParser
;
import
org.jastadd.option.FlagOption
;
import
org.jastadd.option.Option
;
import
java.io.PrintStream
;
...
...
@@ -70,6 +71,11 @@ public class PreprocessorConfiguration extends org.jastadd.Configuration {
if
(
options
.
containsKey
(
option
.
name
()))
{
System
.
err
.
println
(
"Unable to add option '"
+
option
.
name
()
+
"', because there is a JastAdd option with the same name."
);
}
else
{
if
(
option
.
name
().
equals
(
"help"
)
&&
option
instanceof
FlagOption
)
{
this
.
helpOption
=
(
FlagOption
)
option
;
}
else
if
(
option
.
name
().
equals
(
"version"
)
&&
option
instanceof
FlagOption
)
{
this
.
versionOption
=
(
FlagOption
)
option
;
}
argParser
.
addOption
(
option
);
options
.
put
(
option
.
name
(),
option
);
}
...
...
src/main/java/org/jastadd/relast/compiler/AbstractCompiler.java
View file @
56ced9b5
...
...
@@ -5,6 +5,8 @@ import org.jastadd.option.FlagOption;
import
org.jastadd.option.Option
;
import
java.util.ArrayList
;
import
java.util.MissingResourceException
;
import
java.util.ResourceBundle
;
public
abstract
class
AbstractCompiler
{
...
...
@@ -13,7 +15,7 @@ public abstract class AbstractCompiler {
protected
ArrayList
<
Option
<?>>
options
;
private
PreprocessorConfiguration
configuration
;
p
ublic
AbstractCompiler
(
String
name
,
boolean
jastaddCompliant
)
{
p
rotected
AbstractCompiler
(
String
name
,
boolean
jastaddCompliant
)
{
this
.
name
=
name
;
this
.
jastAddCompliant
=
jastaddCompliant
;
}
...
...
@@ -33,6 +35,16 @@ public abstract class AbstractCompiler {
return
0
;
}
if
(
configuration
.
shouldPrintVersion
())
{
try
{
ResourceBundle
resources
=
ResourceBundle
.
getBundle
(
"preprocessor"
);
System
.
out
.
println
(
getName
()
+
", version "
+
resources
.
getString
(
"version"
));
}
catch
(
MissingResourceException
e
)
{
System
.
out
.
println
(
getName
()
+
", unknown version"
);
}
return
0
;
}
return
compile
();
}
...
...
src/main/java/org/jastadd/relast/compiler/RelastSourceToSourceCompiler.java
View file @
56ced9b5
...
...
@@ -15,7 +15,7 @@ public class RelastSourceToSourceCompiler extends RelAstProcessor {
public
static
void
main
(
String
[]
args
)
{
try
{
new
RelastSourceToSourceCompiler
(
"
r
ela
st-preprocessor"
,
tru
e
).
run
(
args
);
new
RelastSourceToSourceCompiler
(
"
R
ela
tional RAGs Source-To-Source Compiler"
,
fals
e
).
run
(
args
);
}
catch
(
CompilerException
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
System
.
exit
(-
1
);
...
...
src/main/resources/preprocessor.properties
0 → 100644
View file @
56ced9b5
version
=
1.0.0
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment