Select Git revision
build.gradle
-
Jueun Park authored
# Conflicts: # .gitlab-ci.yml # build.gradle # gradle.properties
Jueun Park authored# Conflicts: # .gitlab-ci.yml # build.gradle # gradle.properties
build.gradle 5.66 KiB
group 'de.tudresden.inf.st'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'jastadd'
apply plugin: 'application'
apply plugin: 'idea'
apply plugin: 'maven-publish'
mainClassName = 'de.tudresden.inf.st.rago'
sourceCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
maven {
name 'gitlab-maven'
url 'https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven'
}
}
configurations {
grammar2uml
relast
}
dependencies {
implementation group: 'com.flipkart.zjsonpatch', name: 'zjsonpatch', version: "${json_patch_version}"
implementation group: 'io.swagger.parser.v3', name: 'swagger-parser', version: "${swagger_parser_version}"
grammar2uml group: 'de.tudresden.inf.st', name: 'grammar2uml', version: "${grammar2uml_version}"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${junit_jupiter_version}"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${junit_jupiter_version}"
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: "${junit_jupiter_version}"
testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: "${json_path_version}"
}
buildscript {
repositories.mavenCentral()
dependencies {
classpath "org.jastadd:jastaddgradle:${jastaddgradle_version}"
}
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': "${mainClassName}"
)
}
}
test {
testLogging.showStandardStreams = true
useJUnitPlatform()
maxHeapSize = '1G'
}
// Input and output files for relast
def relastInputFiles = [
"src/main/jastadd/OpenAPISpecification.relast"
]
def relastOutputFiles = [
"src/gen/jastadd/OpenAPISpecification.ast",
"src/gen/jastadd/OpenAPISpecification.jadd"
]
def grammarDiagramFile = './src/gen/resources/diagrams/grammar/openapiRelast.png'
task generateGrammarDiagrams(type: JavaExec) {
group = 'Documentation'
classpath = configurations.grammar2uml
main = 'de.tudresden.inf.st.jastadd.grammar2uml.compiler.Compiler'
args "--output=${grammarDiagramFile}", '--defaultFolders'
args relastInputFiles
inputs.files relastInputFiles
outputs.files file(grammarDiagramFile)
}
task relast(type: JavaExec) {
classpath = files("libs/relast.jar")
group = 'Build'
doFirst {
delete relastOutputFiles
mkdir "src/gen/jastadd/"
}
args = [
"--listClass=java.util.ArrayList",
"--jastAddList=JastAddList",
"--useJastAddNames",
"--file",
"--resolverHelper",
"--grammarName=./src/gen/jastadd/RelAst"
] + relastInputFiles
inputs.files relastInputFiles
outputs.files relastOutputFiles
}
File genSrc = file("src/gen/java")
sourceSets.main.java.srcDir genSrc
idea.module.generatedSourceDirs += genSrc
jastadd {
configureModuleBuild()
modules {
//noinspection GroovyAssignabilityCheck
module("openapispecification") {
java {
basedir "src/main/java/"
include "**/*.java"
}
jastadd {
basedir "src/"
include "**/**/*.ast"
include "**/**/*.jadd"
include "**/**/*.jrag"
}
}
}
module = "openapispecification"
astPackage = 'de.tudresden.inf.st.openapi.ast'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
jastaddOptions = [
"--lineColumnNumbers",
"--List=JastAddList",
"--safeLazy",
"--rewrite=cnta",
// "--debug",
// "--cache=all",
// "--concurrent",
// "--cache=none",
// "--flush=api",
// "--incremental=param,debug",
// "--tracing",
// "--visitCheck=true",
]
cleanGen.doFirst {
delete "src/gen"
delete "src/gen-res"
}
}
def versionFile = 'src/main/resources/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)
}
}
task setDevVersionForCI() {
doFirst {
def props = new Properties()
props['version'] = version + "-$System.env.CI_PIPELINE_IID"
props.store(file(versionFile).newWriter(), null)
}
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
url "https://git-st.inf.tu-dresden.de/api/v4/projects/$System.env.CI_PROJECT_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)
}
}
}
}