Code Monkey home page Code Monkey logo

sbt-native-image's Introduction

scalameta

Build Status

User documentation

Head over to the user docs to learn more about the project and its roadmap.

Tutorial

If you'd like to find out how to use scalameta, see this tutorial.

Team

The current maintainers (people who can merge pull requests) are:

An up-to-date list of contributors is available here: https://github.com/scalameta/scalameta/graphs/contributors.

sbt-native-image's People

Contributors

alexitc avatar ckipp01 avatar cobr123 avatar danirey avatar dependabot[bot] avatar eed3si9n avatar exoego avatar fehu avatar guizmaii avatar i10416 avatar jannikarndt avatar leifwickland avatar olafurpg avatar parched avatar tabdulradi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sbt-native-image's Issues

Support of LLVM backend

Describe the bug

The plugin should support compilation with LLVM backend

To Reproduce

  1. Clone the following repository: git clone --depth 1 https://github.com/plokhotnyuk/jsoniter-scala
  2. Enter to the examples project: cd jsoniter-scala/jsoniter-scala-examples
  3. Add "-H:CompilerBackend=llvm" to the sequence of nativeImageOptions in the build.sbt
  4. Run sbt jsoniter-scala-examplesJVM/nativeImage

Expected behavior

Successfully compiled native image

Current behavior

andriy@notebook:~/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples$ sbt jsoniter-scala-examplesJVM/nativeImage
[info] welcome to sbt 1.7.2 (Azul Systems, Inc. Java 17.0.5)
[info] loading global plugins from /home/andriy/.sbt/1.0/plugins
[info] loading settings for project jsoniter-scala-examples-build-build from sbt-updates.sbt ...
[info] loading project definition from /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/project/project
[info] loading settings for project jsoniter-scala-examples-build from plugins.sbt ...
[info] loading project definition from /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/project
[info] loading settings for project root from build.sbt ...
[info] set current project to root (in build file:/home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/)
[warn] there are 2 keys that are not used by any other settings/tasks:
[warn]  
[warn] * jsoniter-scala-examplesJVM / nativeImageJvm
[warn]   +- /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/build.sbt:27
[warn] * jsoniter-scala-examplesJVM / nativeImageVersion
[warn]   +- /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/build.sbt:26
[warn]  
[warn] note: a setting might still be used by a command; to exclude a key from this `lintUnused` check
[warn] either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key
[info] /home/andriy/.cache/coursier/jvm/[email protected]/bin/native-image -cp /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/.jvm/target/native-image-internal/manifest.jar --no-fallback --initialize-at-build-time --diagnostics-mode -H:CompilerBackend=llvm com.github.plokhotnyuk.jsoniter_scala.examples.Example01 /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/.jvm/target/native-image/jsoniter-scala-examples
# Diagnostics mode enabled: image-build reports are saved to reports/diagnostics_20230213_105957
Apply jar:file:///home/andriy/.cache/coursier/jvm/[email protected]/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties
Apply jar:file:///home/andriy/.cache/coursier/jvm/[email protected]/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties
# Printing command line arguments to: reports/diagnostics_20230213_105957/command-line_20230213_105957.txt
Error: Please install the LLVM backend for GraalVM Native Image via `$JAVA_HOME/bin/gu install native-image-llvm-backend`.
Error: Image build request failed with exit status 1
[error] native-image command failed with exit code '1'
[error] (jsoniter-scala-examplesJVM / nativeImage) native-image command failed with exit code '1'
[error] Total time: 2 s, completed Feb 13, 2023, 10:59:58 AM

Installation:

  • Operating system: Linux
  • Version: v0.3.2

nativeImageRunAgent doesn't appear to properly parse arguments

Describe the bug

Running nativeImageRunAgent with a single argument results in an Invalid Input exception being thrown (for sbt 1.4.7)

sbt> nativeImageRunAgent foo
[error] stack trace is suppressed; run last nativeImageRunAgent for the full output
[error] (nativeImageRunAgent) Invalid programmatic input:
[error] Expected whitespace character
[error] foo
[error] ^

sbt> last nativeImageRunAgent
[error] java.lang.RuntimeException: Invalid programmatic input:
[error] Expected whitespace character
[error] foo
[error] ^
[error]         at scala.sys.package$.error(package.scala:30)
[error]         at sbt.Extracted.runInputTask(Extracted.scala:84)
[error]         at sbtnativeimage.NativeImagePlugin$.$anonfun$projectSettings$31(NativeImagePlugin.scala:213)
[error]         at sbtnativeimage.NativeImagePlugin$.$anonfun$projectSettings$31$adapted(NativeImagePlugin.scala:198)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]         at sbt.Execute.work(Execute.scala:291)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]         at java.base/java.lang.Thread.run(Thread.java:834)
[error] (nativeImageRunAgent) Invalid programmatic input:
[error] Expected whitespace character
[error] foo
[error] ^

Doing nativeImageRunAgent " foo" works as a workaround. Not super familiar with scala parser combinators, but perhaps there's some regression with spaceDelimited - https://github.com/scalameta/sbt-native-image/blob/master/plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala#L211. Happy to help look into this too!

