JetBrains Space Help

Get Maven Artifacts

The typical way of getting a Maven package is referencing it from your project. To help you create a dependency, Packages generate code snippets for popular build tools.

  1. In Packages, find the desired Maven package.

  2. Open the package properties page.

  3. In the snippets field, select your build tool (Gradle, Maven, or SBT) and copy the snippet code.

    Maven snippets
  4. Paste the code to the corresponding configuration file: build.gradle, pom.xml, and so on.

  5. Specify the repository in the configuration file:

    1. In build.gradle, add the repository URL:

      repositories { maven { url "https://maven.pkg.jetbrains.space/mycompany/p/projectkey/my-maven-repo" credentials { username = "$usr" password = "$pwd" } } }
    2. Specify values for the usr and pwd variables.

      You can set variable values in the gradle.properties file, which is stored locally on your machine. The default location of this file is:

      • on Windows: %HOMEPATH%\.gradle\gradle.properties

      • on Linux / macOS: ~/.gradle/gradle.properties

      Open gradle.properties and specify variable values. Here you must use the credentials of either your own Space account (using a permanent token instead of a password is strongly recommended) or a separate service account:

      usr = admin pwd = 1234

    1. In the distributionManagement section, specify repository ID (it must be a unique repository identifier) and URL:

      <repositories> <repository> <id>my-repo</id> <url>https://maven.pkg.jetbrains.space/mycompany/p/projectkey/my-maven-repo</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>

      In this example, releases and snapshots tags allow downloading both RELEASE and SNAPSHOT artifact versions from the repository.

    2. Specify repository credentials.

      As it's not secure to store credentials in the VCS, we must use the local user-specific Maven settings:

      • on Windows: %HOMEPATH%/.m2/settings.xml

      • on Linux / macOS: ~/.m2/settings.xml

      Open settings.xml and place the server id (the one from Step 1) and the credentials into the servers section. Here you must use the credentials of either your own Space account (using a permanent token instead of a password is strongly recommended) or a separate service account:

      <servers> <server> <id>my-repo</id> <username>admin</username> <password>1234</password> </server> </servers>

Last modified: 09 December 2021