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:

plugins {
    id 'com.teamdev.jxbrowser' version '1.0.2'
}
plugins {
    id("com.teamdev.jxbrowser") version "1.0.2"
}

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:

jxbrowser {
    version '7.39.1'
}
jxbrowser {
    version = "7.39.1"
}

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:

jxbrowser {
    version '7.39.1'
    repository Repository.EUROPE
}
jxbrowser {
    version = "7.39.1"
    repository = Repository.EUROPE
}

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

jxbrowser {
    version '7.39.1'
    repository 'https://my.custom.repository'
}
jxbrowser {
    version = "7.39.1"
    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:

jxbrowser {
    version '7.39.1'
    includePreviewBuilds()
}
jxbrowser {
    version = "7.39.1"
    includePreviewBuilds()
}

Dependencies

Cross-platform

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

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

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

Windows 64-bit

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

macOS 64-bit

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

macOS 64-bit ARM

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

Linux 64-bit

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

Linux 64-bit ARM

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:

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

GUI toolkit

Swing

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

JavaFX

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

SWT

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

Summary

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

import com.teamdev.jxbrowser.gradle.Repository

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

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

    // 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.0.2"
}

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

    // 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)
}
Go Top