In addition, while nativeImageRunAgent creates the configuration files (and maybe I'm doing something wrong) but it doesn't look like it automatically gets picked by the nativeImage build command. The GraalVM docs only mentions:

The generated configuration files can be supplied to the native-image tool by placing them in a META-INF/native-image/ directory on the class path, for example, in a JAR file used in the image build. This directory (or any of its subdirectories) is searched for files with the names jni-config.json, reflect-config.json, proxy-config.json and resource-config.json, which are then automatically included in the build. Not all of those files must be present. When multiple files with the same name are found, all of them are included.

and I'm not sure if it'll also pick up stuff in the target/native-image-configs folder by default. What I ended up doing was to pass that into nativeImageOptions (e.g. s"-H:ResourceConfigurationFiles=${target.value.absolutePath}/native-image-configs/resource-config.json",), but this seems like something the plugin can do.

Btw thank you so much for the amazing work on this plugin! Was so fiddly to get GraalVM & native-image configured and set up, and this plugin basically replaced all of that, and did everything seamlessly on my first attempt! 🔥

To Reproduce Steps to reproduce the behavior:

  1. Run command 'nativeImageRunAgent foo'

Expected behavior

Pass the arguments, without needing to wrap the arguments in a string prefixed with a space

Installation:

  • Operating system: Ubuntu under WSL
  • Version: 0.3.0
  • Sbt: 1.4.7

Receiving Unsupported reflection method: methodTypeDescriptor with nativeImageRunAgent

Describe the issue
I am trying to generate reflection configuration with the help of nativeImageRunAgent and I received the following error. The command was successful but had these errors in the logs.

I am running it via sbt on a scala project.

[error] Unsupported reflection method: methodTypeDescriptor
[error] Unsupported reflection method: methodTypeDescriptor
[error] Unsupported reflection method: methodTypeDescriptor
[error] Unsupported reflection method: methodTypeDescriptor
[error] Unsupported reflection method: methodTypeDescriptor
[error] Unsupported reflection method: methodTypeDescriptor

Describe GraalVM and your environment:

  • GraalVM version graalvm-ce-java17-22.1.0
  • JDK major version: 17
  • OS: MacOS Monterey
  • Architecture: AMD64
  • Version 0.3.1

Is there a way to use native image agent while running test?

I have developed a fairly large cli application using scala and am using sbt-native-image plugin to create its native image.
Ability to use sbt command "nativeImageAgentRun" is very helpful as it create the reflect-config.json automatically.

The issue is my application has many many logical branches. I supposed every cli application does have many code branches. To ensure I am creating correct reflect-config.json, I have run the CLI application many times with possibility. And it can be very hard depending on the size of application.

I have written tests for those scenarios. I would be very nice if there can be a way to execute the tests and use agent to derive the reflect-config.json via tests. That way I don't have to remember every code branch and manually test it every time.

native-image 21.1.0 fails on `scala.util.Random$`

GraalVM 21.1.0 has just been released, but my builds are failing unfortunately.

Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  Object has been initialized by the scala.util.Random$ class initializer with a trace: 
 	at java.util.Random.<init>(Random.java:105)
	at scala.util.Random.<init>(Random.scala:30)
	at scala.util.Random$.<init>(Random.scala:260)
	at scala.util.Random$.<clinit>(Random.scala:260)
. Try avoiding to initialize the class that caused initialization of the object. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace: Object was reached by 
	reading field scala.util.Random.self of
		constant scala.util.Random$@5e16dff3 reached by 
	scanning method org.http4s.client.PoolManager.$anonfun$borrow$10(PoolManager.scala:199)
Call path from entry point to org.http4s.client.PoolManager.$anonfun$borrow$10(Iterable): 
	at org.http4s.client.PoolManager.$anonfun$borrow$10(PoolManager.scala:199)
	at org.http4s.client.PoolManager$$Lambda$2848/0x00000007c26b5c40.apply(Unknown Source)
	at scala.collection.Iterator$$anon$22.next(Iterator.scala:1008)
	at scala.collection.convert.JavaCollectionWrappers$IteratorWrapper.next(JavaCollectionWrappers.scala:29)
	at com.oracle.svm.jni.access.JNIReflectionDictionary.unsetEntryPoints(JNIReflectionDictionary.java:178)
	at com.oracle.svm.jni.functions.JNIFunctions.UnregisterNatives(JNIFunctions.java:398)
	at com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_UnregisterNatives_07af9442aa98f893dd700b47b363fa08a3f7e240(generated:0)

Steps to reproduce the behavior

  1. Set GraalVM version to 21.1.0
  2. Run sbt/nativeImage on code that references scala.util.Random$

Solution

scala.util.Random$ extends scala.util.Random and thereby causes a static initialization of java.util.Random which is not allowed, as the error message above suggests. I believe we should therefore add --initialize-at-run-time=scala.util.Random$ to the default options of this plugin.

分享:Scala 3 体验 NativeImage ,基于sbt + native image 插件

Scala3是最新一代的Scala, 经过重新设计的API,让Scala3可玩性大大提升,跟Python语法非常接近了。但是性能更好。

重点不是这个,我们分享一下如何用sbt创建一个scala 3的项目,然后编译为机器原生镜像 nativeImage

我的机器是macos 12

安装Scala3我是通过cs 工具,安装了cs工具,执行cs setup,它就会把各种需要的东西都装好

先用cs工具装sbt,我执行 cs install sbt

装了sbt,我们就可以创建项目了

我们执行 sbt new scala/scala3.g8

创建一个scala3的新项目,然后我们取名为 meo1

我们进入到项目目录cd meo1

注意,我们需要建立一个配置文件,项目的文件路径为:project/plugins.sbt

内容如下

addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.1")

然后我们修改build.sbt也就是项目的根目录下面的构建文件,在.settings上面加入

  .enablePlugins(NativeImagePlugin)

最终的构建文件像这样

val scala3Version = "3.1.3"


lazy val root = project
.in(file("."))
.enablePlugins(NativeImagePlugin)
.settings(
name := "meo1",
version := "0.1.0-SNAPSHOT",


scalaVersion := scala3Version,


libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test
)

接着我们运行sbt命令
进入之后,我们执行nativeImage
编译如果没报错,你最终会得到一个执行文件,在target/native-image目录下面
cd target/native-image 运行应用程序

$ ./meo1
Hello world!
I was compiled by Scala 3. :)

