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 Repositories.

This tutorial explains how to create and use Offline 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 MicroEJ SDK 6 repository for Maven/Gradle modules */
  maven {
    name = "offlineSDKRepositoryMaven"
    url = sdk6Uri
  }

  /* Offline MicroEJ 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 allprojects and pluginManagement blocks:

allprojects {
  repositories {
    ...
    offlineMicroEjSdk()
    ...
  }
}

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

Offline Repository for the Modules

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

  • download an existing online repository.

  • create a SDK 5 offline repository project to create a custom repository.

Download an existing online repository

A quick way to get an Offline 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 Repository

If you need a custom Offline 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. This can be done only with SDK 5 for the moment, so refer to this page.

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

Use an Offline Modules Repository

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

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

  • Add the following repositories declaration in your repositories configuration script, inside the repositories block:

repositories {

  ...

  maven {
      name = "offlineModulesRepositoryMaven"
      url = uri("C:\\modules-repository")
  }
  ivy {
      name = "offlineModulesRepositoryIvy"
      url = uri("C:\\modules-repository")
      patternLayout {
          artifact("[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])")
          ivy("[organisation]/[module]/[revision]/ivy-[revision].xml")
          setM2compatible(true)
      }
  }

  ...

}