List icon Contents

Configuring Gradle project

This page describes how to add JxBrowser to a Gradle project.

To add JxBrowser to a Gradle project, you must include the JxBrowser Gradle plugin in your build script file build.gradle(.kts) and configure the project’s dependencies there.

Applying the plugin

To apply the JxBrowser Gradle plugin, use the plugins block from the Gradle DSL:

Groovy
Kotlin
plugins {
    id 'com.teamdev.jxbrowser' version '1.2.1'
}
plugins {
    id("com.teamdev.jxbrowser") version "1.2.1"
}

Configuring the plugin

Once applied, the plugin can be configured via the jxbrowser extension in the build.gradle(.kts) file.

Version

Set the required library version using the version property:

Groovy
Kotlin
jxbrowser {
    version '7.41.4'
}
jxbrowser {
    version = "7.41.4"
}

The version property is mandatory, omitting it will result in an IllegalStateException.

Repository

You can specify the location of JxBrowser repository to use, which can be either North America or Europe:

Groovy
Kotlin
jxbrowser {
    version '7.41.4'
    repository Repository.EUROPE
}
jxbrowser {
    version = "7.41.4"
    repository = Repository.EUROPE
}

You can also specify a custom repository via its URL, as shown below:

Groovy
Kotlin
jxbrowser {
    version '7.41.4'
    repository 'https://my.custom.repository'
}
jxbrowser {
    version = "7.41.4"
    repository = "https://my.custom.repository"
}

If the repository property is not specified, the location is set to North America.

Preview builds

Use includePreviewBuilds() to add a repository with JxBrowser preview builds to the project:

Groovy
Kotlin
jxbrowser {
    version '7.41.4'
    includePreviewBuilds()
}
jxbrowser {
    version = "7.41.4"
    includePreviewBuilds()
}

Dependencies

Cross-platform

To add JxBrowser library that works on Windows, macOS, and Linux, please add the following code:

Groovy
Kotlin
dependencies {
    implementation jxbrowser.crossPlatform
}
dependencies {
    implementation(jxbrowser.crossPlatform)
}

Platform-specific

If you need JxBrowser JAR files only for a specific platform, you can use the appropriate dependency as described below.

If your Java application runs only on Windows and macOS platforms, and you do not need Linux dependency, you can include only Windows and macOS dependencies.

Windows 32-bit

Groovy
Kotlin
dependencies {
    implementation jxbrowser.win32
}
dependencies {
    implementation(jxbrowser.win32)
}

Windows 64-bit

Groovy
Kotlin
dependencies {
    implementation jxbrowser.win64
}
dependencies {
    implementation(jxbrowser.win64)
}

macOS 64-bit

Groovy
Kotlin
dependencies {
    implementation jxbrowser.mac
}
dependencies {
    implementation(jxbrowser.mac)
}

macOS 64-bit ARM

Groovy
Kotlin
dependencies {
    implementation jxbrowser.macArm
}
dependencies {
    implementation(jxbrowser.macArm)
}

Linux 64-bit

Groovy
Kotlin
dependencies {
    implementation jxbrowser.linux64
}
dependencies {
     implementation(jxbrowser.linux64)
}

Linux 64-bit ARM

Groovy
Kotlin
dependencies {
    implementation jxbrowser.linuxArm
}
dependencies {
    implementation(jxbrowser.linuxArm)
}

Current platform

To detect the current platform and add the corresponding Chromium binaries, use the following dependency:

Groovy
Kotlin
dependencies {
    implementation jxbrowser.currentPlatform
}
dependencies {
    implementation(jxbrowser.currentPlatform)
}

GUI toolkit

Swing

Groovy
Kotlin
dependencies {
    implementation jxbrowser.swing
}
dependencies {
    implementation(jxbrowser.swing)
}

JavaFX

Groovy
Kotlin
dependencies {
    implementation jxbrowser.javafx
}
dependencies {
    implementation(jxbrowser.javafx)
}

SWT

Groovy
Kotlin
dependencies {
    implementation jxbrowser.swt
}
dependencies {
    implementation(jxbrowser.swt)
}

Summary

Here is the complete code of build.gradle(.kts):

Groovy
Kotlin
import com.teamdev.jxbrowser.gradle.Repository

plugins {
    id 'java'
    id 'com.teamdev.jxbrowser' version '1.2.1'
}

jxbrowser {
    // The JxBrowser version. A mandatory field.
    version '7.41.4'

    // The location of JxBrowser repository to use. It's either North America or Europe.
    // If not specified, the location is set to North America.
    repository Repository.NORTH_AMERICA

    // Alternatively, it may point to a custom repo via its URL, as follows:
    // repository "https://my.custom.repository"

    // Adds a repository with JxBrowser preview builds to the project.
    includePreviewBuilds()
}

dependencies {
    // Adds a dependency to the core JxBrowser API.
    implementation jxbrowser.core

    // Adds dependencies to the Chromium binaries for all supported platforms.
    implementation jxbrowser.crossPlatform

    // Adds a dependency to the platform-specific Chromium binaries.
    implementation jxbrowser.mac
    implementation jxbrowser.macArm
    implementation jxbrowser.win32
    implementation jxbrowser.win64
    implementation jxbrowser.linux64
    implementation jxbrowser.linuxArm

    // Detects the current platform and adds the corresponding Chromium binaries.
    implementation jxbrowser.currentPlatform

    // Adds dependencies to the UI toolkit integrations.
    implementation jxbrowser.swt
    implementation jxbrowser.swing
    implementation jxbrowser.javafx
}
import com.teamdev.jxbrowser.gradle.Repository

plugins {
    java
    id("com.teamdev.jxbrowser") version "1.2.1"
}

jxbrowser {
    // The JxBrowser version. A mandatory field.
    version = "7.41.4"

    // The location of JxBrowser repository to use. It's either North America or Europe.
    // If not specified, the location is set to North America.
    repository = Repository.NORTH_AMERICA

    // Alternatively, it may point to a custom repo via its URL, as follows:
    // repository = "https://my.custom.repository"

    // Adds a repository with JxBrowser preview builds to the project.
    includePreviewBuilds()
}

dependencies {
    // Adds a dependency to the core JxBrowser API.
    implementation(jxbrowser.core)

    // Adds dependencies to the Chromium binaries for all supported platforms.
    implementation(jxbrowser.crossPlatform)

    // Adds a dependency to the platform-specific Chromium binaries.
    implementation(jxbrowser.mac)
    implementation(jxbrowser.macArm)
    implementation(jxbrowser.win32)
    implementation(jxbrowser.win64)
    implementation(jxbrowser.linux64)
    implementation(jxbrowser.linuxArm)
    
    // Detects the current platform and adds the corresponding Chromium binaries.
    implementation(jxbrowser.currentPlatform)
    
    // Adds dependencies to the UI toolkit integrations.
    implementation(jxbrowser.swt)
    implementation(jxbrowser.swing)
    implementation(jxbrowser.javafx)
}