forked from dirs-dev/directories-jvm
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sc
184 lines (160 loc) · 5.09 KB
/
build.sc
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
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.1`
import de.tobiasroeser.mill.vcs.version.VcsVersion
import mill._
import mill.define.ModuleRef
import mill.scalalib._
import mill.scalalib.publish._
import scala.util.Properties
trait DirectoriesPublishModule extends PublishModule {
def pomSettings = PomSettings(
description = "directories-jvm",
organization = "io.get-coursier.util",
url = "https://github.com/coursier/directories-jvm",
licenses = Seq(License.`MPL-2.0`),
versionControl = VersionControl.github("coursier", "directories-jvm"),
developers = Seq(
Developer("alexarchambault", "Alex Archambault", "https://github.com/alexarchambault")
)
)
def publishVersion = T {
val value = VcsVersion.vcsState().format()
if (value.contains("-")) {
val value0 = value.takeWhile(_ != '-')
val lastDotIdx = value0.lastIndexOf('.')
if (lastDotIdx < 0) value0 + "-SNAPSHOT"
else
value0.drop(lastDotIdx + 1).toIntOption match {
case Some(lastNum) =>
val prefix = value0.take(lastDotIdx)
s"$prefix.${lastNum + 1}-SNAPSHOT"
case None =>
value0 + "-SNAPSHOT"
}
}
else value
}
}
object directories extends JavaModule with DirectoriesPublishModule {
def javacOptions = super.javacOptions() ++ Seq(
"--release", "8"
)
def javadocOptions = super.javadocOptions() ++ Seq(
"-Xdoclint:none"
)
def sources = T.sources {
Seq(PathRef(T.workspace / "src/main/java"))
}
def jdk22ClassesResources = T {
val destDir = T.dest / "META-INF/versions/22"
os.makeDir.all(destDir)
for (elem <- os.list(jdk22.compile().classes.path))
os.copy(elem, destDir / elem.last)
PathRef(T.dest)
}
def resources = T {
T.sources(Seq(PathRef(T.workspace / "src/main/resources")) ++ Seq(jdk22ClassesResources()))
}
def manifest = T {
super.manifest().add("Multi-Release" -> "true")
}
def localRepo = Task {
val dest = Task.dest
new LocalIvyPublisher(T.dest).publishLocal(
jar = jar().path,
sourcesJar = sourceJar().path,
docJar = docJar().path,
pom = pom().path,
ivy = ivy().path,
artifact = artifactMetadata(),
extras = extraPublish()
)
PathRef(dest)
}
}
object `directories-jni` extends JavaModule with DirectoriesPublishModule {
def moduleDeps = Seq(directories)
def ivyDeps = Agg(
ivy"io.get-coursier.jniutils:windows-jni-utils:0.3.3"
)
def javacOptions = super.javacOptions() ++ Seq(
"--release", "8"
)
def localRepo = Task {
val dest = Task.dest
new LocalIvyPublisher(T.dest).publishLocal(
jar = jar().path,
sourcesJar = sourceJar().path,
docJar = docJar().path,
pom = pom().path,
ivy = ivy().path,
artifact = artifactMetadata(),
extras = extraPublish()
)
PathRef(dest)
}
}
object jdk22 extends JavaModule {
def moduleDeps = Seq(directories)
def javacOptions = super.javacOptions() ++ Seq(
"--release", "22"
)
}
object java8ZincWorker extends ZincWorkerModule {
override def jvmId =
if (Properties.isMac) "zulu:8"
else "8"
}
trait Tests extends Cross.Module[String] with JavaModule {
def zincWorker = crossValue match {
case "8" => ModuleRef(java8ZincWorker)
case "default" => super.zincWorker
}
def ivyDeps = Agg(
ivy"${directories.pomSettings().organization}:directories:${directories.publishVersion()}"
)
def repositoriesTask = Task.Anon {
Seq(
coursier.parse.RepositoryParser.repository(
"ivy:" + directories.localRepo().path.toNIO.toUri.toASCIIString + "[defaultPattern]"
).fold(err => throw new Exception(err), x => x)
) ++ super.repositoriesTask()
}
object test extends JavaTests {
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"junit:junit:4.13",
ivy"com.novocode:junit-interface:0.11"
)
def testFramework = "com.novocode.junit.JUnitFramework"
}
}
trait TestsJni extends Cross.Module[String] with JavaModule {
def zincWorker = crossValue match {
case "8" => ModuleRef(java8ZincWorker)
case "default" => super.zincWorker
}
def ivyDeps = Agg(
ivy"${`directories-jni`.pomSettings().organization}:directories-jni:${`directories-jni`.publishVersion()}"
)
def repositoriesTask = Task.Anon {
Seq(
coursier.parse.RepositoryParser.repository(
"ivy:" + directories.localRepo().path.toNIO.toUri.toASCIIString + "[defaultPattern]"
).fold(err => throw new Exception(err), x => x),
coursier.parse.RepositoryParser.repository(
"ivy:" + `directories-jni`.localRepo().path.toNIO.toUri.toASCIIString + "[defaultPattern]"
).fold(err => throw new Exception(err), x => x)
) ++ super.repositoriesTask()
}
object test extends JavaTests {
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"junit:junit:4.13",
ivy"com.novocode:junit-interface:0.11"
)
def testFramework = "com.novocode.junit.JUnitFramework"
}
}
object tests extends Cross[Tests]("8", "default")
object `tests-jni` extends Cross[TestsJni](
if (Properties.isWin) Seq("8", "default")
else Seq.empty[String]
)