$ otool -L ./meo1
./meo1:
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1858.112.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

好的,现在你已经掌握了如何用Scala 3 ,快速开发并编译自己的原生可执行镜像了。非常棒,就像魔法一样。

Support Java 11 based graalvm distributions

There are graalvm distributions based on Java 8 (graalvm) or Java 11 (graalvm-java11):

...
graalvm:19.0.0
graalvm:19.0.2
graalvm:19.1.0
graalvm:19.1.1
graalvm:19.2.0
graalvm:19.2.0-1
graalvm:19.2.1
graalvm:19.3.0
graalvm:19.3.1
graalvm:19.3.2
graalvm:20.0.0
graalvm:20.1.0
graalvm-java11:19.3.0
graalvm-java11:19.3.1
graalvm-java11:19.3.2
graalvm-java11:20.0.0
graalvm-java11:20.1.0

So far the plugin hardcodes graalvm, but it would be nice if we could select Java 11 based version too.

Btw, thanks for nice plugin 👍

GraalVM 20.2.0 support

Is GraalVM 20.2.0 supported? I see the default is 20.1.0, so I'm wondering if there's still a blocker somewhere for 20.2.0.

I tried setting nativeImageVersion := "20.2.0" and it seems to download it fine. But then it fails with:

Downloaded https://repo1.maven.org/maven2/org/graalvm/compiler/compiler/20.2.0/compiler-20.2.0.jar
Exception in thread "main" coursier.jvm.JvmCache$JvmNotFoundInIndex: JVM graalvm:20.2.0 not found in index: No graalvm version matching '20.2.0' found
	at coursier.jvm.JvmCache.$anonfun$getIfInstalled$2(JvmCache.scala:100)
	at coursier.jvm.JvmCache.$anonfun$getIfInstalled$2$adapted(JvmCache.scala:99)
	at coursier.util.Task$.$anonfun$flatMap$2(Task.scala:14)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Installation:

  • Operating system: macOS
  • sbt: 1.3.13
  • Scala: 2.13.3

Additional context

No particular special config set besides nativeImageVersion.

No native-image-configs folder when running nativeImageRunAgent for play framework.

Describe the bug

This is actually a question.
When I run nativeImageRunAgent, there is no native-image-configs in target folder for play framework.
Does anyone know how to fix it?

Thank you

To Reproduce Steps to reproduce the behavior:

  1. Download play framework sample project. https://github.com/Elvis5566/play-scala-seed

  2. Run $sbt nativeImageRunAgent

Expected behavior

There should be a native-image-configs folder which contains reflect-config.json file.

Screenshots

Installation:

  • Operating system: macOS
  • Version: v0.3.2

Search terms
play framework

Running `nativeImage` fails with download error

Describe the bug

I get this download error:

Error while downloading https://repo1.maven.org/maven2/io/get-coursier/coursier-env_2.12/2.0.3/coursier-env_2.12-2.0.3.jar: Resource temporarily unavailable (connect failed), ignoring it
Error while downloading https://repo1.maven.org/maven2/io/get-coursier/coursier-cache_2.12/2.0.3/coursier-cache_2.12-2.0.3.jar: Resource temporarily unavailable (connect failed), ignoring it
Error while downloading https://repo1.maven.org/maven2/io/get-coursier/coursier-cli_2.12/2.0.3/coursier-cli_2.12-2.0.3.jar: Resource temporarily unavailable (connect failed), ignoring it
[error] stack trace is suppressed; run last nativeImageCommand for the full output
[error] (nativeImageCommand) Nonzero exit value: 255

To Reproduce Steps to reproduce the behavior:

  1. Run command
sbt:project> nativeImage

Expected behavior
I would expect it to work and to download anything from the repositories specified in my .repositories file instead of repo1.maven.org

  • Operating system: Windows10 / WSL1
  • Version: 1909 (18363.1350)

Additional context
I am using this sbt script: https://github.com/coursier/sbt-extras
I am using a .jvmopts file with proxy settings
Dependency downloads from our own sonatype repo works.

Search terms

download proxy .repositories

Unable to run nativeImageAgent for GraalVM 21.x

Describe the bug

Running nativeImageAgent with nativeImageVersion set to 21.x fails because of a missing library: Could not find agent library native-image-agent

To Reproduce Steps to reproduce the behavior:

  1. Set nativeImageVersion := "21.3.0" in build.sbt
  2. Run sbt nativeImageAgent

Expected behavior

It should run successfully just as it does in 20.x

Screenshots

❯ sbt buildNativeImage                                                                                                                                                       54s
...
[info] Error occurred during initialization of VM
[info] Could not find agent library native-image-agent on the library path, with error: dlopen(libnative-image-agent.dylib, 0x0001): tried: '/Users/brendan/Library/Caches/Coursier/jvm/[email protected]/Co
ntents/Home/lib/server/./libnative-image-agent.dylib' (no such file), '/Users/brendan/Library/Caches/Coursier/jvm/[email protected]/Contents/Home/lib/server/../libnative-image-agent.dylib' (no such file),
 '/Users/brendan/Library/Caches/Coursier/jvm/[email protected]/Contents/Home/bin/../lib/jli/libnative-image-agent.dylib' (no such file), 'libnative-image-agent.dylib' (no such file), '/usr/local/lib/libna
tive-image-agent.dylib' (no such file), '/usr/lib/libnative-image-agent.dylib' (no such file), '/Users/brendan/workspace/alfred-s3-workflow/libnative-image-agent.dylib' (no such file), '/usr/local/lib/libnati
ve-image-agent.dylib' (no such file), '/usr/lib/libnative-image-agent.dylib' (no such file)
[error] Nonzero exit code returned from runner: 1
[error] (Compile / run) Nonzero exit code returned from runner: 1
[error] Nonzero exit code returned from runner: 1
[error] (nativeImageRunAgent) Nonzero exit code returned from runner: 1
[error] Total time: 7 s, completed Nov 25, 2021, 9:53:23 PM

Installation:

  • Operating system: macOS
  • Version: Montery 12.0.1
  • M1 chip

Additional Context

Cousier is not downloading the lib so it may not be a problem in this repo, but I'm starting with this issue while I investigate in the hopes that someone has an easy fix.

❯ find ~/Library/Caches/Coursier/jvm/[email protected]/Contents -name libnative-image-agent.dylib
❯ find ~/Library/Caches/Coursier/jvm/[email protected]/Contents -name libnative-image-agent.dylib
/Users/brendan/Library/Caches/Coursier/jvm/[email protected]/Contents/Home/lib/libnative-image-agent.dylib

Search terms

nativeImageAgent

[Security] Workflow release.yml is using vulnerable action actions/checkout

The workflow release.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Thank you.

👋🏽 I know this is a slight abuse of the issues tab, and I apologize for that, but I wanted to say thank you for this work.

I was able to (virtually out of the box and with one downgrade to scala 2.13.6) get a native-image compiled for a toy app (take home) for Windows, Mac, and Linux using the same command in about an hour (most of that was googling stuff). It feels like magic!

Need a way to specify parameters for app when using nativeImageRunAgent

Describe the bug

Currently when trying to run the agent, it seems there is no way to specify a parameter for the app. If the app requires mandatory arguments, then I can't use this command.

To Reproduce Steps to reproduce the behavior:

  1. Run command nativeImageRunAgent
  2. Add some parameters after it

Expected behavior

Any arguments after nativeImageRunAgent should be passed to the app.

Screenshots

image

Installation:

  • Operating system: macOS BigSur

Native image for windows not working using github actions

Describe the bug
Trying to generate a native image for windows using github actions I get this error:

Run "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && sbt nativeImage
  "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && sbt nativeImage
  shell: C:\Windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}""
  env:
    CI: true
    JAVA_HOME: C:\Users\runneradmin\.jabba\jdk\[email protected]
The system cannot find the path specified.
Error: Process completed with exit code 1.

Link to the job: https://github.com/tonivade/scala-bricks/runs/5173939939?check_suite_focus=true

I used the example from your project .github/workflows/native.yml

To Reproduce Steps to reproduce the behavior:

  1. Create a clone of my project: https://github.com/tonivade/scala-bricks
  2. Run github actions
  3. You get the error I described

Expected behavior

I expect to generate native image for windows, the same way it's working in your project.
https://github.com/scalameta/sbt-native-image/runs/4599915745?check_suite_focus=true

Screenshots

N/A

Installation:

N/A

Additional context

N/A

Search terms

N/A

Issues migrating from scala-native-packager

Describe the bug
We're trying to use this plugin rather than scala-native-packager but native-image seems to exit unexpectedly.

After configuring the plugin with nativeImageOptions ++= List("--no-fallback") and running the nativeImage command it fails with the following output:

[info] /Users/<redacted>/Library/Caches/Coursier/jvm/[email protected]/Contents/Home/bin/native-image -cp /Users/<redacted>/git/nuclearfamly/famlyi18n/target/native-image-internal/manifest.jar --no-fallback co.famly.i18n.interpolations.I18nExtractor /Users/<redacted>/git/nuclearfamly/famlyi18n/target/native-image/famlyi18n
[/Users/<redacted>/git/nuclearfamly/famlyi18n/target/native-image/famlyi18n:71608]    classlist:  17,077.02 ms,  0.94 GB
[/Users/<redacted>/git/nuclearfamly/famlyi18n/target/native-image/famlyi18n:71608]        (cap):   4,654.91 ms,  0.94 GB
[/Users/<redacted>/git/nuclearfamly/famlyi18n/target/native-image/famlyi18n:71608]        setup:   7,259.70 ms,  0.94 GB
[/Users/<redacted>/git/nuclearfamly/famlyi18n/target/native-image/famlyi18n:71608]     analysis:  31,106.84 ms,  1.92 GB
Error: Classes that should be initialized at run time got initialized during image building:
 scala.collection.immutable.VM was unintentionally initialized at build time. To see why scala.collection.immutable.VM got initialized use -H:+TraceClassInitialization

Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
[error] native-image command failed with exit code '1'

Adding the -H:xxx options changes the output as follows:

Error: Classes that should be initialized at run time got initialized during image building:
 scala.collection.immutable.VM was unintentionally initialized at build time. scala.collection.immutable.VM has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=scala.collection.immutable.VM

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 scala.collection.immutable.VM was unintentionally initialized at build time. scala.collection.immutable.VM has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try marking this class for build-time initialization with --initialize-at-build-time=scala.collection.immutable.VM

	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
	at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:526)
	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:227)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:732)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:732)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:555)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Error: Image build request failed with exit status 1

Installation:

  • Operating system: macOS Catalin (10.15.7)
  • Version: v0.1.0
  • sbt version: 2.12.12

Search terms

Migrate, sbt-native-packager

Graal 22.x Doesn't Work

When trying to use sbt-native-image with:

nativeImageVersion := "22.2.0"

I get:

JVM graalvm-java11:22.2.0 not found in index: No graalvm-java11 version matching '22.2.0' foundraalvm-tester / Compile / compileIncremental 0s
[error] java.lang.RuntimeException: Nonzero exit value: 1
[error] 	at scala.sys.package$.error(package.scala:30)

Native image ready! BUT Error: Image build request failed with exit status 1

