@@ -54,7 +54,7 @@ sourceSets {
54
54
55
55
dependencies {
56
56
implementation(" ru.spbstu:g4-to-ebnf:0.0.0.4" )
57
- implementation(" ru.spbstu:kotlin-pandoc:0.0.13 " )
57
+ implementation(" ru.spbstu:kotlin-pandoc:0.0.15 " )
58
58
implementation(" ru.spbstu:simple-diagrammer:0.0.0.7" )
59
59
implementation(" com.github.ajalt:clikt:1.7.0" )
60
60
implementation(" com.zaxxer:nuprocess:2.0.1" )
@@ -65,30 +65,13 @@ tasks.withType<KotlinCompile> {
65
65
kotlinOptions.jvmTarget = " 1.8"
66
66
}
67
67
68
- tasks.create<ShellExec >(" buildPdf" ) {
69
- group = " internal"
70
-
71
- dependsOn(" convertGrammar" )
72
-
73
- doFirst {
74
- workingDir = File (scriptsDir)
75
- command = getScriptText(" buildPdf" )
76
-
77
- File (pdfBuildDir).mkdirs()
78
- }
79
- }
80
-
81
- tasks.create<ShellExec >(" buildPdfBySections" ) {
82
- group = " internal"
83
-
84
- dependsOn(" convertGrammar" )
85
-
86
- doFirst {
87
- workingDir = File (scriptsDir)
88
- command = getScriptText(" buildPdfBySections" )
89
-
90
- Paths .get(" $pdfBuildDir /sections" ).toFile().apply { deleteRecursively(); mkdirs() }
91
- }
68
+ tasks.create<Jar >(" filtersJar" ) {
69
+ from(
70
+ sourceSets.main.get().output,
71
+ * configurations.runtimeClasspath.get().map { if (it.isDirectory()) it else zipTree(it) }.toTypedArray()
72
+ )
73
+ archiveFileName.set(" filters.jar" )
74
+ with (tasks.jar.get())
92
75
}
93
76
94
77
tasks.create<JavaExec >(" convertGrammar" ) {
@@ -97,37 +80,60 @@ tasks.create<JavaExec>("convertGrammar") {
97
80
val parserGrammar = " KotlinParser.g4"
98
81
val outputFile = " ./src/md/kotlin.core/grammar.generated.md"
99
82
83
+ inputs.files(" $grammarsDir /$lexerGrammar " , " $grammarsDir /$parserGrammar " )
100
84
outputs.file(outputFile)
101
85
102
86
classpath = sourceSets[" main" ].runtimeClasspath
103
87
main = " org.jetbrains.kotlin.spec.ConvertGrammarKt"
104
88
args = listOf (" -d" , grammarsDir, " -l" , lexerGrammar, " -p" , parserGrammar, " -o" , outputFile)
105
89
}
106
90
107
- tasks.create< ShellExec >( " buildHtml " ) {
91
+ tasks.create( " prepareShell " ) {
108
92
group = " internal"
109
93
110
- dependsOn(" convertGrammar" )
94
+ val disableTODOS = project.findProperty(" disableTODOS" ) != null
95
+ val enableStaticMath = project.findProperty(" enableStaticMath" ) != null
111
96
112
- doFirst {
113
- workingDir = File (scriptsDir)
114
- command = getScriptText( " buildHtml " )
97
+ if (enableStaticMath) {
98
+ dependsOn( " :kotlinNpmInstall " ) // we need npm to install Katex to run it
99
+ }
115
100
116
- File (htmlBuildDir).mkdirs()
101
+ doFirst {
102
+ val res = with (StringBuilder ()) {
103
+ appendln(" PROJECT_DIR=$projectDir " )
104
+ if (disableTODOS) appendln(" TODO_OPTION=--disable-todos" )
105
+ else appendln(" TODO_OPTION=--enable-todos" )
106
+
107
+ if (enableStaticMath) {
108
+ appendln(" STATIC_MATH_OPTION=--enable-static-math" )
109
+ appendln(" KATEX_BIN_OPTION=\" --katex=${rootProject.buildDir} /js/node_modules/.bin/katex\" " )
110
+ }
111
+ else appendln(" STATIC_MATH_OPTION=--disable-static-math" )
112
+ }
113
+
114
+ File (" $buildDir /prepare.sh" ).writeText(" $res " )
117
115
}
116
+
118
117
}
119
118
120
- tasks.create< ShellExec >( " buildHtmlBySections " ) {
119
+ tasks.create( " buildPdf " ) {
121
120
group = " internal"
121
+ dependsOn(" pdf:build" )
122
+ }
122
123
123
- dependsOn(" convertGrammar" )
124
+ tasks.create(" buildPdfBySections" ) {
125
+ group = " internal"
126
+ dependsOn(" pdfSections:build" )
127
+ }
124
128
125
- doFirst {
126
- workingDir = File (scriptsDir)
127
- command = getScriptText(" buildHtmlBySections" )
129
+ tasks.create(" buildHtml" ) {
130
+ group = " internal"
131
+ dependsOn(" html:build" )
132
+ }
128
133
129
- Paths .get(htmlBuildDir).toFile().apply { deleteRecursively(); mkdirs() }
130
- }
134
+ tasks.create(" buildHtmlBySections" ) {
135
+ group = " internal"
136
+ dependsOn(" htmlSections:build" )
131
137
}
132
138
133
139
tasks.create<JavaExec >(" execute" ) {
0 commit comments