Skip to content
Snippets Groups Projects
Commit b5bd462a authored by Johannes Mey's avatar Johannes Mey
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 713 additions and 0 deletions
# Cookiecutter template for relational RAG projects
Requirements:
- Cookiecutter (0.7.0+) installed, e.g., using `pip install cookiecutter`.
Usage:
1. Create a [new project](https://git-st.inf.tu-dresden.de/projects/new). Note the URL to clone the project and its project ID.
2. Run `cookiecutter https://git-st.inf.tu-dresden.de/jastadd/project-templates/relast` and put in your information, especially the URL from step 1 as `project_url` and the project ID from step 1 as `project_gitlab_id`.
{
"repo_name": "test_repo",
"project_name": "My New Relational RAG Project",
"project_short_name": "NewRelAST",
"project_slug": "{{cookiecutter.project_name|replace(' ','_')|lower}}",
"project_gitlab_id": "001",
"package": "jastadd",
"project_url": "git@git-st.inf.tu-dresden.de:{{cookiecutter.package}}/{{cookiecutter.project_slug}}.git",
"repo_url": "https://git-st.inf.tu-dresden.de/{{cookiecutter.package}}/{{cookiecutter.project_slug}}",
"version": "0.0.1",
"_copy_without_render": [
"pages/custom_theme/footer.html"
]
}
import sys
import subprocess
PROJECT_URL = '{{cookiecutter.project_url}}'
def main():
subprocess.call(['git', 'init'])
if __name__ == '__main__':
main()
import sys
project_short_name = '{{cookiecutter.project_short_name}}'
def main():
if not project_short_name.isalnum():
print('project_short_name "' + project_short_name + '" must be a single word. Exiting.')
sys.exit(1)
if __name__ == '__main__':
main()
.gradle/
src/gen/
src/gen-res/
.idea/
build/
out/
logs/
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- test
- ragdoc
- publish
build:
image: openjdk:11
stage: build
before_script:
# - apt-get update && apt-get -y install graphviz # uncomment if relast2uml is used
script:
- "./gradlew assemble"
artifacts:
paths:
- "src/gen/java"
- "src/gen/jastadd"
test:
image: openjdk:11
stage: test
needs:
- build
before_script:
# - apt-get update && apt-get -y install graphviz # uncomment if relast2uml is used
script:
- "./gradlew test"
artifacts:
reports:
junit: "*/build/test-results/test/TEST-*.xml"
paths:
- "src/gen/resources"
ragdoc_build:
image:
name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-builder"
entrypoint: [""]
stage: ragdoc
needs:
- build
script:
- JAVA_FILES=$(find src/ -name '*.java')
- /ragdoc-builder/start-builder.sh -excludeGenerated -d data/ $JAVA_FILES
artifacts:
paths:
- "data/"
ragdoc_view:
image:
name: "git-st.inf.tu-dresden.de:4567/jastadd/ragdoc-view:relations"
entrypoint: [""]
stage: ragdoc
needs:
- ragdoc_build
script:
- DATA_DIR=$(pwd -P)/data
- mkdir -p pages/docs/ragdoc
- OUTPUT_DIR=$(pwd -P)/pages/docs/ragdoc
- cd /ragdoc-view/src/ && rm -rf data && ln -s $DATA_DIR
- /ragdoc-view/build-view.sh --output-path=$OUTPUT_DIR
only:
- dev
- main
artifacts:
paths:
- "pages/docs/ragdoc"
pages:
image: python:3.10.0-bullseye
stage: publish
needs:
- ragdoc_view
- test
before_script:
- pip install -r pages/requirements.txt
script:
- cd pages && mkdocs build
artifacts:
paths:
- public/
only:
- main
# {{cookiecutter.project_name}}
For documentation, please see https://{{cookiecutter.package}}.pages.st.inf.tu-dresden.de/{{cookiecutter.project_slug}}
plugins {
id 'java'
id 'application'
id 'maven-publish'
id 'idea'
id 'org.jastadd' version "${jastaddgradle_version}"
}
group 'de.tudresden.inf.st'
ext {
mainClassName = 'de.tudresden.inf.st.{{cookiecutter.project_slug}}.Main'
}
// set the main class name for `gradle run`
application.mainClassName = "${mainClassName}"
java.toolchain.languageVersion = JavaLanguageVersion.of(11)
repositories {
mavenCentral()
maven {
name 'gitlab-maven'
url 'https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven'
}
}
configurations {
// add a configuration to store the grammar printing dependency in
grammar2uml
}
File genSrc = file("src/gen/java")
idea.module.generatedSourceDirs += genSrc
sourceSets.main.java.srcDir genSrc
dependencies {
// uncomment if relast2uml should be used; this requires graphviz in CI and on system
// implementation group: 'de.tudresden.inf.st', name: 'dumpAstWithPlantuml', version: "${relast2uml_version}"
grammar2uml group: 'de.tudresden.inf.st', name: 'grammar2uml', version: "${grammar2uml_version}"
testImplementation group: 'org.assertj', name: 'assertj-core', version: "${assertj_version}"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${jupyter_version}"
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${jupyter_version}"
}
def versionFile = 'src/main/resources/{{cookiecutter.project_slug}}Version.properties'
def oldProps = new Properties()
try {
file(versionFile).withInputStream { stream -> oldProps.load(stream) }
version = oldProps['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)
}
task printVersion() {
doLast {
println(version)
}
}
task newVersion() {
doFirst {
def props = new Properties()
props['version'] = value
props.store(file(versionFile).newWriter(), null)
}
}
test {
testLogging.showStandardStreams = true
useJUnitPlatform()
}
jar {
manifest {
attributes "Main-Class": "${mainClassName}"
}
from {
configurations.runtimeClasspath.collect { return (it.isDirectory() ? it : zipTree(it)) : null }
}
}
def relastJar = 'libs/relast.jar'
def relastFiles = ['./src/main/jastadd/common/MotionGrammar.relast', './src/main/jastadd/World.relast', './src/main/jastadd/LoadUnload.relast']
def grammarPrefix = './src/gen/jastadd/MotionGrammar'
def grammarDiagramFile = './src/gen/resources/diagrams/grammar/uml.png'
def jastAddListName = 'JastAddList'
task generateGrammarDiagrams(type: JavaExec) {
group = 'Documentation'
classpath = configurations.grammar2uml
args "--output=${grammarDiagramFile}", '--defaultFolders'
args relastFiles
inputs.files relastFiles
outputs.files file(grammarDiagramFile)
}
task relastToJastAdd(type: JavaExec) {
group = 'Build'
classpath = files("${relastJar}")
args "--grammarName=${grammarPrefix}",
'--useJastAddNames',
'--listClass=java.util.ArrayList',
"--jastAddList=${jastAddListName}",
'--file'
args relastFiles
inputs.files relastFiles
outputs.files file("${grammarPrefix}.ast"), file("${grammarPrefix}.jadd")
}
jastadd {
configureModuleBuild()
modules {
//noinspection GroovyAssignabilityCheck
module('relast-module') {
java {
basedir 'src/'
include 'main/**/*.java'
include 'gen/**/*.java'
}
jastadd {
basedir 'src/'
include 'main/jastadd/**/*.ast'
include 'main/jastadd/**/*.jadd'
include 'main/jastadd/**/*.jrag'
include 'gen/jastadd/**/*.ast'
include 'gen/jastadd/**/*.jadd'
include 'gen/jastadd/**/*.jrag'
}
scanner {
// TODO add scanner here
// include 'src/main/jastadd/scanner/Scanner.flex'
}
parser {
// TODO add parser here
// include 'src/main/jastadd/parser/Parser.parser'
}
}
}
cleanGen.doFirst {
delete 'src/gen/'
delete 'src/gen-res/'
}
// TODO uncomment of parser is used
// parser.name = '{{cookiecutter.project_short_name}}Parser'
// scanner.genDir = 'src/gen/java/de/tudresden/inf/st/{{cookiecutter.project_slug}}/scanner'
// parser.genDir = 'src/gen/java/de/tudresden/inf/st/{{cookiecutter.project_slug}}/parser'
module = 'relast-module'
astPackage = 'de.tudresden.inf.st.{{cookiecutter.project_slug}}.ast'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
// default options are: '--rewrite=cnta', '--safeLazy', '--visitCheck=false', '--cacheCycle=false'
extraJastAddOptions = ["--List=${jastAddListName}"]
}
//{{cookiecutter.project_gitlab_id}}
publishing {
publications {
maven(MavenPublication) {
artifactId = '{{cookiecutter.project_slug}}'
// from components.java
artifact("build/libs/{{cookiecutter.project_slug}}-${version}.jar") {
extension 'jar'
}
}
}
repositories {
maven {
url "https://git-st.inf.tu-dresden.de/api/v4/projects/{{cookiecutter.project_gitlab_id}}/packages/maven"
// Uncomment the following lines to publish manually (and comment out the other credentials section)
// credentials(HttpHeaderCredentials) {
// name = "Private-Token"
// value = gitLabPrivateToken // the variable resides in ~/.gradle/gradle.properties
// }
credentials(HttpHeaderCredentials) {
name = 'Job-Token'
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
// Workflow configuration for phases
clean.dependsOn cleanGen
generateAst.dependsOn relastToJastAdd
generateAst.dependsOn generateGrammarDiagrams
publish.dependsOn jar
relast2uml_version = 0.3.6-54
jupyter_version = 5.8.2
assertj_version = 3.22.0
grammar2uml_version = 0.2.1
jastaddgradle_version = 1.14.5
\ No newline at end of file
File added
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
File added
/docs/ragdoc/
__pycache__
{% block footer %}
<p>{% if config.copyright %}
<small>{{ config.copyright }}<br></small>
{% endif %}
<hr>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
{% if page and page.meta and page.meta.git_revision_date_localized %}
<small><br><i>Last updated {{ page.meta.git_revision_date_localized }}</i></small>
{% endif %}
</p>
{% endblock %}
# {{cookiecutter.project_name}} Documentation
[{{cookiecutter.project_name}}](https://git-st.inf.tu-dresden.de/jastadd/preprocessors/{{cookiecutter.project_slug}}) is a preprocessor to <TODO> using [JastAdd](http://jastadd.org/).
# Using the {{cookiecutter.project_name}} in your project
<TODO>
{{cookiecutter.project_slug}}VersionFileName = '../src/main/resources/{{cookiecutter.project_slug}}Version.properties'
def get_version():
with open({{cookiecutter.project_slug}}VersionFileName) as {{cookiecutter.project_slug}}VersionFile:
versionFileContent = {{cookiecutter.project_slug}}VersionFile.read()
return versionFileContent[versionFileContent.rindex('version=') + 8:].strip()
def define_env(env):
"""
This is the hook for defining variables, macros and filters
- variables: the dictionary that contains the environment variables
- macro: a decorator function, to declare a macro.
"""
env.conf['site_name'] = '{{cookiecutter.project_name}} ' + get_version()
@env.macro
def {{cookiecutter.project_slug}}_version():
return get_version()
if __name__ == '__main__':
print(get_version())
site_name: {{cookiecutter.project_name}}
repo_url: {{cookiecutter.repo_url}}
site_dir: ../public
nav:
- "Overview": index.md
- "Usage": using.md
- "API documentation": ragdoc/index.html
theme:
name: readthedocs
custom_dir: custom_theme/
markdown_extensions:
- toc:
permalink:
- admonition
- footnotes
plugins:
- search
- git-revision-date-localized:
type: datetime
timezone: Europe/Berlin
locale: en
fallback_to_build_date: True
- macros
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment