-
Notifications
You must be signed in to change notification settings - Fork 3
How to Import
Platform | Prerequisites |
---|---|
Windows | Developers and end-users must have the WebView2 runtime installed on their system for any version of Windows before Windows 11. |
Linux | The GTK and WebKit2GTK libraries are required for development and distribution. |
See webview#prerequisites for more information.
- Add GitLab Packages for Gradle
webviewko is published in GitLab Package Registry, so you need to add webviewko's maven repo by using:
repositories {
maven("https://gitlab.com/api/v4/projects/38224197/packages/maven")
}
- Import webviewko
dependencies {
implementation("com.github.winterreisender:webviewko:0.2.0")
implementation("com.github.winterreisender:webviewko-jvm:0.2.0")
}
These steps is no longer required in 0.6, except Linux.
- Add GitLab Packages for Gradle
webviewko is published in GitlLab Package Registry, so you need to add webviewko's maven repo by using:
repositories {
maven("https://gitlab.com/api/v4/projects/38224197/packages/maven")
}
- Import webviewko
kotlin {
...
sourceSets {
val nativeMain by getting {
dependencies {
implementation("com.github.winterreisender:webviewko-linux:0.2.0-SNAPSHOT")
}
}
val nativeTest by getting
}
}
-
Download dll/so/dylib for your OS
Like other native dynamic link lib, you need to make sure your program (.exe) can find the dynamic libs (.dll, .so, .dylib).
You can find these files in the webviewko's project or in webview_nativebuild -
Link the dynamic lib (For Linux and macOS)
AddlinkerOpts
to link the.so
or.dylib
. Suppose you save these files atnative/src/nativeMain/resources/linuxx64/
,native/src/nativeMain/resources/mingwx64/
andnative/src/nativeMain/resources/macosx64/
You also need change the rpath for you program to find the.so
file by adding-Wl,-rpath=$ORIGIN
kotlin{
...
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
if(hostOs == "Linux")
linkerOpts("native/src/nativeMain/resources/linuxx64/libwebview.so","-Wl,-rpath=${'$'}ORIGIN")
if(hostOs == "Mac OS X")
linkerOpts("native/src/nativeMain/resources/macosx64/libwebview.dylib","-Wl,-rpath=${'$'}ORIGIN")
}
}
}
}
- Copy
.so/.dll/.dylib
to output folder.
You can either do it manually or using Gradle:
kotlin{
nativeTarget.apply {
binaries {
executable {
copy {
from(rootDir.resolve("native/src/nativeMain/resources/linux"))
into(outputDirectory)
include("*.dll", "*.dylib", "*.so")
duplicatesStrategy= DuplicatesStrategy.WARN
}}}}}
A full example can be found at Winterreisender/webviewkoCLI
- Download
.jar
from GitHub Releases - Copy
webviewko-0.0.1.jar
to your project, suppose it insrc/main/libs/webviewjar-0.0.1.jar
- If you are using a build system like Gradle, Maven, you need to manually add webviewko as local dependency for your project. In Gradle, you need:
dependencies { implementation(fileTree(mapOf( "dir" to "src/main/libs", "include" to listOf("*.jar") ))) }
Please notice that GitHub Maven service doesn’t allow for unauthorized access (see How to allow unauthorised read access to GitHub packages maven repository? ) You can read GitHub docs to Learn more about Maven or Gradle
repositories {
maven {
url = uri("https://maven.pkg.github.com/Winterreisender/webviewko")
credentials {
username = "YOUR-USERNAME"
password = "YOUR-GITHUB-TOKEN"
}
}
}