Describe the bug

It says the native image was ready even though there was an error:

Installing new component: Native Image (org.graalvm.native-image, version 20.2.0)
[info] C:\Users\fearis\AppData\Local\Coursier\cache\jvm\[email protected]\bin\native-image.cmd -cp C:\Users\fearis\Documents\workspace\CloseProcess\target\scala-2.13\classes;C:\Users\fearis\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.5\scala-library-2.13.5.jar;C:\Users\fearis\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scalameta\svm-subs\101.0.0\svm-subs-101.0.0.jar io.doerfler.ReaperMain C:\Users\fearis\Documents\workspace\CloseProcess\target\native-image\closeprocess
[C:\Users\fearis\Documents\workspace\CloseProcess\target\native-image\closeprocess:3360]    classlist:   2,269.72 ms,  0.96 GB
[C:\Users\fearis\Documents\workspace\CloseProcess\target\native-image\closeprocess:3360]        setup:     506.26 ms,  0.96 GB
Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
[info] Native image ready!
[info] C:\Users\fearis\Documents\workspace\CloseProcess\target\native-image\closeprocess

To Reproduce Steps to reproduce the behavior:

build.sbt

scalaVersion := "2.13.5"
enablePlugins(NativeImagePlugin)

plugins.sbt

addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.0")

Run task nativeImage in sbt.

The tasks succeeds but fails to produce a binary. The reported path where said binary supposedly resides does not exist.

Expected behavior

I expect no error but if there is one I expect the task to fail and not be successful in the eyes of sbt.

Screenshots

image

Installation:

  • Operating system: Windows 10 Pro

Feature Request: Allow to automatically use https://github.com/oracle/graalvm-reachability-metadata

As described in the README of https://github.com/oracle/graalvm-reachability-metadata, the Maven and Gradle plugins are able to automatically use the metadata contained in this repo to facilitate the build of native images.

That'd be awesome if sbt-native-image could have the same feature.

Gradle plugin related doc: https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html#metadata-support
Maven plugin related doc: https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#metadata-support

Related question: oracle/graalvm-reachability-metadata#343

missing native-image-internal directory

In a plain new sbt project with the configuration from the README plus

nativeImageCommand := List("/usr/lib/jvm/java-11-graalvm/bin/native-image")

I got the following error:

sbt:testt> nativeImage
[info] Compiling 1 Scala source to /tmp/tmp.jPSIv0tyLa/testt/target/scala-2.13/classes ...
[error] stack trace is suppressed; run last nativeImage for the full output
[error] (nativeImage) java.nio.file.NoSuchFileException: /tmp/tmp.jPSIv0tyLa/testt/target/native-image-internal/manifest.jar
[error] Total time: 5 s, completed 30 Aug 2020, 01:36:15
sbt:testt> last nativeImage
[error] java.nio.file.NoSuchFileException: /tmp/tmp.jPSIv0tyLa/testt/target/native-image-internal/manifest.jar
[error] 	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
[error] 	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
[error] 	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
[error] 	at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
[error] 	at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
[error] 	at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
[error] 	at sbtnativeimage.NativeImagePlugin$.createManifestJar(NativeImagePlugin.scala:186)
[error] 	at sbtnativeimage.NativeImagePlugin$.$anonfun$projectSettings$20(NativeImagePlugin.scala:143)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] 	at sbt.Execute.work(Execute.scala:290)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:834)
[error] (nativeImage) java.nio.file.NoSuchFileException: /tmp/tmp.jPSIv0tyLa/testt/target/native-image-internal/manifest.jar

Creating the native-image-internal subdirectory fixes the problem.

Installation:

  • Operating system: Arch Linux
  • Version: v0.1.2
  • sbt 1.3.13
  • Scala 2.13.3
  • GraalVM Version 20.2.0 (Java Version 11.0.8)

Scala 3, Windows 10 failing to produce a native image, Error: Native-image building on Windows currently only supports target architecture: AMD64 (x86 unsupported)

Github project https://github.com/PhilAndrew/dotty-project-template

Error: Native-image building on Windows currently only supports target architecture: AMD64 (x86 unsupported)

Running within C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools Developer Command Prompt for VS 2019

C:\home\projects\r\dotty-project-template>sbt nativeImage
[info] welcome to sbt 1.4.2 (Oracle Corporation Java 11.0.2)
[info] loading global plugins from C:\Users\philip.sbt\1.0\plugins
[info] loading settings for project dotty-project-template-build-build-build from metals.sbt ...
[info] loading project definition from C:\home\projects\r\dotty-project-template\project\project\project
[info] loading settings for project dotty-project-template-build-build from metals.sbt ...
[info] loading project definition from C:\home\projects\r\dotty-project-template\project\project
[success] Generated .bloop\dotty-project-template-build-build.json
[success] Total time: 1 s, completed 3 Dec. 2020, 7:52:58 pm
[info] loading settings for project dotty-project-template-build from metals.sbt,plugins.sbt ...
[info] loading project definition from C:\home\projects\r\dotty-project-template\project
[success] Generated .bloop\dotty-project-template-build.json
[success] Total time: 1 s, completed 3 Dec. 2020, 7:52:59 pm
[info] loading settings for project root from build.sbt ...
[info] set current project to dotty-simple (in build file:/C:/home/projects/r/dotty-project-template/)
[info] C:\Users\philip\AppData\Local\Coursier\cache\jvm\[email protected]\bin\native-image.cmd -cp C:\home\projects\r\dotty-project-template\target\scala-3.0.0-M2\classes;C:\Users\philip\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scalameta\svm-subs\101.0.0\svm-subs-101.0.0.jar;C:\Users\philip\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala3-library_3.0.0-M2\3.0.0-M2\scala3-library_3.0.0-M2-3.0.0-M2.jar;C:\Users\philip\AppData\Local\Coursier\cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.13.4\scala-library-2.13.4.jar Main C:\home\projects\r\dotty-project-template\target\native-image\dotty-simple
[C:\home\projects\r\dotty-project-template\target\native-image\dotty-simple:68156] classlist: 3,387.06 ms, 0.96 GB
[C:\home\projects\r\dotty-project-template\target\native-image\dotty-simple:68156] setup: 775.27 ms, 0.96 GB
Error: Native-image building on Windows currently only supports target architecture: AMD64 (x86 unsupported)
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
[info] Native image ready!
[info] C:\home\projects\r\dotty-project-template\target\native-image\dotty-simple
[success] Total time: 9 s, completed 3 Dec. 2020, 7:53:11 pm

