Creating and Using an Offline Repository

Developing MicroEJ projects requires the Gradle plugins used for the build, as well as the modules (Add-On Libraries, Foundation Libraries, …) used by the project code. All these artifacts must be available in artifact repositories.

MicroEJ provides them as online repositories which can be used directly, thanks to the configuration described in the Configure Repositories section. However, it is not always possible to rely on these online repositories. Gradle allows to use repositories packaged as a set of local folders and files, called Offline Module Repositories.

This tutorial explains how to create and use Offline Module Repositories for your MicroEJ project.

Offline Repository for the Gradle Plugins

The first step is to create an Offline Repository for the Gradle plugins. The artifacts of the Gradle plugins are available in the SDK 6 Forge repository.

Download SDK 6 Gradle Plugins Repository

Download SDK 6 Gradle Plugins Repository

  • In the upcoming popup, check the Include Checksum Files checkbox.

  • Click on Download.

Now that the Offline Repository of the Gradle plugins has been retrieved, you can configure your projects to use it:

  • Unzip the downloaded archive at the location of your choice, for example in the C:\sdk6-repository folder.

  • Add the following repository definition at the beginning of your repositories configuration script:

fun RepositoryHandler.offlineMicroEjSdk() {
  val sdk6Uri = uri("C:\\sdk6-repository")

  /* Offline SDK 6 repository for Maven/Gradle modules */
  maven {
    name = "offlineSDKRepositoryMaven"
    url = sdk6Uri
  }

  /* Offline SDK 6 repository for Ivy modules */
  ivy {
    name = "offlineSDKRepositoryMaven"
    url = sdk6Uri
    patternLayout {
       artifact("[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])")
       ivy("[organisation]/[module]/[revision]/ivy-[revision].xml")
       setM2compatible(true)
    }
  }
}
  • Add the previously created repository declaration inside the repositories block of both dependencyResolutionManagement and pluginManagement blocks:

dependencyResolutionManagement {
  repositories {
    ...
    offlineMicroEjSdk()
    ...
  }
}

pluginManagement {
  repositories {
    ...
    offlineMicroEjSdk()
    ...
  }
}

Offline Module Repository

There are 2 ways to create an Offline Module Repository containing the required modules:

  • download an existing online repository.

  • create an offline module repository project to create a custom repository.

Download an existing online repository

A quick way to get an Offline Module Repository for the modules is to download an existing online repository. MicroEJ provides several module repositories, the main one being the Central Repository.

If this online repository, or another one, contains all the module required for your project, download it. For example for the Central Repository, go to its location and click on the Download button.

Now go to this section to configure your project to use it.

Custom Offline Module Repository

If you need a custom Offline Module Repository (for example because the available online repositories does not contain all the modules required by your project, or you want to control exactly what contains the repository), you can create your own. Refer to this page.

Once done, go to this section to configure your project to use it.

Use an Offline Module Repository

When the Offline Module Repository of the modules has been retrieved or created, you can configure your projects to use it:

  • Unzip the Offline Module Repository archive at the location of your choice, for example in the C:\module-repository folder.

  • Depending on the SDK used to build the repository, add it to your project as follows:

Add the following line in the build.gradle.kts file of your project to declare the repository:

apply(file("C:\\module-repository\\module-repository.gradle.kts"))