230 lines
6.1 KiB
Groovy
230 lines
6.1 KiB
Groovy
import groovy.transform.NullCheck
|
|
import groowt.gradle.antlr.GroowtAntlrExecTask
|
|
|
|
plugins {
|
|
id 'groowt-conventions'
|
|
id 'groowt-antlr-plugin'
|
|
id 'groowt-testing'
|
|
id 'groowt-publish'
|
|
id 'java-library'
|
|
id 'groovy'
|
|
id 'org.jetbrains.kotlin.jvm'
|
|
id 'java-test-fixtures'
|
|
id 'distribution'
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
configurations {
|
|
groovyConsole
|
|
sketchingImplementation {
|
|
extendsFrom(apiElements, runtimeElements)
|
|
}
|
|
testFixturesApi {
|
|
extendsFrom configurations.testing
|
|
}
|
|
toolsImplementation {
|
|
extendsFrom(apiElements, runtimeElements)
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
sketching {
|
|
java {
|
|
compileClasspath += sourceSets.main.output
|
|
runtimeClasspath += sourceSets.main.output
|
|
srcDirs = [file('sketching/java')]
|
|
}
|
|
groovy {
|
|
srcDirs = [file('sketching/groovy')]
|
|
}
|
|
resources {
|
|
srcDirs = [file('sketching/resources')]
|
|
}
|
|
}
|
|
tools {
|
|
java {
|
|
compileClasspath += sourceSets.main.output
|
|
runtimeClasspath += sourceSets.main.output
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
api project(':web-view-components')
|
|
api libs.antlr.runtime
|
|
api project(':fp')
|
|
|
|
compileOnlyApi libs.jetbrains.anotations
|
|
|
|
implementation libs.slf4j.api
|
|
implementation libs.kotlin.stdlib
|
|
implementation libs.jansi
|
|
implementation libs.asm
|
|
implementation project(':di')
|
|
implementation project(':extensible')
|
|
|
|
groowtAntlr libs.antlr
|
|
|
|
testing libs.mockito.core, libs.mockito.junit
|
|
|
|
groovyConsole libs.groovy.console
|
|
|
|
toolsImplementation libs.picocli
|
|
toolsImplementation libs.groovy.console
|
|
toolsImplementation libs.log4j.core
|
|
|
|
toolsRuntimeOnly libs.log4j.slf4jBinding
|
|
}
|
|
|
|
ext {
|
|
antlrPackageName = 'groowt.view.component.web.antlr'
|
|
toolsPackageName = 'groowt.view.component.web.tools'
|
|
}
|
|
|
|
groowtAntlr {
|
|
packageName = project.ext.get('antlrPackageName')
|
|
visitor = true
|
|
}
|
|
|
|
tasks.named('generateWebViewComponentsLexerBase', GroowtAntlrExecTask) { task ->
|
|
dependsOn('generateLexerFragments')
|
|
doLast {
|
|
def pattern = ~/public class WebViewComponentsLexerBase(.*)/
|
|
def lexerSource = task.resolveOutputFile 'WebViewComponentsLexerBase.java'
|
|
def outLines = lexerSource.readLines().collect {
|
|
def matcher = pattern.matcher(it)
|
|
if (matcher.matches()) {
|
|
return 'public abstract class WebViewComponentsLexerBase' + matcher.group(1)
|
|
} else {
|
|
return it
|
|
}
|
|
}
|
|
lexerSource.write(outLines.join('\n'))
|
|
}
|
|
}
|
|
|
|
tasks.named('generateWebViewComponentsParser', GroowtAntlrExecTask) {
|
|
dependsOn('generateWebViewComponentsLexerBase')
|
|
}
|
|
|
|
tasks.named({ String name ->
|
|
name in ['compileJava', 'compileGroovy', 'compileKotlin']
|
|
} as Spec<String>).configureEach {
|
|
dependsOn 'generateAllAntlr'
|
|
}
|
|
|
|
tasks.register('groovyConsole', JavaExec) {
|
|
group = 'groovy'
|
|
classpath += sourceSets.main.runtimeClasspath + configurations.groovyConsole
|
|
mainClass = 'groovy.console.ui.Console'
|
|
}
|
|
|
|
tasks.register('toolsJar', Jar) {
|
|
group 'tools'
|
|
archiveBaseName = 'web-view-components-compiler-tools'
|
|
exclude { FileTreeElement element ->
|
|
element.file in sourceSets.main.output
|
|
}
|
|
from sourceSets.tools.output
|
|
from sourceSets.tools.runtimeClasspath.filter(File.&exists).collect { it.isDirectory() ? it : zipTree(it) }
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
}
|
|
|
|
@NullCheck
|
|
class ToolSpec {
|
|
|
|
final String name
|
|
final String mainClass
|
|
final String mainClassPackage
|
|
|
|
ToolSpec(String name, String mainClass, String mainClassPackage) {
|
|
this.name = name
|
|
this.mainClass = mainClass
|
|
this.mainClassPackage = mainClassPackage
|
|
}
|
|
|
|
String getFullMainClass() {
|
|
this.mainClassPackage + '.' + this.mainClass
|
|
}
|
|
|
|
}
|
|
|
|
def toolSpec = { String name, String mainClass ->
|
|
new ToolSpec(name, mainClass, project.ext.get('toolsPackageName') as String)
|
|
}
|
|
|
|
final List<ToolSpec> toolSpecs = [
|
|
toolSpec('astBuilder', 'AstBuilder'),
|
|
toolSpec('astFileMaker', 'AstFileMakerCli'), // deprecated
|
|
toolSpec('convertToGroovy', 'ConvertToGroovy'),
|
|
toolSpec('groovyWvc', 'GroovyWvcCompiler'),
|
|
toolSpec('lexer', 'LexerTool'), // deprecated
|
|
toolSpec('parser', 'ParserTool'), // deprecated
|
|
toolSpec('parseTreeFileMaker', 'ParseTreeFileMakerCli'), // deprecated
|
|
toolSpec('parseWvc', 'ParseWvc'),
|
|
toolSpec('tokenizeWvc', 'TokenizeWvc'),
|
|
toolSpec('tokensFileMaker', 'TokensFileMakerCli') // deprecated
|
|
]
|
|
|
|
toolSpecs.each { spec ->
|
|
tasks.register("create${spec.name.capitalize()}StartScripts", CreateStartScripts) {
|
|
group = 'tools'
|
|
outputDir = file('bin')
|
|
applicationName = spec.name
|
|
classpath = sourceSets.tools.runtimeClasspath
|
|
mainClass = spec.fullMainClass
|
|
unixStartScriptGenerator.template = resources.text.fromFile('src/tools/binTemplate.gst')
|
|
}
|
|
}
|
|
|
|
tasks.register('createToolsStartScripts') {
|
|
group 'tools'
|
|
dependsOn tasks.matching { Task task ->
|
|
task != it
|
|
&& task.name.startsWith('create')
|
|
&& task.name.endsWith('StartScripts')
|
|
&& task.group == 'tools'
|
|
}
|
|
}
|
|
|
|
tasks.register('cleanBin', Delete) {
|
|
group = 'tools'
|
|
delete file('bin')
|
|
}
|
|
|
|
tasks.register('uberJar', Jar) {
|
|
group 'groovyc'
|
|
archiveBaseName = 'web-view-components-uber'
|
|
from sourceSets.main.output
|
|
from sourceSets.main.runtimeClasspath
|
|
.filter(File.&exists)
|
|
.collect { it.isDirectory() ? it : zipTree(it) }
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
}
|
|
|
|
test {
|
|
jvmArgs '-XX:+EnableDynamicAgentLoading' // for mockito/bytebuddy
|
|
}
|
|
|
|
java {
|
|
withSourcesJar()
|
|
}
|
|
|
|
tasks.named('sourcesJar', Jar) {
|
|
from fileTree('src/main/antlr')
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
dependsOn 'generateAllAntlr'
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
create('webViewComponentsCompiler', MavenPublication) {
|
|
artifactId = 'web-view-components-compiler'
|
|
from components.java
|
|
}
|
|
}
|
|
}
|