Gradle and Maven
This page sets up a Gradle or Maven build to download packages from Telesphorepo. To publish a Gradle or Maven project, see Publish from a project, under Publish your packages.
For other formats, see npm, Python, Rust and Cargo, .NET and NuGet, Docker and Helm, and Debian, raw and curl.
In the blocks, put your server’s address in place of https://your-server, and your repository’s name in place of your-repo. The Use this repository tab of your repository shows the same blocks with your values filled in.
1Which build tool?
2Who can download from the repository?
Gradle (Kotlin), anyone can download
-
Paste this into
build.gradle.kts, with your package independencies.build.gradle.kts repositories {maven {name = "telesphorepo"url = uri("https://your-server/maven/your-repo")}mavenCentral()}dependencies {implementation("com.example:my-lib:1.0.0")} -
Run this.
Terminal window ./gradlew build
Done when Gradle prints BUILD SUCCESSFUL.
Gradle (Groovy), anyone can download
-
Paste this into
build.gradle, with your package independencies.build.gradle repositories {maven {name = 'telesphorepo'url = 'https://your-server/maven/your-repo'}mavenCentral()}dependencies {implementation 'com.example:my-lib:1.0.0'} -
Run this.
Terminal window ./gradlew build
Done when Gradle prints BUILD SUCCESSFUL.
Maven, anyone can download
-
Paste this into
pom.xml, inside<project>, with your package.pom.xml <repositories><repository><id>your-repo</id><url>https://your-server/maven/your-repo</url></repository></repositories><dependencies><dependency><groupId>com.example</groupId><artifactId>my-lib</artifactId><version>1.0.0</version></dependency></dependencies> -
Run this.
Terminal window mvn package
Done when Maven prints BUILD SUCCESS.
Gradle (Kotlin), only signed-in people can download
-
Make a read token.
Settings › Tokens › New read token. Type a name, then click Create token.
-
Paste your username and the token into
~/.gradle/gradle.properties.~/.gradle/gradle.properties telesphorepoUsername=YOUR_USERNAMEtelesphorepoPassword=YOUR_READ_TOKENThis file is in your home folder, not in the project. It holds your token, so do not commit it.
-
Paste this into
build.gradle.kts, with your package independencies.build.gradle.kts repositories {maven {name = "telesphorepo"url = uri("https://your-server/maven/your-repo")credentials(PasswordCredentials::class)}mavenCentral()}dependencies {implementation("com.example:my-lib:1.0.0")} -
Run this.
Terminal window ./gradlew build
Done when Gradle prints BUILD SUCCESSFUL.
Gradle (Groovy), only signed-in people can download
-
Make a read token.
Settings › Tokens › New read token. Type a name, then click Create token.
-
Paste your username and the token into
~/.gradle/gradle.properties.~/.gradle/gradle.properties telesphorepoUsername=YOUR_USERNAMEtelesphorepoPassword=YOUR_READ_TOKENThis file is in your home folder, not in the project. It holds your token, so do not commit it.
-
Paste this into
build.gradle, with your package independencies.build.gradle repositories {maven {name = 'telesphorepo'url = 'https://your-server/maven/your-repo'credentials(PasswordCredentials)}mavenCentral()}dependencies {implementation 'com.example:my-lib:1.0.0'} -
Run this.
Terminal window ./gradlew build
Done when Gradle prints BUILD SUCCESSFUL.
Maven, only signed-in people can download
-
Make a read token.
Settings › Tokens › New read token. Type a name, then click Create token.
-
Paste your username and the token into
~/.m2/settings.xml.~/.m2/settings.xml <settings><servers><server><id>your-repo</id><username>YOUR_USERNAME</username><password>YOUR_READ_TOKEN</password></server></servers></settings>This file is in your home folder, not in the project. It holds your token, so do not commit it.
-
Paste this into
pom.xml, inside<project>, with your package.pom.xml <repositories><repository><id>your-repo</id><url>https://your-server/maven/your-repo</url></repository></repositories><dependencies><dependency><groupId>com.example</groupId><artifactId>my-lib</artifactId><version>1.0.0</version></dependency></dependencies> -
Run this.
Terminal window mvn package
Done when Maven prints BUILD SUCCESS.
If something goes wrong
Section titled “If something goes wrong”Gradle or Maven cannot find the package
Use the group, the name and the version of a package in the repository. Open the package in the web UI to see its line.
Gradle or Maven cannot find a public package, such as one of Maven Central
The repository is hosted, and holds your own packages only. Keep mavenCentral() in the build, or ask your server admin for a group with a proxy of Maven Central. A Maven group merges the versions of all its members.
401 when you download
The repository is for signed-in people only. Choose Only signed-in people above. Check the username and the read token.
There is no New read token button
Read tokens are for accounts with a password. A single sign-on account cannot make one.
Maven refuses an http:// address
Maven allows http:// only for localhost. Serve the server over HTTPS. See Serve over HTTPS.
~/.m2/settings.xml already has <servers>
Add only the <server> part to it.
pom.xml already has <repositories> or <dependencies>
Add only the inner part to it.
A CI job must download from a private repository
Keep the read token in a CI secret. For Gradle, set ORG_GRADLE_PROJECT_telesphorepoUsername and ORG_GRADLE_PROJECT_telesphorepoPassword. For Maven, write ${env.REPO_USERNAME} and ${env.REPO_TOKEN} in the <server> part, and set those variables.
The repository holds a Gradle plugin
Put the repository in pluginManagement, at the top of the settings file:
pluginManagement { repositories { maven { name = "telesphorepo" url = uri("https://your-server/maven/your-repo") } gradlePluginPortal() }}You need a Debian package or a plain file
See Debian, raw and curl.