Add new sbt-native-image plugin that helps generate a correct native … (#2494)

* Add new sbt-native-image plugin that helps generate a correct native image for the cli

* Initialize everything at build time to try and get cli working again

* Get server working with native image build

* Add '--no-fallback' which will report failures if we fail to build a standalone image

* Revert server project, file issue 2506 to indicate problems with server build

* Add native cli publishing using github actions

* Preprend 'app/' to paths

* Enable http,https protocols on cli

* Remove old graalvm plugin settings related to sbt native packager
This commit is contained in:
Chris Stewart 2021-01-13 09:41:00 -06:00 committed by GitHub
parent 4e285e6746
commit 0f84e3d158
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 36 deletions

57
.github/workflows/native.yml vendored Normal file
View file

@ -0,0 +1,57 @@
# Docs:
# https://github.com/scalameta/sbt-native-image#generate-native-image-from-github-actions
name: Native Image bitcoin-s-cli
on:
push:
branches:
- master
pull_request:
release:
types: [published]
jobs:
unix:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
include:
- os: macOS-latest
uploaded_filename: bitcoin-s-cli-x86_64-apple-darwin
local_path: app/cli/target/native-image/bitcoin-s-cli
- os: ubuntu-latest
uploaded_filename: bitcoin-s-cli-x86_64-pc-linux
local_path: app/cli/target/native-image/bitcoin-s-cli
- os: windows-latest
uploaded_filename: bitcoin-s-cli-x86_64-pc-win32.exe
local_path: app\cli\target\native-image\bitcoin-s-cli.exe
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
- run: git fetch --tags || true
- run: sbt cli/nativeImage
shell: bash
if: ${{ matrix.os != 'windows-latest' }}
- run: echo $(pwd)
shell: bash
- name: sbt cliTest/test
shell: cmd
if: ${{ matrix.os == 'windows-latest' }}
run: >-
"C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && sbt
cli/nativeImage
- uses: actions/upload-artifact@master
with:
path: ${{ matrix.local_path }}
name: ${{ matrix.uploaded_filename }}
- name: Upload release
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ matrix.local_path }}
asset_name: ${{ matrix.uploaded_filename }}
asset_content_type: application/zip

View file

@ -2,17 +2,12 @@ name := "bitcoin-s-cli"
libraryDependencies ++= Deps.cli(scalaVersion.value)
graalVMNativeImageOptions ++= Seq(
"-H:EnableURLProtocols=http",
nativeImageOptions ++= Seq(
"-H:+ReportExceptionStackTraces",
// builds a stand-alone image or reports a failure
"--initialize-at-build-time",
"--no-fallback",
// without this, we get complaints about Function3
// I'm not sure why, though...
"--initialize-at-build-time=scala.Function3",
"--report-unsupported-elements-at-runtime",
"--verbose",
"--allow-incomplete-classpath"
"--enable-http",
"--enable-https"
)
enablePlugins(JavaAppPackaging, GraalVMNativeImagePlugin)
enablePlugins(JavaAppPackaging, NativeImagePlugin)

View file

@ -8,20 +8,8 @@ libraryDependencies ++= Deps.oracleServer
mainClass := Some("org.bitcoins.oracle.server.OracleServerMain")
graalVMNativeImageOptions ++= Seq(
"-H:EnableURLProtocols=http",
"-H:+ReportExceptionStackTraces",
// builds a stand-alone image or reports a failure
"--no-fallback",
// without this, we get complaints about Function3
// I'm not sure why, though...
"--initialize-at-build-time=scala.Function3",
"--report-unsupported-elements-at-runtime",
"--verbose"
)
packageSummary := "A DLC Oracle"
packageDescription := "A basic DLC oracle that allows you to commit to events and sign them"
enablePlugins(JavaAppPackaging, GraalVMNativeImagePlugin)
enablePlugins(JavaAppPackaging)

View file

@ -8,21 +8,9 @@ libraryDependencies ++= Deps.server(scalaVersion.value)
mainClass := Some("org.bitcoins.server.BitcoinSServerMain")
graalVMNativeImageOptions ++= Seq(
"-H:EnableURLProtocols=http",
"-H:+ReportExceptionStackTraces",
// builds a stand-alone image or reports a failure
"--no-fallback",
// without this, we get complaints about Function3
// I'm not sure why, though...
"--initialize-at-build-time=scala.Function3",
"--report-unsupported-elements-at-runtime",
"--verbose"
)
packageSummary := "A Bitcoin neutrino node and wallet"
packageDescription := "Runs a Bitcoin neutrino node and wallet, has functionality " +
"for many different modes and configuration options, see more at https://bitcoin-s.org/docs/applications/server"
enablePlugins(JavaAppPackaging, GraalVMNativeImagePlugin)
enablePlugins(JavaAppPackaging)

View file

@ -33,3 +33,6 @@ addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "6.4.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")
//https://github.com/scalameta/sbt-native-image
addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.2.2")