C:\home\projects\r\dotty-project-template>sbt nativeImage

simple example fails to build native image

Describe the bug

An extremely simple example fails to generate a native executable.

To Reproduce Steps to reproduce the behavior:

create the following three files in an empty directory:

% cat build.sbt
enablePlugins(NativeImagePlugin)
mainClass.in(Compile) := Some("Prog")
% cat Prog.scala
object Prog { def main(args: Array[String]): Unit = println("hi!") }
% cat project/build.properties
sbt.version=1.3.13

start sbt and issue the 'nativeCompile' command:

% sbt
[info] welcome to sbt 1.3.13 (Red Hat, Inc. Java 14.0.2)
[info] loading settings for project global-plugins from sbt-native-packager.sbt,sbt-jmh.sbt,sbt-dotty.sbt,sbt-github-packages.sbt,sbt-scalafmt.sbt,sbt-coverage.sbt,sbt-missinglink.sbt,idea.sbt,sbt-native-image.sbt,sbt-metals.sbt,sbt-explicitDependences.sbt,sbt-updates.sbt,sbt-scalafix.sbt ...
[info] loading global plugins from /home/mtk/.sbt/1.0/plugins
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] loading project definition from /home/mtk/tmp/ni/project
[warn] undefined keys githubOwner and githubRepository
[warn] retaining pre-existing publication settings
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] loading settings for project ni from build.sbt ...
[info] set current project to ni (in build file:/home/mtk/tmp/ni/)
[info] sbt server started at local:///home/mtk/.sbt/1.0/server/0b1762cb6463b64b1743/sock
sbt:ni> nativeImage
[warn] undefined keys githubOwner and githubRepository
[warn] retaining pre-existing publication settings
[info] Compiling 1 Scala source to /home/mtk/tmp/ni/target/scala-2.12/classes ...
[info] /home/mtk/.cache/coursier/jvm/[email protected]/bin/native-image -cp /home/mtk/tmp/ni/target/native-image-internal/manifest.jar Prog /home/mtk/tmp/ni/target/native-image/ni
Build on Server(pid: 255308, port: 33383)*
[/home/mtk/tmp/ni/target/native-image/ni:255308] classlist: 5,418.49 ms, 0.96 GB
[/home/mtk/tmp/ni/target/native-image/ni:255308] setup: 602.92 ms, 0.96 GB
Error: substitution target for scala.meta.internal.svm_subs.Target_scala_runtime_Statics is not loaded. Use field onlyWith in the TargetClass annotation to make substitution only active when needed.
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1
[error] native-image command failed with exit code '1'
[error] (nativeImage) native-image command failed with exit code '1'
[error] Total time: 10 s, completed Sep 12, 2020, 5:07:17 PM
sbt:ni>

Expected behavior

a native image for the trivial program should have been created. or an error message that explains the problem in an understandable way?

Installation:

  • Operating system: Fedora Linux
  • Version: v32

Additional context

the same result occurs if JDK 11 is used instead of 14.

Windows native-image error for large classpath

Describe the bug

Windows native image builds fail when there are a large number of JARs in the classpath.
It looks like previously a single manifest.jar was used to avoid this issue, but this was removed for Windows in #9

To Reproduce Steps to reproduce the behavior:

  1. Create a new SBT project with a large number (~50) of dependencies
  2. Run sbt nativeImage

Expected behavior
native-image is invoked to create the binary

Screenshots
Instead, the command fails due to the length of the command:

[info] C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\bin\native-image.cmd -cp [long class path here] com.example.MyClass D:\a\my-project\my-project\target\native-image\my-project
 The command line is too long.
[error] native-image command failed with exit code '1'
[error] (my-project / nativeImage) native-image command failed with exit code '1'

Installation:

  • Operating system: Windows
  • Version: v0.3.0

Additional context
I've been able to work around this for now by pre-assembling a fat jar with sbt-assembly, and then overriding the classpath with the result:

fullClasspath in Compile := Seq(Attributed(assembly.value)(AttributeMap.empty)),

Search terms

Windows classpath

Readme let me confuse

 sbt
> myNativeImageProject/nativeImage

What i really run

cd myproject
sbt
# then run nativeImage
sbt:myproject> nativeImage

I have no that command: myNativeImageProject/nativeImage

and my configure file

build.sbt

val scala3Version = "3.1.3"

lazy val root = project
  .in(file("."))
  .enablePlugins(NativeImagePlugin)
  .settings(
    name := "bsmi_sc3",
    version := "0.1.0-SNAPSHOT",

    scalaVersion := scala3Version,

    libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test
  )

I only added one line, it's ok


  .enablePlugins(NativeImagePlugin)

nativeImage on Windows fails in 0.3.1 and 0.3.2 (No issue in 0.3.0)

Describe the bug
nativeImage on Windows fails in sbt-native-image 0.3.1 and 0.3.2 (No issue in 0.3.0).

