Commit 699ebb7a authored by René Schöne's avatar René Schöne
Browse files

Merge branch 'improvement/modern-gradle' into 'develop'

Update build and test system, add package deployment

See merge request !19
parents 76cdf8f3 e6aebf05
Pipeline #12980 passed with stages
in 1 minute and 52 seconds
......@@ -13,4 +13,3 @@ src/test/jastadd/*/*.ast
src/test/jastadd/*/*.jadd
src/test/jastadd/*/*ResolverStubs.jrag
!src/test/jastadd/*/MyRefResolver.jadd
/gradle.properties
......@@ -15,7 +15,7 @@ build:
image: openjdk:8
stage: build
script:
- ./gradlew --console=plain --no-daemon assemble jar
- ./gradlew --console=plain --no-daemon assemble fatJar
artifacts:
paths:
- "/builds/jastadd/relational-rags/build/libs/relast-*.jar"
......@@ -36,5 +36,28 @@ pages:
paths:
- public
only:
- master
- master
- main
publish:
image: openjdk:8
stage: deploy
needs:
- test
script:
- "./gradlew publish"
only:
- master
- main
publish_dev:
image: openjdk:8
stage: deploy
needs:
- test
script:
- "./gradlew setDevVersionForCI"
- "./gradlew publish"
except:
- master
- main
......@@ -23,33 +23,27 @@ This location can be [configured](#build-configuration).
## Build configuration
Currently, the test setup is configured within `build.gradle` using a specialized Gradle task `RelastTest`.
Currently, the test setup is configured within `build.gradle` using a specialized Gradle task `RelastTest` provided by the [preprocessor testing Gradle plugin][preprocessor-testing].
An example configuration might look like:
```groovy
task compileMultipleTest(type: RelastTest) {
relastFiles 'src/test/jastadd/multiple/Part1.relast',
'src/test/jastadd/multiple/Part2.relast',
'src/test/jastadd/multiple/Part3.relast'
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
packageName = 'multiple.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
relast {
inputFiles = [file('src/test/jastadd/multiple/Part1.relast'),
file('src/test/jastadd/multiple/Part2.relast'),
file('src/test/jastadd/multiple/Part3.relast')]
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'multiple.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
```
The following options are supported, similar to the [command-line options](/../#supported-command-line-options):
| Name | Description | Required | Default |
|-------------------|--------------------------------------------------------------------------------------------------------|--------------------|---------------------|
| `relastFiles` | Input grammar(s). Either one or multiple files separated by comma. | Yes | _none_ |
| `grammarName` | Directory and file prefix for the generated grammar and jrag created by RelAST. | Yes | _none_ |
| `useJastAddNames` | Set to `true` to use accessor names for relations matching JastAdd naming convention. | No | `false` |
| `packageName` | Name of the package for the Java files generated by JastAdd. | Yes (not enforced) | The empty package |
| `moreInputFiles` | Additional files as input for JastAdd. | No | No additional files |
| `resolverHelper` | Set to `true` to generate means for lazy resolving. | No | `false` |
| `jastAddList` | Alternative name for `List` nodes. Will be passed to both RelAST and JastAdd. | No | `List` |
| `serializer` | Name of supported serializer. One of {`jackson`, `jackson-json-pointer`, `jackson-manual-references`}. | No | No serializer |
Please see the [documentation of the plugin][preprocessor-testing] for all options.
## Test files
......@@ -106,3 +100,4 @@ The workflow:
[semantic-versioning]: https://semver.org/
[create-release]: /../-/tags/new
[create-issue]: https://git-st.inf.tu-dresden.de/jastadd/relational-rags/issues/new
[preprocessor-testing]: https://jastadd.pages.st.inf.tu-dresden.de/testing/
......@@ -2,7 +2,7 @@
![RelAST process](relast-process.png)
See [releases page](/../../releases) for the latest version.
See [releases page](/../../releases) for the latest version and <https://jastadd.pages.st.inf.tu-dresden.de/relational-rags/> for more documentation.
The RelAST preprocessor takes a `.relast` file as input comprising AST rules and relations. It produces files that afterwards are processed by JastAdd to generated Java code.
To use it in your project, build the JAR file running
......@@ -52,21 +52,23 @@ Note that you may have to change
## Supported relations
// Directed relations
A.b -> B;
A.b? -> B;
A.bs* -> B;
B <- A.b ;
B <- A.b? ;
B <- A.bs*;
```
// Directed relations
A.b -> B;
A.b? -> B;
A.bs* -> B;
B <- A.b ;
B <- A.b? ;
B <- A.bs*;
// Bidirectional relations
A.b <-> B.a;
A.b <-> B.a?;
A.b <-> B.as*;
A.b? <-> B.a;
A.b? <-> B.a?;
A.b? <-> B.as*;
A.bs* <-> B.a;
A.bs* <-> B.a?;
A.bs* <-> B.as*;
// Bidirectional relations
A.b <-> B.a;
A.b <-> B.a?;
A.b <-> B.as*;
A.b? <-> B.a;
A.b? <-> B.a?;
A.b? <-> B.as*;
A.bs* <-> B.a;
A.bs* <-> B.a?;
A.bs* <-> B.as*;
```
import org.jastadd.relast.plugin.RelastTest
buildscript {
repositories {
maven {
name "gitlab-maven"
url "https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven"
}
}
dependencies {
classpath 'org.jastadd.preprocessor:testing:0.2.14-32'
}
}
apply plugin: "com.github.ben-manes.versions"
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'jastadd'
apply plugin: 'application'
apply plugin: "idea"
apply plugin: "org.jastadd.relast.plugin"
import org.jastadd.preprocessor.testing.plugin.PreprocessorPlugin
import org.jastadd.preprocessor.testing.plugin.RelastTest
//file:noinspection HardCodedStringLiteral
plugins {
id 'java'
id 'java-library'
id 'application'
id 'idea'
id 'maven-publish'
id 'org.jastadd' version '1.14.5'
}
sourceCompatibility = 1.8
apply plugin: PreprocessorPlugin
mainClassName = 'org.jastadd.relast.compiler.Compiler'
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
repositories {
jcenter()
ext {
mainClassName = 'org.jastadd.relast.compiler.Compiler'
}
group = 'org.jastadd'
apply plugin: 'maven-publish'
buildscript {
repositories.jcenter()
dependencies {
classpath 'org.jastadd:jastaddgradle:1.13.3'
classpath "com.github.ben-manes:gradle-versions-plugin:0.34.0"
repositories {
mavenCentral()
maven {
name 'gitlab-maven'
url 'https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven'
}
}
dependencyUpdates.gradleReleaseChannel="current"
dependencyUpdates.revision="release"
group = 'org.jastadd'
// set the main class name for `gradle run`
application.mainClass = "${mainClassName}"
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'org.assertj:assertj-core:3.18.0'
testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3'
implementation group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'com.fasterxml.jackson.core:jackson-core:2.13.1'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.13.1'
api 'org.jastadd:jastadd:2.3.5'
api 'net.sf.beaver:beaver-rt:0.9.11'
}
File genSrc = file("src/gen/java")
File testGenSrc = file("src/test/java-gen")
File genSrc = file('src/gen/java')
File testGenSrc = file('src/test/java-gen')
sourceSets.main.java.srcDir genSrc
sourceSets.main.java.srcDir "buildSrc/gen/java"
sourceSets.test.java.srcDir testGenSrc
idea.module.generatedSourceDirs += genSrc
idea.module.generatedSourceDirs += testGenSrc
def versionFile = 'src/main/resources/RelASTVersion.properties'
def oldProps = new Properties()
try {
def oldProps = new Properties()
file(versionFile).withInputStream { stream -> oldProps.load(stream) }
version = oldProps['version']
} catch (ignored) {
......@@ -68,110 +81,129 @@ task newVersion() {
}
}
jar {
manifest {
attributes "Main-Class": 'org.jastadd.relast.compiler.Compiler'
task printVersion() {
doLast {
println(version)
}
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
task setDevVersionForCI() {
doFirst {
def props = new Properties()
props['version'] = version + "-$System.env.CI_PIPELINE_IID"
props.store(file(versionFile).newWriter(), null)
}
}
jar.archiveBaseName = 'relast'
task fatJar(type: Jar) {
dependsOn jar
group = "build"
archiveBaseName = 'relast'
archiveAppendix = "fatjar"
from sourceSets.main.output
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes "Main-Class": "${mainClassName}"
}
}
jastadd {
configureModuleBuild()
modules {
//noinspection GroovyAssignabilityCheck
module("RelAst") {
java {
basedir "."
include "src/main/**/*.java"
include "src/gen/**/*.java"
}
module('RelAst') {
jastadd {
basedir "src/main/jastadd/"
include "**/*.ast"
include "**/*.jadd"
include "**/*.jrag"
basedir 'src/main/jastadd/'
include '**/*.ast'
include '**/*.jadd'
include '**/*.jrag'
}
scanner {
include "src/main/jastadd/RelAst.flex"
include 'src/main/jastadd/RelAst.flex'
}
parser {
include "src/main/jastadd/Preamble.parser"
include "src/main/jastadd/RelAst.parser"
include 'src/main/jastadd/Preamble.parser'
include 'src/main/jastadd/RelAst.parser'
}
}
}
cleanGen.doFirst {
delete "src/gen/java/org"
delete "src/gen-res/BuildInfo.properties"
delete 'src/gen/'
delete 'src/gen-res/'
}
preprocessParser.doFirst {
args += ["--no-beaver-symbol"]
}
module = "RelAst"
module = 'RelAst'
astPackage = 'org.jastadd.relast.ast'
parser.name = 'RelAstParser'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
scanner.genDir = 'src/gen/java/org/jastadd/relast/scanner'
parser.genDir = 'src/gen/java/org/jastadd/relast/parser'
scanner.genDir = "src/gen/java/org/jastadd/relast/scanner"
parser.genDir = "src/gen/java/org/jastadd/relast/parser"
jastaddOptions = ["--lineColumnNumbers", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
// default options are: ['--rewrite=cnta', '--safeLazy', '--visitCheck=false', '--cacheCycle=false']
extraJastAddOptions = ['--lineColumnNumbers', '--visitCheck=true']
}
// publish gitlab project
publishing {
publications {
maven(MavenPublication) {
artifact("build/libs/relast-${version}.jar") {
extension 'jar'
}
artifactId = 'relast'
from components.java
}
}
repositories {
maven {
name 'nexus'
url "http://172.22.1.152:8081/repository/" + (project.hasProperty('asSnapshot') ? "maven-snapshots" : "maven-releases/")
credentials {
username project.ext.properties.repoUser
password project.ext.properties.repoPassword
url "https://git-st.inf.tu-dresden.de/api/v4/projects/$System.env.CI_PROJECT_ID/packages/maven"
credentials(HttpHeaderCredentials) {
name = 'Job-Token'
value = System.getenv('CI_JOB_TOKEN')
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
publish.dependsOn jar
task firstRelationsRun(type: RelastTest) {
relastFiles 'src/test/jastadd/relations/Relations.relast'
grammarName = 'src/test/jastadd/relations/Relations'
useJastAddNames = true
packageName = 'relations.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/relations/Relations.jrag'
relast {
inputFiles = [file('src/test/jastadd/relations/Relations.relast')]
grammarName = 'src/test/jastadd/relations/Relations'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'relations.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/relations/Relations.jrag')]
}
}
task secondRelationsRun(type: RelastTest, dependsOn: firstRelationsRun) {
relastFiles 'src/test/jastadd/relations/Relations.ast'
grammarName = 'src/test/jastadd/relations/Relations2'
useJastAddNames = true
packageName = 'ignored'
relast {
inputFiles = [file('src/test/jastadd/relations/Relations.ast')]
grammarName = 'src/test/jastadd/relations/Relations2'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
skipRun = true
packageName = 'ignored'
}
doLast {
delete fileTree('src/test/java-gen/ignored')
......@@ -180,131 +212,198 @@ task secondRelationsRun(type: RelastTest, dependsOn: firstRelationsRun) {
}
task compileConstructorTest(type: RelastTest) {
relastFiles 'src/test/jastadd/constructors/Constructors.relast'
grammarName = 'src/test/jastadd/constructors/Constructors'
packageName = 'constructors.ast'
moreInputFiles 'src/test/jastadd/constructors/Constructors.jrag'
relast {
inputFiles = [file('src/test/jastadd/constructors/Constructors.relast')]
grammarName = 'src/test/jastadd/constructors/Constructors'
noResolverHelper = true
}
jastadd {
packageName = 'constructors.ast'
inputFiles = [file('src/test/jastadd/constructors/Constructors.jrag')]
}
}
task compileDefaultNamesTest(type: RelastTest) {
relastFiles 'src/test/jastadd/relations/Relations.relast'
grammarName = 'src/test/jastadd/relations/Relations3'
packageName = 'defaultnames.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/relations/Relations.jrag'
relast {
inputFiles = [file('src/test/jastadd/relations/Relations.relast')]
grammarName = 'src/test/jastadd/relations/Relations3'
useJastAddNames = false
noResolverHelper = true
}
jastadd {
packageName = 'defaultnames.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/relations/Relations.jrag')]
}
}
task compileDefaultNamesResolverTest(type: RelastTest) {
relastFiles 'src/test/jastadd/resolver/Resolver.relast'
grammarName = 'src/test/jastadd/resolver/Resolver2'
resolverHelper = true
packageName = 'defaultnames.resolver.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd',
'src/test/jastadd/resolver/ResolverUtils.jadd',
'src/test/jastadd/resolver/MyRefResolver.jadd'
relast {
inputFiles = [file('src/test/jastadd/resolver/Resolver.relast')]
grammarName = 'src/test/jastadd/resolver/Resolver2'
useJastAddNames = false
}
jastadd {
packageName = 'defaultnames.resolver.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/resolver/ResolverUtils.jadd'),
file('src/test/jastadd/resolver/MyRefResolver.jadd')]
}
}
task compileLowerBoundsTest(type: RelastTest) {
relastFiles 'src/test/jastadd/lowerbounds/LowerBounds.relast'
grammarName = 'src/test/jastadd/lowerbounds/LowerBounds'
useJastAddNames = true
packageName = 'lowerbounds.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
relast {
inputFiles = [file('src/test/jastadd/lowerbounds/LowerBounds.relast')]
grammarName = 'src/test/jastadd/lowerbounds/LowerBounds'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'lowerbounds.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileMultipleTest(type: RelastTest) {
relastFiles 'src/test/jastadd/multiple/Part1.relast',
'src/test/jastadd/multiple/Part2.relast',
'src/test/jastadd/multiple/Part3.relast'
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
packageName = 'multiple.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
relast {
inputFiles = [file('src/test/jastadd/multiple/Part1.relast'),
file('src/test/jastadd/multiple/Part2.relast'),
file('src/test/jastadd/multiple/Part3.relast')]
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'multiple.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileMultipleMixedTest(type: RelastTest) {
relastFiles 'src/test/jastadd/multiple-mixed/Part1.relast',
'src/test/jastadd/multiple-mixed/Part2.relast',
'src/test/jastadd/multiple-mixed/Part3.relast'
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
packageName = 'mixed.multiple.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
relast {
inputFiles = [file('src/test/jastadd/multiple-mixed/Part1.relast'),
file('src/test/jastadd/multiple-mixed/Part2.relast'),
file('src/test/jastadd/multiple-mixed/Part3.relast')]
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'mixed.multiple.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileResolverTest(type: RelastTest) {
relastFiles 'src/test/jastadd/resolver/Resolver.relast'
grammarName = 'src/test/jastadd/resolver/Resolver'
useJastAddNames = true
resolverHelper = true
packageName = 'resolver.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd',
'src/test/jastadd/resolver/ResolverUtils.jadd',
'src/test/jastadd/resolver/MyRefResolver.jadd'
relast {
inputFiles = [file('src/test/jastadd/resolver/Resolver.relast')]
grammarName = 'src/test/jastadd/resolver/Resolver'
useJastAddNames = true
}
jastadd {
packageName = 'resolver.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/resolver/ResolverUtils.jadd'),
file('src/test/jastadd/resolver/MyRefResolver.jadd')]
}
}
task compileResolver2Test(type: RelastTest) {
relastFiles 'src/test/jastadd/resolver2/Resolver.relast'
grammarName = 'src/test/jastadd/resolver2/Resolver'
useJastAddNames = true
resolverHelper = true
packageName = 'resolver2.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd',
'src/test/jastadd/resolver2/ResolverUtils.jadd',
'src/test/jastadd/resolver2/MyRefResolver.jadd'
relast {
inputFiles = [file('src/test/jastadd/resolver2/Resolver.relast')]
grammarName = 'src/test/jastadd/resolver2/Resolver'
useJastAddNames = true
}
jastadd {
packageName = 'resolver2.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/resolver2/ResolverUtils.jadd'),
file('src/test/jastadd/resolver2/MyRefResolver.jadd')]
}
}
task compileListNamesTest(type: RelastTest) {
relastFiles 'src/test/jastadd/listnames/ListNames.relast'
grammarName = 'src/test/jastadd/listnames/ListNames'
useJastAddNames = true
jastAddList = 'ListyMcListface'
listClass = 'java.util.LinkedList'
packageName = 'listnames.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
relast {
inputFiles = [file('src/test/jastadd/listnames/ListNames.relast')]
grammarName = 'src/test/jastadd/listnames/ListNames'
useJastAddNames = true
noResolverHelper = true
listClass = 'java.util.LinkedList'
}
jastadd {
jastAddList = 'ListyMcListface'
packageName = 'listnames.ast'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileSerializerTest(type: RelastTest) {
relastFiles 'src/test/jastadd/serializer/Serializer.relast'
grammarName = 'src/test/jastadd/serializer/Serializer'
useJastAddNames = true
serializer = 'jackson'
packageName = 'serializer.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
relast {
inputFiles = [file('src/test/jastadd/serializer/Serializer.relast')]
grammarName = 'src/test/jastadd/serializer/Serializer'
useJastAddNames = true
serializer = 'jackson'
noResolverHelper = true