1
- import $ivy .`io.github.alexarchambault.mill::mill-native-image::0.1.31-1`
2
- import $ivy .`io.github.alexarchambault.mill::mill-native-image-upload:0.1.31-1`
1
+ package build
3
2
4
- import $file . publish , publish .{ finalPublishVersion , publishSonatype => publishSonatype0 }
3
+ import $packages . _
5
4
5
+ import $ivy .`io.github.alexarchambault.mill::mill-native-image::0.1.31-1`
6
+ import $ivy .`io.github.alexarchambault.mill::mill-native-image-upload:0.1.31-1`
7
+ import build .project .publish
8
+ import build .project .publish .{finalPublishVersion , publishSonatype => publishSonatype0 }
6
9
import io .github .alexarchambault .millnativeimage .NativeImage
7
10
import io .github .alexarchambault .millnativeimage .upload .Upload
8
- import mill ._ , scalalib ._
11
+ import mill ._
12
+ import scalalib ._
9
13
10
14
import java .io .File
15
+ import scala .annotation .unused
11
16
12
17
object Deps {
13
18
object Versions {
@@ -42,7 +47,7 @@ def ghOrg = "VirtusLab"
42
47
def ghName = " scala-cli-signing"
43
48
trait ScalaCliSigningPublish extends PublishModule {
44
49
import mill .scalalib .publish ._
45
- def pomSettings = PomSettings (
50
+ def pomSettings : Target [ PomSettings ] = PomSettings (
46
51
description = artifactName(),
47
52
organization = " org.virtuslab.scala-cli-signing" ,
48
53
url = s " https://github.com/ $ghOrg/ $ghName" ,
@@ -52,63 +57,64 @@ trait ScalaCliSigningPublish extends PublishModule {
52
57
Developer (" alexarchambault" , " Alex Archambault" , " https://github.com/alexarchambault" )
53
58
)
54
59
)
55
- def publishVersion = finalPublishVersion()
60
+ def publishVersion : Target [ String ] = finalPublishVersion()
56
61
}
57
62
58
63
object shared extends Cross [Shared ](Scala .scala213, Scala .scala3)
59
64
trait Shared extends CrossScalaModule with ScalaCliSigningPublish {
60
- override val crossScalaVersion = crossValue
61
- def ivyDeps = super .ivyDeps() ++ Seq (
65
+ override val crossScalaVersion : String = crossValue
66
+ def ivyDeps : Target [ Agg [ Dep ]] = super .ivyDeps() ++ Seq (
62
67
Deps .jsoniterCore,
63
68
Deps .osLib
64
69
)
65
- def compileIvyDeps = super .ivyDeps() ++ Seq (
70
+ def compileIvyDeps : Target [ Agg [ Dep ]] = super .ivyDeps() ++ Seq (
66
71
Deps .jsoniterMacros
67
72
)
68
73
}
69
74
70
75
trait CliNativeImage extends NativeImage {
71
- def nativeImagePersist = System .getenv(" CI" ) != null
72
- def nativeImageGraalVmJvmId = Deps .graalVmId
73
- def nativeImageName = " scala-cli-signing"
74
- def nativeImageClassPath = `native-cli`.runClasspath()
75
- def nativeImageMainClass = T {
76
+ def nativeImagePersist : Boolean = System .getenv(" CI" ) != null
77
+ def nativeImageGraalVmJvmId : Target [ String ] = Deps .graalVmId
78
+ def nativeImageName = " scala-cli-signing"
79
+ def nativeImageClassPath : Target [ Seq [ PathRef ]] = `native-cli`.runClasspath()
80
+ def nativeImageMainClass : Target [ String ] = Task {
76
81
`native-cli`.mainClass().getOrElse(sys.error(" no main class found" ))
77
82
}
78
- def nativeImageOptions = super .nativeImageOptions() ++ Seq (
83
+ def nativeImageOptions : Target [ Seq [ String ]] = super .nativeImageOptions() ++ Seq (
79
84
" --no-fallback" ,
80
85
" --rerun-class-initialization-at-runtime=org.bouncycastle.jcajce.provider.drbg.DRBG$Default,org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV"
81
86
)
82
87
83
88
def nameSuffix = " "
84
- def copyToArtifacts (directory : String = " artifacts/" ) = T .command {
85
- val _ = Upload .copyLauncher(
86
- nativeImage().path,
87
- directory,
88
- " scala-cli-signing" ,
89
+
90
+ @ unused
91
+ def copyToArtifacts (directory : String = " artifacts/" ): Command [Unit ] = Task .Command {
92
+ val _ = Upload .copyLauncher0(
93
+ nativeLauncher = nativeImage().path,
94
+ directory = directory,
95
+ name = " scala-cli-signing" ,
89
96
compress = true ,
90
- suffix = nameSuffix
97
+ suffix = nameSuffix,
98
+ workspace = Task .workspace
91
99
)
92
100
}
93
101
}
94
102
95
103
object cli extends Cross [Cli ](Scala .scala213, Scala .scala3)
96
104
trait Cli extends CrossScalaModule with ScalaCliSigningPublish {
97
105
self =>
98
- override val crossScalaVersion = crossValue
99
- def ivyDeps = super .ivyDeps() ++ Seq (
106
+ override val crossScalaVersion : String = crossValue
107
+ def ivyDeps : Target [ Agg [ Dep ]] = super .ivyDeps() ++ Seq (
100
108
Deps .bouncycastle,
101
109
Deps .bouncycastleUtils,
102
110
Deps .caseApp,
103
111
Deps .coursierPublish // we can probably get rid of that one
104
112
)
105
- def moduleDeps = Seq (
106
- shared()
107
- )
108
- def mainClass = Some (" scala.cli.signing.ScalaCliSigning" )
113
+ def moduleDeps : Seq [Shared ] = Seq (shared())
114
+ def mainClass : Target [Option [String ]] = Some (" scala.cli.signing.ScalaCliSigning" )
109
115
110
116
object test extends ScalaTests with TestModule .Munit {
111
- def ivyDeps = super .ivyDeps() ++ Agg (
117
+ def ivyDeps : Target [ Agg [ Dep ]] = super .ivyDeps() ++ Agg (
112
118
Deps .expecty,
113
119
Deps .munit,
114
120
Deps .jsoniterMacros
@@ -117,25 +123,25 @@ trait Cli extends CrossScalaModule with ScalaCliSigningPublish {
117
123
super .forkArgs() ++ Seq (" -Xmx512m" , " -Xms128m" , " --add-opens=java.base/java.util=ALL-UNNAMED" )
118
124
}
119
125
120
- override def scalaVersion = crossScalaVersion
126
+ override def scalaVersion : Target [ String ] = crossScalaVersion
121
127
}
122
128
}
123
129
object `native-cli` extends ScalaModule with ScalaCliSigningPublish { self =>
124
- private def scalaVer = Scala .scala3
125
- def scalaVersion = scalaVer
126
- def ivyDeps = super .ivyDeps() ++ Seq (
130
+ private def scalaVer : String = Scala .scala3
131
+ def scalaVersion : Target [ String ] = scalaVer
132
+ def ivyDeps : Target [ Agg [ Dep ]] = super .ivyDeps() ++ Seq (
127
133
Deps .svm
128
134
)
129
- def moduleDeps = Seq (
135
+ def moduleDeps : Seq [ Cli ] = Seq (
130
136
cli(scalaVer)
131
137
)
132
138
133
- def mainClass = cli(scalaVer).mainClass()
139
+ def mainClass : Target [ Option [ String ]] = cli(scalaVer).mainClass()
134
140
135
141
object `base-image` extends CliNativeImage
136
142
object `static-image` extends CliNativeImage {
137
143
private def helperImageName = " scala-cli-signing-musl"
138
- def nativeImageDockerParams = T {
144
+ def nativeImageDockerParams : Target [ Option [ NativeImage . DockerParams ]] = T {
139
145
buildHelperImage()
140
146
Some (
141
147
NativeImage .linuxStaticParams(
@@ -144,20 +150,21 @@ object `native-cli` extends ScalaModule with ScalaCliSigningPublish { self =>
144
150
)
145
151
)
146
152
}
147
- def buildHelperImage = T {
153
+ def buildHelperImage : Target [ Unit ] = Task {
148
154
os.proc(" docker" , " build" , " -t" , helperImageName, " ." )
149
155
.call(cwd = os.pwd / " project" / " musl-image" , stdout = os.Inherit )
150
156
()
151
157
}
152
- def writeNativeImageScript (scriptDest : String , imageDest : String = " " ) = T .command {
153
- buildHelperImage()
154
- super .writeNativeImageScript(scriptDest, imageDest)()
155
- }
158
+ def writeNativeImageScript (scriptDest : String , imageDest : String = " " ): Command [Unit ] =
159
+ Task .Command {
160
+ buildHelperImage()
161
+ super .writeNativeImageScript(scriptDest, imageDest)()
162
+ }
156
163
def nameSuffix = " -static"
157
164
}
158
165
159
166
object `mostly-static-image` extends CliNativeImage {
160
- def nativeImageDockerParams = Some (
167
+ def nativeImageDockerParams : Target [ Option [ NativeImage . DockerParams ]] = Some (
161
168
NativeImage .linuxMostlyStaticParams(
162
169
Deps .ubuntuDockerVersion,
163
170
s " https://github.com/coursier/coursier/releases/download/v ${Deps .coursierVersion}/cs-x86_64-pc-linux.gz "
@@ -167,15 +174,15 @@ object `native-cli` extends ScalaModule with ScalaCliSigningPublish { self =>
167
174
}
168
175
}
169
176
170
- def tmpDirBase = T . persistent {
171
- PathRef (T .dest / " working-dir" )
177
+ def tmpDirBase : Target [ PathRef ] = Task ( persistent = true ) {
178
+ PathRef (Task .dest / " working-dir" )
172
179
}
173
180
174
181
trait CliTests extends ScalaModule {
175
- def testLauncher : T [PathRef ]
176
- def cliKind : T [String ]
182
+ def testLauncher : Target [PathRef ]
183
+ def cliKind : Target [String ]
177
184
178
- override def scalaVersion = Scala .scala3
185
+ override def scalaVersion : Target [ String ] = Scala .scala3
179
186
180
187
def prefix = " integration-"
181
188
private def updateRef (name : String , ref : PathRef ): PathRef = {
@@ -185,45 +192,45 @@ trait CliTests extends ScalaModule {
185
192
)
186
193
PathRef (os.Path (rawPath))
187
194
}
188
- private def mainArtifactName = T (artifactName())
189
- def modulesPath = T {
195
+ private def mainArtifactName : Target [ String ] = Task (artifactName())
196
+ def modulesPath : Target [ PathRef ] = Task {
190
197
val name = mainArtifactName().stripPrefix(prefix)
191
198
val baseIntegrationPath = os.Path (millSourcePath.toString.stripSuffix(name))
192
199
val p = os.Path (
193
200
baseIntegrationPath.toString.stripSuffix(baseIntegrationPath.baseName)
194
201
)
195
202
PathRef (p)
196
203
}
197
- def sources = T .sources {
204
+ def sources : Target [ Seq [ PathRef ]] = Task . Sources {
198
205
val mainPath = PathRef (modulesPath().path / " integration" / " src" / " main" / " scala" )
199
206
super .sources() ++ Seq (mainPath)
200
207
}
201
- def resources = T .sources {
208
+ def resources : Target [ Seq [ PathRef ]] = Task . Sources {
202
209
val mainPath = PathRef (modulesPath().path / " integration" / " src" / " main" / " resources" )
203
210
super .resources() ++ Seq (mainPath)
204
211
}
205
212
206
213
trait Tests extends ScalaTests with TestModule .Munit {
207
- def ivyDeps = super .ivyDeps() ++ Agg (
214
+ def ivyDeps : Target [ Agg [ Dep ]] = super .ivyDeps() ++ Agg (
208
215
Deps .expecty,
209
216
Deps .munit,
210
217
Deps .osLib
211
218
)
212
- def testFramework = " munit.Framework"
213
- def forkArgs = super .forkArgs() ++ Seq (" -Xmx512m" , " -Xms128m" )
214
- def forkEnv = super .forkEnv() ++ Seq (
219
+ def testFramework = " munit.Framework"
220
+ def forkArgs : Target [ Seq [ String ]] = super .forkArgs() ++ Seq (" -Xmx512m" , " -Xms128m" )
221
+ def forkEnv : Target [ Map [ String , String ]] = super .forkEnv() ++ Seq (
215
222
" SIGNING_CLI" -> testLauncher().path.toString,
216
223
" SIGNING_CLI_KIND" -> cliKind(),
217
224
" SIGNING_CLI_TMP" -> tmpDirBase().path.toString
218
225
)
219
226
220
- def sources = T .sources {
227
+ def sources : Target [ Seq [ PathRef ]] = Task . Sources {
221
228
val name = mainArtifactName().stripPrefix(prefix)
222
229
super .sources().flatMap { ref =>
223
230
Seq (updateRef(name, ref), ref)
224
231
}
225
232
}
226
- def resources = T .sources {
233
+ def resources : Target [ Seq [ PathRef ]] = Task . Sources {
227
234
val name = mainArtifactName().stripPrefix(prefix)
228
235
super .resources().flatMap { ref =>
229
236
Seq (updateRef(name, ref), ref)
@@ -235,35 +242,37 @@ trait CliTests extends ScalaModule {
235
242
object `jvm-integration` extends Cross [JvmIntegration ](Scala .scala213, Scala .scala3)
236
243
trait JvmIntegration extends CrossScalaModule with CliTests { self =>
237
244
scalaVersion
238
- override val crossScalaVersion = crossValue
239
- def testLauncher = cli(crossScalaVersion).launcher()
240
- def cliKind = " jvm"
245
+ override val crossScalaVersion : String = crossValue
246
+ def testLauncher : Target [ PathRef ] = cli(crossScalaVersion).launcher()
247
+ def cliKind = " jvm"
241
248
242
249
object test extends Tests
243
250
}
251
+
244
252
object `native-integration` extends Module {
245
253
object native extends CliTests {
246
- def testLauncher = `native-cli`.`base-image`.nativeImage()
247
- def cliKind = " native"
254
+ def testLauncher : Target [ PathRef ] = `native-cli`.`base-image`.nativeImage()
255
+ def cliKind = " native"
248
256
249
257
object test extends Tests
250
258
}
251
259
object static extends CliTests {
252
- def testLauncher = `native-cli`.`static-image`.nativeImage()
253
- def cliKind = " native-static"
260
+ def testLauncher : Target [ PathRef ] = `native-cli`.`static-image`.nativeImage()
261
+ def cliKind = " native-static"
254
262
255
263
object test extends Tests
256
264
}
257
265
object `mostly-static` extends CliTests {
258
- def testLauncher = `native-cli`.`mostly-static-image`.nativeImage()
259
- def cliKind = " native-mostly-static"
266
+ def testLauncher : Target [ PathRef ] = `native-cli`.`mostly-static-image`.nativeImage()
267
+ def cliKind = " native-mostly-static"
260
268
261
269
object test extends Tests
262
270
}
263
271
}
264
272
265
273
object ci extends Module {
266
- def upload (directory : String = " artifacts/" ) = T .command {
274
+ @ unused
275
+ def upload (directory : String = " artifacts/" ): Command [Unit ] = Task .Command {
267
276
val version = finalPublishVersion()
268
277
269
278
val path = os.Path (directory, os.pwd)
@@ -276,23 +285,26 @@ object ci extends Module {
276
285
else (" v" + version, false )
277
286
278
287
Upload .upload(
279
- ghOrg,
280
- ghName,
281
- ghToken,
282
- tag,
288
+ ghOrg = ghOrg ,
289
+ ghProj = ghName,
290
+ ghToken = ghToken ,
291
+ tag = tag ,
283
292
dryRun = false ,
284
293
overwrite = overwriteAssets
285
294
)(launchers : _* )
286
295
}
287
296
288
- def publishSonatype (tasks : mill.main.Tasks [PublishModule .PublishData ]) = T .command {
289
- publishSonatype0(
290
- data = define.Target .sequence(tasks.value)(),
291
- log = T .ctx().log
292
- )
293
- }
297
+ @ unused
298
+ def publishSonatype (tasks : mill.main.Tasks [PublishModule .PublishData ]): Command [Unit ] =
299
+ Task .Command {
300
+ publishSonatype0(
301
+ data = define.Target .sequence(tasks.value)(),
302
+ log = Task .ctx().log
303
+ )
304
+ }
294
305
295
- def copyJvm (jvm : String = Deps .graalVmId, dest : String = " jvm" ) = T .command {
306
+ @ unused
307
+ def copyJvm (jvm : String = Deps .graalVmId, dest : String = " jvm" ): Command [os.Path ] = Task .Command {
296
308
import sys .process ._
297
309
val command = os.proc(
298
310
" cs" ,
@@ -303,9 +315,9 @@ object ci extends Module {
303
315
" --ttl" ,
304
316
" 0"
305
317
)
306
- val baseJavaHome = os.Path (command.call().out.text().trim, os.pwd )
318
+ val baseJavaHome = os.Path (command.call().out.text().trim, Task .workspace )
307
319
System .err.println(s " Initial Java home $baseJavaHome" )
308
- val destJavaHome = os.Path (dest, os.pwd )
320
+ val destJavaHome = os.Path (dest, Task .workspace )
309
321
os.copy(baseJavaHome, destJavaHome, createFolders = true )
310
322
System .err.println(s " New Java home $destJavaHome" )
311
323
destJavaHome
0 commit comments