I'm getting the following error when running nativeImage on Windows platform in GitHub Actions.
https://github.com/Kevin-Lee/whatsub/runs/6899749209?check_suite_focus=true#step:7:304

========================================================================================================================
GraalVM Native Image: Generating 'D:\a\whatsub\whatsub\cli\target\native-image\whatsub-cli' (executable)...
========================================================================================================================
[1/7] Initializing...                                                                                    (0.0s @ 0.10GB)
Fatal error: java.lang.NoClassDefFoundError: pirate/Command
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
	at java.base/java.lang.Class.getDeclaredMethod(Class.java:2673)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:359)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)
Caused by: java.lang.ClassNotFoundException: pirate.Command
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 7 more
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1678)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1389)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1350)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1337)
[error] native-image command failed with exit code '1'
[error] (cli / nativeImage) native-image command failed with exit code '1'
[error] Total time: 30 s, completed Jun 15, 2022, 12:37:27 PM

I get no error and build is successfully done if I use 0.3.0.

To Reproduce Steps to reproduce the behavior:

  1. Run command nativeImage
  2. Watch the build log please.

Expected behavior

Successful build like this one: https://github.com/Kevin-Lee/whatsub/runs/6900296176?check_suite_focus=true#step:7:306
It's the build result when sbt-native-image 0.3.0 is used.

Screenshots

Failed build when 0.3.1 or 0.3.2 is used. (This screenshot was taken from the build with 0.3.2).
Screen Shot 2022-06-15 at 11 19 15 pm

Installation:

  • Operating system: Windows
  • Version: windows-latest from GitHub Actions

Additional Info
The command executed by GitHub Actions:

