-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.sbt
executable file
·279 lines (232 loc) · 9.4 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
import java.io.{File, FileOutputStream}
import java.util.Properties
import Dependencies.deps
import org.scalajs.core.tools.linker.ModuleKind
import org.scalajs.core.tools.linker.backend.OutputMode
import org.scalajs.sbtplugin.ScalaJSPlugin.AutoImport.scalaJSOutputMode
import sbt.Keys.{mainClass, packageOptions}
import sbtcrossproject.CrossPlugin.autoImport.crossProject
name := "api-language-server"
version := deps("version")
scalaVersion := "2.12.6"
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv()
val settings = Common.settings ++ Common.publish ++ Seq(
organization := "org.mule.als",
version := deps("version"),
resolvers ++= List(
Common.releases,
Common.snapshots,
Resolver.mavenLocal /*,
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")*/
),
resolvers += "jitpack" at "https://jitpack.io",
credentials ++= Common.credentials(),
libraryDependencies ++= Seq(
"com.github.amlorg" %%% "amf-webapi" % deps("amf"),
"com.github.amlorg" %%% "amf-core" % deps("amf"),
"com.github.amlorg" %%% "amf-client" % deps("amf"),
"com.github.amlorg" %%% "amf-aml" % deps("amf"),
"org.mule.common" %%% "scala-common" % deps("common"),
"org.mule.syaml" %%% "syaml" % deps("syaml"),
"org.scalatest" %%% "scalatest" % "3.0.5" % Test,
"com.chuusai" %% "shapeless" % "2.3.3",
"org.scala-js" %% "scalajs-stubs" % scalaJSVersion % "provided",
"com.lihaoyi" %%% "upickle" % "0.5.1" % Test
)
)
lazy val common = crossProject(JSPlatform, JVMPlatform).settings(
Seq(
name := "als-common"
))
.in(file("./als-common"))
.settings(settings: _*)
.jsSettings(
scalaJSOutputMode := org.scalajs.core.tools.linker.backend.OutputMode.ECMAScript6,
scalaJSModuleKind := ModuleKind.CommonJSModule
// artifactPath in (Compile, fastOptJS) := baseDirectory.value / "target" / "artifact" /"high-level.js"
)
lazy val commonJVM = common.jvm.in(file("./als-common/jvm"))
lazy val commonJS = common.js.in(file("./als-common/js"))
lazy val hl = crossProject(JSPlatform, JVMPlatform).settings(
Seq(
name := "als-hl"
))
.dependsOn(common)
.in(file("./als-hl"))
.settings(settings: _*)
.jsSettings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.2",
libraryDependencies += "com.lihaoyi" %%% "upickle" % "0.5.1",
scalaJSOutputMode := org.scalajs.core.tools.linker.backend.OutputMode.ECMAScript6,
scalaJSModuleKind := ModuleKind.CommonJSModule
// artifactPath in (Compile, fastOptJS) := baseDirectory.value / "target" / "artifact" /"high-level.js"
)
lazy val hlJVM = hl.jvm.in(file("./als-hl/jvm"))
lazy val hlJS = hl.js.in(file("./als-hl/js"))
//
lazy val suggestions = crossProject(JSPlatform, JVMPlatform).settings(
Seq(
name := "als-suggestions"
))
.dependsOn(hl)
.in(file("./als-suggestions"))
.settings(settings: _*)
.jsSettings(
skip in packageJSDependencies := false,
scalaJSOutputMode := OutputMode.Defaults,
scalaJSModuleKind := ModuleKind.CommonJSModule
)
lazy val suggestionsJVM = suggestions.jvm.in(file("./als-suggestions/jvm"))
lazy val suggestionsJS = suggestions.js.in(file("./als-suggestions/js"))
lazy val structure = crossProject(JSPlatform, JVMPlatform).settings(
Seq(
name := "als-structure"
))
.dependsOn(hl)
.in(file("./als-structure"))
.settings(settings: _*)
.jsSettings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.2",
libraryDependencies += "com.lihaoyi" %%% "upickle" % "0.5.1",
scalaJSOutputMode := org.scalajs.core.tools.linker.backend.OutputMode.ECMAScript6,
scalaJSModuleKind := ModuleKind.CommonJSModule
// artifactPath in (Compile, fastOptJS) := baseDirectory.value / "target" / "artifact" /"als-suggestions.js"
)
lazy val structureJVM = structure.jvm.in(file("./als-structure/jvm"))
lazy val structureJS = structure.js.in(file("./als-structure/js"))
lazy val server = crossProject(JSPlatform, JVMPlatform)
.settings(Seq(
name := "als-server"
))
.dependsOn(suggestions, structure % "compile->compile;test->test")
.in(file("./als-server"))
.settings(settings: _*)
.jvmSettings(
// https://mvnrepository.com/artifact/org.eclipse.lsp4j/org.eclipse.lsp4j
libraryDependencies += "org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.6.0",
packageOptions in(Compile, packageBin) += Package.ManifestAttributes("Automatic-Module-Name" → "org.mule.als"),
aggregate in assembly := true,
mainClass in assembly := Some("org.mulesoft.language.server.lsp4j.Main"),
mainClass in Compile := Some("org.mulesoft.language.server.lsp4j.Main"),
scalacOptions += "-Xmixin-force-forwarders:false",
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
)
.jsSettings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.2",
libraryDependencies += "com.lihaoyi" %%% "upickle" % "0.5.1",
scalaJSModuleKind := ModuleKind.CommonJSModule,
artifactPath in(Compile, fullOptJS) := baseDirectory.value / "target" / "artifact" / "als-server.js"
)
lazy val serverJVM = server.jvm.in(file("./als-server/jvm"))
lazy val serverJS = server.js.in(file("./als-server/js"))
// ******************** BuildJS ****************************************************************************************
val buildJS = TaskKey[Unit]("buildJS", "Build npm module")
buildJS := {
val _ = (fullOptJS in Compile in serverJS).value
"./als-server/js/build-scripts/buildJs.sh".!
}
mainClass in Compile := Some("org.mulesoft.language.server.lsp4j.Main")
val buildSuggestionsJS = TaskKey[Unit]("buildSuggestionsJS", "Build suggestions npm module")
buildSuggestionsJS := {
(fastOptJS in Compile in suggestionsJS).value
(fullOptJS in Compile in suggestionsJS).value
Process(
"./build-package.sh",
new File("./als-suggestions/js/node-package/")
).!
}
// ************** SONAR *******************************
enablePlugins(SonarRunnerPlugin)
val setSonarProperties = TaskKey[Unit](
"setSonarProperties",
"Set sonar properties!"
)
setSonarProperties := {
lazy val url = sys.env.getOrElse("SONAR_SERVER_URL", "Not found url.")
lazy val token = sys.env.getOrElse("SONAR_SERVER_TOKEN", "Not found token.")
val values = Map(
"sonar.host.url" -> url,
"sonar.login" -> token,
"sonar.projectKey" -> "mulesoft.als",
"sonar.projectName" -> "ALS",
"sonar.projectVersion" -> "1.0.0",
"sonar.sourceEncoding" -> "UTF-8",
"sonar.github.repository" -> "mulesoft/als",
"sonar.modules" -> "als-hl,als-server",
"als-server.sonar.sources" -> "shared/src/main/scala",
"als-server.sonar.scoverage.reportPath" -> "jvm/target/scala-2.12/scoverage-report/scoverage.xml",
"als-hl.sonar.sources" -> "shared/src/main/scala",
"als-hl.sonar.scoverage.reportPath" -> "jvm/target/scala-2.12/scoverage-report/scoverage.xml",
"als-server.sonar.tests" -> "shared/src/test/scala",
"als-hl.sonar.tests" -> "shared/src/test/scala"
)
sonarProperties := values
val p = new Properties()
values.foreach(v => p.put(v._1, v._2))
val stream = new FileOutputStream(file("./sonar-project.properties"))
p.store(stream, null)
stream.close()
}
val runSonar = TaskKey[Unit](
"runSonar",
"Run sonar!")
runSonar := {
// sonarRunnerOptions := Seq(
// "-D",
// s"sonar.host.url=$url",
// "-D",
// s"sonar.login=$token"
// )
// val a = generateSonarConfiguration.value
setSonarProperties.value
sonar.value
}
//**************** ALIASES *********************************************************************************************
// run only one?
addCommandAlias(
"testJVM",
"; serverJVM/test; suggestionsJVM/test; structureJVM/test; hlJVM/test"
)
addCommandAlias(
"testJS",
"; serverJS/test; suggestionsJS/test; structureJVM/test; hlJS/test"
)
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
//******* fat jar*****************************
lazy val core = crossProject(JSPlatform,JVMPlatform).settings(
Seq(
name := "api-language-server"
)
)
.dependsOn(suggestions, structure, hl, server)
.in(file(".")).settings(settings: _*).jvmSettings(
libraryDependencies += "com.github.amlorg" %%% "amf-aml" % deps("amf"),
// packageOptions in (Compile, packageBin) += Package.ManifestAttributes("Automatic-Module-Name" → "org.mule.als"),
// aggregate in assembly := true,
assemblyMergeStrategy in assembly := {
case x if x.toString.endsWith("JS_DEPENDENCIES") => MergeStrategy.discard
case PathList(ps @ _*) if ps.last endsWith "JS_DEPENDENCIES" => MergeStrategy.discard
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case x => {
MergeStrategy.first
}
},
assemblyJarName in assembly := "server.jar",
addArtifact(Artifact("api-language-server", ""), sbtassembly.AssemblyKeys.assembly)
).jsSettings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "0.9.2",
libraryDependencies += "com.lihaoyi" %%% "upickle" % "0.5.1",
scalaJSOutputMode := org.scalajs.core.tools.linker.backend.OutputMode.ECMAScript6,
scalaJSModuleKind := ModuleKind.CommonJSModule,
scalaJSUseMainModuleInitializer := true,
mainClass in Compile := Some("org.mulesoft.language.client.js.ServerProcess"),
artifactPath in (Compile, fastOptJS) := baseDirectory.value / "target" / "artifact" /"serverProcess.js"
)
lazy val coreJVM = core.jvm.in(file("./"))