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.
In Packages, find the desired Maven package.
Open the package properties page.
In the snippets field, select your build tool (Gradle, Maven, or SBT) and copy the snippet code.
Paste the code to the corresponding configuration file:
build.gradle
,pom.xml
, and so on.Specify the repository in the configuration file:
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" } } }Specify values for the
usr
andpwd
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
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
andsnapshots
tags allow downloading both RELEASE and SNAPSHOT artifact versions from the repository.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 theservers
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>