Executing [
'C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\bin\java.exe' \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
-Dsubstratevm.IgnoreGraalVersionCheck=true \
--add-exports=java.base/com.sun.crypto.provider=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.access.foreign=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.event=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.logger=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.module=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.perf=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.platform=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED \
--add-exports=java.base/sun.invoke.util=ALL-UNNAMED \
--add-exports=java.base/sun.net=ALL-UNNAMED \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.factory=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.repository=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.scope=ALL-UNNAMED \
--add-exports=java.base/sun.reflect.generics.tree=ALL-UNNAMED \
--add-exports=java.base/sun.security.jca=ALL-UNNAMED \
--add-exports=java.base/sun.security.provider=ALL-UNNAMED \
--add-exports=java.base/sun.security.ssl=ALL-UNNAMED \
--add-exports=java.base/sun.security.util=ALL-UNNAMED \
--add-exports=java.base/sun.security.x509=ALL-UNNAMED \
--add-exports=java.base/sun.text.spi=ALL-UNNAMED \
--add-exports=java.base/sun.util.calendar=ALL-UNNAMED \
--add-exports=java.base/sun.util.cldr=ALL-UNNAMED \
--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED \
--add-exports=java.base/sun.util.locale=ALL-UNNAMED \
--add-exports=java.base/sun.util.resources=ALL-UNNAMED \
--add-exports=java.base/sun.util=ALL-UNNAMED \
--add-exports=java.desktop/sun.java2d.pipe=ALL-UNNAMED \
--add-exports=java.desktop/sun.java2d=ALL-UNNAMED \
--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \
--add-exports=java.management/sun.management=ALL-UNNAMED \
--add-exports=java.xml.crypto/org.jcp.xml.dsig.internal.dom=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.events=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal.handlers=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal.jfc=ALL-UNNAMED \
--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED \
--add-exports=jdk.management/com.sun.management.internal=ALL-UNNAMED \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-Xms1g \
-Xmx601[257](https://github.com/Kevin-Lee/whatsub/runs/6899749209?check_suite_focus=true#step:7:258)7376 \
-Djava.awt.headless=true \
-Dorg.graalvm.version=22.1.0 \
-Dorg.graalvm.config=CE \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
'-javaagent:C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\builder\svm.jar' \
-cp \
'C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\builder\native-image-base.jar;C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\builder\objectfile.jar;C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\builder\pointsto.jar;C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\builder\svm.jar' \
--module-path \
'C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\truffle\truffle-api.jar' \
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus' \
-imagecp \
'D:\a\whatsub\whatsub\cli\target\native-image-internal\manifest.jar;D:\a\whatsub\whatsub\cli\target\scala-3.1.2\classes;D:\a\whatsub\whatsub\core\target\scala-3.1.2\classes;D:\a\whatsub\whatsub\cli\target\native-image-internal\classes;D:\a\whatsub\whatsub\cli\target\native-image-internal\scala3-library_3-3.1.2.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\svm-subs-101.0.0.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\cats-core_3-2.7.0.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\cats-effect_3-3.3.6.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\cats-parse_3-0.3.4.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\effectie-cats-effect3_3-2.0.0-SNAPSHOT.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\extras-cats_3-0.4.0.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\extras-scala-io_3-0.4.0.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\scalaz-core_2.13-7.2.31.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\scalaz-effect_2.13-7.2.31.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\scala-library-2.13.8.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\cats-kernel_3-2.7.0.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\simulacrum-scalafix-annotations_3-0.5.4.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\cats-effect-kernel_3-3.3.6.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\cats-effect-std_3-3.3.6.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\effectie-core_3-2.0.0-SNAPSHOT.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\effectie-cats_3-2.0.0-SNAPSHOT.jar;D:\a\whatsub\whatsub\cli\target\native-image-internal\slf4j-api-1.7.32.jar;C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\library-support.jar' \
'-H:Path=D:\a\whatsub\whatsub\cli\target\native-image' \
'-H:DynamicProxyConfigurationResources@jar:file:///D:/a/whatsub/whatsub/cli/target/native-image-internal/cats-effect_3-3.3.6.jar!/META-INF/native-image/org.typelevel/cats-effect/native-image.properties=META-INF/native-image/org.typelevel/cats-effect/sun-misc-signal-proxy-config.json' \
-H:FallbackThreshold=0 \
-H:+ReportExceptionStackTraces \
-H:ClassInitialization=:build_time \
-H:+AddAllCharsets \
-H:+ReportUnsupportedElementsAtRuntime \
'-H:CLibraryPath=C:\Users\runneradmin\AppData\Local\Coursier\cache\jvm\[email protected]\lib\svm\clibraries\windows-amd64' \
'-H:Class@explicit main-class=whatsub.WhatsubApp' \
'-H:Name@explicit image name=D:\a\whatsub\whatsub\cli\target\native-image\whatsub-cli'
]

Unused Keys Warning But The Versions and NativeImage JVM Defined Are Followed

Warnings are seen after SBT is started

[warn] there are 2 keys that are not used by any other settings/tasks:                             
[warn] * root / nativeImageJvm
[warn]   +- /project/foo/build.sbt:31
[warn] * root / nativeImageVersion
[warn]   +- /project/foo/build.sbt:30                     

when nativeImageJvm and nativeImageVersion are defined in project settings i.e.

    .settings(
      name = "foo-bar",
      nativeImageVersion := "20.3.0",
      nativeImageJvm := "graalvm-ce-11",
      ...)

To Reproduce Steps to reproduce the behavior:

    1. Run sbt with these properties defiend

Expected behavior

No warning or how to disable these warnings

Installation:

  • Operating system: Linux / Ubuntu
  • Version: v20.04

Additional context

SBT v1.4.1 and sbt-native-image v0.2.2

Windows support

It would be super helpful if plugin supports building native images for Windows. Right now it's not working, because coursier program inside internal directory is not in a Win32-executable format:

sbt:native-hello-world> nativeImage
[info] C:\Dev\native-hello-world\target\native-image-internal\coursier launch --jvm graalvm:20.1.0 org.graalvm.nativeimage:svm-driver:20.1.0 -- -cp C:\Dev\native-hello-world\target\native-image-internal\manifest.jar Main C:\Dev\native-hello-world\target\native-image\native-hello-world
[error] stack trace is suppressed; run last nativeImage for the full output
[error] (nativeImage) java.io.IOException: Cannot run program "C:\Dev\native-hello-world\target\native-image-internal\coursier" (in directory "C:\Dev\native-hello-world\target\native-image"): CreateProcess error=193, %1 is not a valid Win32 application
[error] Total time: 0 s, completed 3 сент. 2020 г., 15:26:07

Tested on Windows 10.

FeatureRequest: support for setting up Experimental Agent Options

I would like to use the features described in here like agent-extracted-predefined-classes or experimental-omit-config-from-classpath, but I don't think there is any way to set them because the agentOptions is created like this:

val agentOption = s"-agentlib:native-image-agent=$agentConfig=${nativeImageAgentOutputDir.value}"`

java.lang.NoClassDefFoundError: Ljava/nio/ByteBuffer - when running a JavaFX app

Describe the bug

If I build a native image with JavaFX and try to run it, an error crashes the app at initialization:

Exception in thread "main" java.lang.RuntimeException: java.lang.NoClassDefFoundError: Ljava/nio/ByteBuffer;
  | => nat com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:290)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288)
...

To Reproduce Steps to reproduce the behavior:

I prepared a minimal example and put the steps to reproduce the error in the description:
https://github.com/makingthematrix/javafx_sbt_minimal

Missing artifacts for 0.3.3 release

Currently I'm using it for the examples project of jsoniter-scala and it works fine for v0.3.2.

Here is a list of checked repositories for v0.3.3:

[warn] 
[warn] 	Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn] 		org.scalameta:sbt-native-image:0.3.3 (sbtVersion=1.0, scalaVersion=2.12)
[warn] 
[warn] 	Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scalameta:sbt-native-image;sbtVersion=1.0;scalaVersion=2.12:0.3.3
[error]   Not found
[error]   Not found
[error]   not found: https://repo1.maven.org/maven2/org/scalameta/sbt-native-image_2.12_1.0/0.3.3/sbt-native-image-0.3.3.pom
[error]   not found: /home/andriy/.ivy2/local/org.scalameta/sbt-native-image/scala_2.12/sbt_1.0/0.3.3/ivys/ivy.xml
[error]   not found: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scalameta/sbt-native-image/scala_2.12/sbt_1.0/0.3.3/ivys/ivy.xml
[error]   not found: https://repo.typesafe.com/typesafe/ivy-releases/org.scalameta/sbt-native-image/scala_2.12/sbt_1.0/0.3.3/ivys/ivy.xml

No nativeImageAgentOutputDir are created after nativeImagerunAgent

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. Run command 'nativeImageRunAgent' and leave 'nativeImageAgentOutputDir' as default
  2. No nativeImageAgentOutputDir folder are created

Expected behavior
nativeImageAgentOutputDir folder are created

Installation:

  • Operating system: macOS
  • Version: v0.3.0

Unable to get graalvm in index on macm1

Describe the bug

Unable to find graalvm in index when running nativeImage command.

To Reproduce Steps to reproduce the behavior:
with additional setting of:

JVM graalvm-java11:21.0.0 not found in index: JVM graalvm-java11 not found

and run sbt myproject/nativeImage.

  1. Run command 'sbt myproject/nativeImage'

Expected behavior

I would expect the binary to be generated

Installation:

  • Operating system: macOS/Linux - mac m1
  • Version: Monterey 12.2.1

Additional context

I can see a graalvm-java11 entry "...github.com/coursier/jvm-index/.../index.json" entry.

Search terms

m1 java11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.