-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
79 lines (65 loc) · 2.81 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
import sbt.file
import sbtassembly.AssemblyPlugin.autoImport.assembly
name := "opal-generate-library-usage"
version := "0.1-SNAPSHOT"
scalaVersion := "2.12.15"
lazy val root: Project = project
.in(file("."))
.settings(
libraryDependencies += "de.opal-project" % "framework_2.12" % "4.0.0",
libraryDependencies += "com.github.scopt" %% "scopt" % "4.0.1",
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.11",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % "test",
libraryDependencies += "io.get-coursier" %% "coursier" % "2.1.0-M5-18-gfebf9838c",
assembly / assemblyJarName := "usagegen.jar",
assembly / assemblyExcludedJars := {
val cp = (assembly / fullClasspath).value
cp.filter { f =>
Seq("coursier", "scalatest", "jniutils", "windows-jni-utils", "windows-ansi", "jansi", "plexus")
.exists { excluded => f.data.getName.contains(excluded) }
}
},
assembly / assemblyMergeStrategy := discardModuleInfoMergeStrategy,
Test / compile := (Test / compile).dependsOn(
instancesearcherTestResources / copyJarToTestResources,
interfacesTestResources / copyJarToTestResources,
exceptionsTestResources / copyJarToTestResources
).value
)
lazy val discardModuleInfoMergeStrategy: (String => sbtassembly.MergeStrategy) = {
case "module-info.class" => MergeStrategy.discard
case other => MergeStrategy.defaultMergeStrategy(other)
}
val copyJarToTestResources = taskKey[Unit]("Copy jar from packageBin to root test resources")
val instancesearcherTestResources = project.in(file("testfiles/instancesearcher/"))
.settings(
Compile / javacOptions ++= Seq("-source", "8", "-target", "8"),
copyJarToTestResources := {
(Compile / compile).value
val sourceFile = (Compile / packageBin).value
doCopyJarToTestResources(sourceFile)
},
)
val interfacesTestResources = project.in(file("testfiles/interfaces/"))
.settings(
Compile / javacOptions ++= Seq("-source", "8", "-target", "8"),
copyJarToTestResources := {
(Compile / compile).value
val sourceFile = (Compile / packageBin).value
doCopyJarToTestResources(sourceFile)
},
)
val exceptionsTestResources = project.in(file("testfiles/exceptions/"))
.settings(
Compile / javacOptions ++= Seq("-source", "8", "-target", "8"),
copyJarToTestResources := {
(Compile / compile).value
val sourceFile = (Compile / packageBin).value
doCopyJarToTestResources(sourceFile)
},
)
def doCopyJarToTestResources(sourceFile: File): Unit = {
val targetFileName = sourceFile.getName.replaceFirst("_\\d\\..*-SNAPSHOT", "")
val targetFile = root.base / "src/test/resources" / targetFileName
IO.copyFile(sourceFile, targetFile, CopyOptions(overwrite = true, preserveLastModified = false, preserveExecutable = false))
}