@@ -10,11 +10,14 @@ import com.goyeau.mill.scalafix.ScalafixModule
10
10
import $ivy .`io.github.davidgregory084::mill-tpolecat::0.3.1`
11
11
import io .github .davidgregory084 .TpolecatModule
12
12
13
- import $ivy .`com.carlosedp::mill-docker-nativeimage::0.1-SNAPSHOT`
13
+ import $ivy .`io.github.alexarchambault.mill::mill-native-image::0.1.21`
14
+ import io .github .alexarchambault .millnativeimage .NativeImage
15
+
16
+ import $ivy .`com.carlosedp::mill-docker-nativeimage::0.0.1`
14
17
import com .carlosedp .milldockernative .DockerNative
15
18
16
19
object libVersion {
17
- val scala = " 3.2.0 "
20
+ val scala = " 2.13.10 "
18
21
val scalajs = " 1.11.0"
19
22
val zio = " 2.0.2"
20
23
val zhttp = " 2.0.0-RC11"
@@ -27,6 +30,8 @@ object libVersion {
27
30
trait Common extends ScalaModule with TpolecatModule with ScalafmtModule with ScalafixModule {
28
31
override def scalaVersion = libVersion.scala
29
32
def scalafixIvyDeps = Agg (ivy " com.github.liancheng::organize-imports: ${libVersion.organizeimports}" )
33
+ override def scalacPluginIvyDeps =
34
+ Agg (ivy " org.scalameta:::semanticdb-scalac:4.5.13 " )
30
35
def repositoriesTask = T .task { // Add snapshot repositories in case needed
31
36
super .repositoriesTask() ++ Seq (" oss" , " s01.oss" )
32
37
.map(r => s " https:// $r.sonatype.org/content/repositories/snapshots " )
@@ -44,43 +49,14 @@ trait Common extends ScalaModule with TpolecatModule with ScalafmtModule with Sc
44
49
45
50
// object shared extends Common
46
51
47
- object backend extends Common with DockerModule with DockerNative {
52
+ object backend extends Common with DockerModule with DockerNative with NativeImage with NativeImageConfig {
48
53
// Runtime dependencies
49
54
def ivyDeps = super .ivyDeps() ++ Agg (
50
55
ivy " dev.zio::zio: ${libVersion.zio}" ,
51
56
ivy " io.d11::zhttp: ${libVersion.zhttp}" ,
52
57
)
53
58
54
- object dockerNative extends DockerNativeConfig {
55
- def nativeImageName = " backend"
56
- def nativeImageGraalVmJvmId = T {
57
- sys.env.getOrElse(" GRAALVM_ID" , " graalvm-java17:22.2.0" )
58
- }
59
- def nativeImageClassPath = runClasspath()
60
- def nativeImageMainClass = " com.carlosedp.zioscalajs.backend.MainApp"
61
- def nativeImageOptions = super .nativeImageOptions() ++ Seq (
62
- " --no-fallback" ,
63
- " --enable-url-protocols=http,https" ,
64
- " -Djdk.http.auth.tunneling.disabledSchemes=" ,
65
- // "--static", // Does not work on MacOS
66
- " --no-fallback" ,
67
- " --install-exit-handlers" ,
68
- " --enable-http" ,
69
- " --initialize-at-run-time=io.netty.channel.DefaultFileRegion" ,
70
- " --initialize-at-run-time=io.netty.channel.epoll.Native" ,
71
- " --initialize-at-run-time=io.netty.channel.epoll.Epoll" ,
72
- " --initialize-at-run-time=io.netty.channel.epoll.EpollEventLoop" ,
73
- " --initialize-at-run-time=io.netty.channel.epoll.EpollEventArray" ,
74
- " --initialize-at-run-time=io.netty.channel.kqueue.KQueue" ,
75
- " --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventLoop" ,
76
- " --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventArray" ,
77
- " --initialize-at-run-time=io.netty.channel.kqueue.Native" ,
78
- " --initialize-at-run-time=io.netty.channel.unix.Limits" ,
79
- " --initialize-at-run-time=io.netty.channel.unix.Errors" ,
80
- " --initialize-at-run-time=io.netty.channel.unix.IovArray" ,
81
- " --allow-incomplete-classpath" ,
82
- )
83
-
59
+ object dockerNative extends DockerNativeConfig with NativeImageConfig {
84
60
def tags = List (" docker.io/carlosedp/zioscalajs-backend" )
85
61
def exposedPorts = Seq (8080 )
86
62
}
@@ -99,6 +75,39 @@ object backend extends Common with DockerModule with DockerNative {
99
75
}
100
76
}
101
77
78
+ trait NativeImageConfig extends JavaModule with NativeImage {
79
+ def nativeImageName = " backend"
80
+ def nativeImageClassPath = runClasspath()
81
+ def nativeImageGraalVmJvmId = T {
82
+ sys.env.getOrElse(" GRAALVM_ID" , " graalvm-java17:22.2.0" )
83
+ }
84
+ // def nativeImageClassPath = runClasspath()
85
+ def nativeImageMainClass = " com.carlosedp.zioscalajs.backend.MainApp"
86
+ def nativeImageOptionsDef = Seq (
87
+ " --no-fallback" ,
88
+ " --enable-url-protocols=http,https" ,
89
+ " -Djdk.http.auth.tunneling.disabledSchemes=" ,
90
+ " --install-exit-handlers" ,
91
+ " --enable-http" ,
92
+ " --initialize-at-run-time=io.netty.channel.DefaultFileRegion" ,
93
+ " --initialize-at-run-time=io.netty.channel.epoll.Native" ,
94
+ " --initialize-at-run-time=io.netty.channel.epoll.Epoll" ,
95
+ " --initialize-at-run-time=io.netty.channel.epoll.EpollEventLoop" ,
96
+ " --initialize-at-run-time=io.netty.channel.epoll.EpollEventArray" ,
97
+ " --initialize-at-run-time=io.netty.channel.kqueue.KQueue" ,
98
+ " --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventLoop" ,
99
+ " --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventArray" ,
100
+ " --initialize-at-run-time=io.netty.channel.kqueue.Native" ,
101
+ " --initialize-at-run-time=io.netty.channel.unix.Limits" ,
102
+ " --initialize-at-run-time=io.netty.channel.unix.Errors" ,
103
+ " --initialize-at-run-time=io.netty.channel.unix.IovArray" ,
104
+ " --allow-incomplete-classpath" ,
105
+ )
106
+ if (System .getProperty(" os.name" ).startsWith(" Linux" )) {
107
+ def nativeImageOptions = nativeImageOptionsDef ++ Seq (" --static" )
108
+ } else nativeImageOptionsDef
109
+ }
110
+
102
111
object frontend extends ScalaJSModule with Common {
103
112
def scalaJSVersion = libVersion.scalajs
104
113
def ivyDeps = super .ivyDeps() ++ Agg (
0 commit comments