Maven & Gradle Packages
Artifacts speaks the native Maven repository protocol. Standard Maven CLI (mvn) and Gradle build tools work directly against your Artifacts repository with no plugins required -- just point them at the registry URL and authenticate with an API token.
Replace ORGSLUG and REPOSLUG with your actual organization and repository slugs in every example below.
Maven (pom.xml)
Repository configuration
Add your Artifacts repository to pom.xml so Maven can resolve dependencies from it:
<repositories>
<repository>
<id>artifacts</id>
<url>https://artifacts.premex.se/api/maven/ORGSLUG/REPOSLUG/</url>
</repository>
</repositories>
Publishing with distributionManagement
To publish artifacts via mvn deploy, add a <distributionManagement> block:
<distributionManagement>
<repository>
<id>artifacts</id>
<url>https://artifacts.premex.se/api/maven/ORGSLUG/REPOSLUG/</url>
</repository>
</distributionManagement>
Authentication via settings.xml
Maven uses Basic auth for repository authentication. Configure your ~/.m2/settings.xml with the server ID matching the <id> in your pom.xml:
<settings>
<servers>
<server>
<id>artifacts</id>
<username>token</username>
<password>art_your_token_here</password>
</server>
</servers>
</settings>
The username can be any string (conventionally token). The password is your Artifacts API token.
Tip: Never commit
settings.xmlwith real tokens. On CI, write the file dynamically from a secret (see the CI/CD section below).
Deploy
mvn deploy
Maven will upload your JAR, POM, and any other configured artifacts to the Artifacts registry.
Gradle / Kotlin DSL
Publishing
Add a publishing block to your build.gradle.kts:
publishing {
repositories {
maven {
name = "Artifacts"
url = uri("https://artifacts.premex.se/api/maven/ORGSLUG/REPOSLUG/")
credentials {
username = "token"
password = findProperty("artifacts.token") as String?
?: System.getenv("ARTIFACTS_TOKEN")
?: ""
}
}
}
}
Then publish:
./gradlew publish
Gradle will upload all configured publications to your Artifacts repository.
Consuming dependencies
Add the Artifacts repository to your build.gradle.kts (or settings.gradle.kts for centralized repository declarations):
repositories {
maven {
url = uri("https://artifacts.premex.se/api/maven/ORGSLUG/REPOSLUG/")
credentials {
username = "token"
password = providers.gradleProperty("artifacts.token").getOrElse("")
}
}
}
Then add dependencies as usual:
dependencies {
implementation("com.example:my-library:1.0.0")
}
Token setup via gradle.properties
For local development, add your token to ~/.gradle/gradle.properties (user-level, not committed to git):
artifacts.token=art_your_token_here
For CI/CD, use an environment variable instead (see the System.getenv("ARTIFACTS_TOKEN") fallback in the publishing block above).
CI/CD Example
A GitHub Actions workflow that publishes Maven packages on tag push:
name: Publish to Artifacts
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Publish
run: ./gradlew publish
env:
ARTIFACTS_TOKEN: ${{ secrets.ARTIFACTS_TOKEN }}
Add your API token as a repository secret named ARTIFACTS_TOKEN in your GitHub repo settings.
Maven CLI on CI
If you use Maven CLI instead of Gradle, write settings.xml dynamically:
- name: Configure Maven settings
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << 'XML'
<settings>
<servers>
<server>
<id>artifacts</id>
<username>token</username>
<password>${env.ARTIFACTS_TOKEN}</password>
</server>
</servers>
</settings>
XML
- name: Deploy
run: mvn deploy
env:
ARTIFACTS_TOKEN: ${{ secrets.ARTIFACTS_TOKEN }}
Versions API
Query published versions for any package via a simple HTTP endpoint -- useful for CI/CD scripts, update checkers, or install scripts.
# JSON — all versions with metadata
curl -s https://artifacts.premex.se/api/v/ORGSLUG/REPOSLUG/PACKAGE/versions
# Plain text — latest version only
curl -s https://artifacts.premex.se/api/v/ORGSLUG/REPOSLUG/PACKAGE/versions?format=txt\&limit=1
# Latest 5 versions
curl -s https://artifacts.premex.se/api/v/ORGSLUG/REPOSLUG/PACKAGE/versions?limit=5
This endpoint works for all package types. Public repos require no authentication.
Troubleshooting
401 Unauthorized
- Verify your token is valid and has not expired. Check Settings > API Tokens in the web UI.
- For Maven CLI: ensure the
<server><id>insettings.xmlmatches the<repository><id>inpom.xml. A mismatch means Maven sends no credentials. - For Gradle: confirm the token is available via
gradle.propertiesor theARTIFACTS_TOKENenvironment variable.
403 Forbidden
- Your token may lack the required scope. Publishing requires
write; managing members requiresadmin. - If the token is restricted to specific repositories, verify it includes the target repo.
Wrong groupId or artifactId
Maven maps group IDs to directory paths (com.example becomes com/example/). If downloads fail with 404, check that the group ID and artifact ID in your dependency declaration match exactly what was published. You can browse the package list in the web UI to verify.
Missing settings.xml
If mvn deploy returns a 401 even though your token is correct, Maven may not be finding settings.xml. Verify:
mvn help:effective-settings
This prints the merged settings Maven is using. Look for your <server> entry under <servers>.
Gradle dependency resolution fails
Make sure the repository block appears before mavenCentral() if your artifact is only in Artifacts, or after it if you want Gradle to check Maven Central first. Gradle resolves repositories in declaration order.