Skip to content

Deploy artifacts

Deploying uploads your build's files to a repository with the Maven repository protocol. Artifex accepts what mvn deploy and Gradle's maven-publish plugin send.

To deploy, you need write permission in the repository. A build tool authenticates with a personal access token that has been granted access to that repository.

Configure Maven

Put the credentials in ~/.m2/settings.xml. The password is the token; the user name can be anything, so use your handle.

xml
<settings>
  <servers>
    <server>
      <id>codesoh</id>
      <username>YOUR_HANDLE</username>
      <password>cs_pat_YOUR_TOKEN</password>
    </server>
  </servers>
</settings>

Name the repository in pom.xml, using the same id so that Maven finds the credentials:

xml
<distributionManagement>
  <repository>
    <id>codesoh</id>
    <url>https://artifex.soh.gg/maven/OWNER/SLUG/</url>
  </repository>
  <snapshotRepository>
    <id>codesoh</id>
    <url>https://artifex.soh.gg/maven/OWNER/SLUG/</url>
  </snapshotRepository>
</distributionManagement>

Then deploy:

shell
mvn deploy

Configure Gradle

Put the credentials in ~/.gradle/gradle.properties. Gradle reads the two properties whose names start with the repository's name:

properties
codesohUsername=YOUR_HANDLE
codesohPassword=cs_pat_YOUR_TOKEN

In the Kotlin DSL:

kotlin
plugins {
    `maven-publish`
}

publishing {
    publications {
        create<MavenPublication>("maven") {
            from(components["java"])
        }
    }
    repositories {
        maven {
            name = "codesoh"
            url = uri("https://artifex.soh.gg/maven/OWNER/SLUG/")
            credentials(PasswordCredentials::class)
        }
    }
}

In the Groovy DSL:

groovy
plugins {
    id 'maven-publish'
}

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            name = 'codesoh'
            url = 'https://artifex.soh.gg/maven/OWNER/SLUG/'
            credentials(PasswordCredentials)
        }
    }
}

Then publish:

shell
./gradlew publishAllPublicationsToCodesohRepository

What happens during a deploy

A deploy is a series of PUT requests. For each one, Artifex does the following:

  1. Checks that the path follows the Maven repository layout, and that the version in the file name matches the directory it's in.
  2. Checks the repository's settings: whether the file may replace an existing one, and whether snapshots are accepted.
  3. Reads the bytes and computes the MD5, SHA-1, SHA-256, and SHA-512 digests.
  4. Records the file and reads what it can from it: the coordinates and dependencies of a POM, the variants of a Gradle module file, and the entries, plugin descriptor, and OSGi headers of a jar.
  5. Answers 201 Created, or 200 OK when the file replaced one that existed.

Checksum files that the client uploads, such as hello-1.0.0.jar.sha1, are checked against the file that they belong to. A checksum that doesn't match is refused with 400 Bad Request and names the value that Artifex computed, so a corrupted upload can't be recorded. Upload the file before its checksum; a checksum for a file that isn't there is refused with 404 Not Found.

Artifex stores the file, not the uploaded checksum. It serves every algorithm for every file. For more information, see Checksums and signatures.

Metadata is generated, not stored

Maven uploads a maven-metadata.xml at the end of a deploy. Artifex accepts the upload and then generates the repository's metadata from what it actually holds, so the version list can never drift from the files.

For a snapshot version, Artifex compares the uploaded document with what was deployed. If it names a build other than the newest one, the upload is refused with 400 Bad Request and the message names both builds. For more information, see Snapshots.

Deploying over an existing file

By default, a release file that exists can't be deployed again, and the second deploy is refused with 409 Conflict. For how to allow it, see Immutability.

Limits

A single file can be at most 4 GiB. A larger upload is refused with 413 Payload Too Large. For every limit, see Limits.