

Amazon CodeCatalyst is no longer open to new customers. Existing customers can continue to use the service as normal. For more information, see [How to migrate from CodeCatalyst](migration.md).

# Using Maven
<a name="packages-maven"></a>

The Maven repository format is used by many different languages, including Java, Kotlin, Scala, and Clojure. It's supported by many different build tools, including Maven, Gradle, Scala SBT, Apache Ivy, and Leiningen. 

We have tested and confirmed compatibility with CodeCatalyst for the following versions:
+ Latest **Maven** version: 3.6.3.
+ Latest **Gradle** version: 6.4.1. Version 5.5.1 has also been tested.

**Topics**
+ [Configuring and using Gradle Groovy](packages-maven-gradle.md)
+ [Configuring and using mvn](packages-maven-mvn.md)
+ [Publishing packages with curl](packages-maven-curl.md)
+ [Using Maven checksums and snapshots](packages-maven-checksums-snapshots.md)

# Configuring and using Gradle Groovy
<a name="packages-maven-gradle"></a>

To use Gradle Groovy with CodeCatalyst, you must connect Gradle Groovy to your package repository and provide a personal access token (PAT) for authentication. You can view instructions for connecting Gradle Groovy to your package repository in the CodeCatalyst console.

**Contents**
+ [Fetching dependencies from CodeCatalyst](#gradle-fetch-dependencies)
+ [Fetching plugins from CodeCatalyst](#gradle-fetch-plugins)
+ [Fetching packages from external package repositories through CodeCatalyst](#gradle-install-public)
+ [Publishing packages to CodeCatalyst](#gradle-publish-packages)
+ [Running a Gradle build in IntelliJ IDEA](#gradle-intellij)
  + [Method 1: Put the PAT in `gradle.properties`](#gradle-intellij-gradle-properties)
  + [Method 2: Put the PAT in a separate file](#gradle-intellij-file)

## Fetching dependencies from CodeCatalyst
<a name="gradle-fetch-dependencies"></a>

The following instructions explain how to configure Gradle Groovy to fetch dependencies your CodeCatalyst package repository.

**To use Gradle Groovy to fetch dependencies from your CodeCatalyst package repository**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. Navigate to your project.

1. In the navigation pane, choose **Packages**.

1. Choose your package repository from the list of package repositories.

1. Choose **Connect to repository**.

1. In the **Connect to repository** dialog box, choose **Gradle Groovy** from the list of package manager clients.

1. You will need a personal access token (PAT) to authenticate Gradle Groovy with CodeCatalyst. If you already have one, you can use that. If not, you can create one here.

   1. Choose **Create token**.

   1. Choose **Copy** to copy your PAT.
**Warning**  
You will not be able to see or copy your PAT again after you close the dialog box.

1. Update your gradle properties file with your access credentials. Replace *username* with your CodeCatalyst username and replace *PAT* with your CodeCatalyst personal access token. You can use any value for *spaceUsername* and *spacePassword* as long as you use the same values in the following steps.

   ```
   spaceUsername=username
   spacePassword=PAT
   ```

1. To fetch dependencies from CodeCatalyst in a Gradle build, copy the `maven` code snippet and add it to the `repositories` section in your project's `build.gradle` file. Replace the following values. You can use any value for *spaceName* as long as you use the same values in the following steps.
**Note**  
If copying from the console instructions, the following values should be updated for you and should not be changed.
   + Replace *space\$1name* with your CodeCatalyst space name.
   + Replace *proj\$1name* with your CodeCatalyst project name.
   + Replace *repo\$1name* with your CodeCatalyst package repository name.

   ```
   maven {
     name = 'spaceName'
     url = uri('https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/')
     credentials(PasswordCredentials)
   }
   ```

1. (Optional) To use the CodeCatalyst package repository as the only source for your project dependencies, remove any other sections in repositories from the `build.gradle` file. If you have more than one repository, Gradle searches each repository for dependencies in the order they are listed.

## Fetching plugins from CodeCatalyst
<a name="gradle-fetch-plugins"></a>

By default Gradle will resolve plugins from the public [Gradle Plugin Portal](https://plugins.gradle.org/). The following steps configure your Gradle project to resolve plugins from your CodeCatalyst package repository.

**To use Gradle to fetch plugins from your CodeCatalyst package repository**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. Navigate to your project.

1. In the navigation pane, choose **Packages**.

1. Choose your package repository from the list of package repositories.

1. Choose **Connect to repository**.

1. In the **Connect to repository** dialog box, choose **Gradle** from the list of package manager clients.

1. You will need a personal access token (PAT) to authenticate Gradle with CodeCatalyst. If you already have one, you can use that. If not, you can create one here.

   1. Choose **Create token**.

   1. Choose **Copy** to copy your PAT.
**Warning**  
You will not be able to see or copy your PAT again after you close the dialog box.

1. Update your gradle properties file with your access credentials. Replace *username* with your CodeCatalyst username and replace *PAT* with your CodeCatalyst personal access token. You can use any value for *spaceUsername* and *spacePassword* as long as you use the same values in the following steps.

   ```
   spaceUsername=username
   spacePassword=PAT
   ```

1. Add a `pluginManagement` block to your `settings.gradle` file. The `pluginManagement` block must appear before any other statements in `settings.gradle`. Replace the following values.
**Note**  
If copying from the console instructions, the following values should be updated for you and should not be changed.
   + Replace *spaceName* with the name value used in the previous step.
   + Replace *space\$1name* with your CodeCatalyst space name.
   + Replace *proj\$1name* with your CodeCatalyst project name.
   + Replace *repo\$1name* with your CodeCatalyst package repository name.

   ```
   pluginManagement {
       repositories {
           maven {
               name = 'spaceName'
               url = uri('https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/')
               credentials(PasswordCredentials)
           }
       }
   }
   ```

   This will ensure that Gradle resolves plugins from the specified repository. The repository must have an upstream connection configured to the Gradle Plugin Portal (`gradle-plugins-store`) so that commonly required Gradle plugins are available to the build. For more information, see the [Gradle documentation](https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories).

## Fetching packages from external package repositories through CodeCatalyst
<a name="gradle-install-public"></a>

You can install Maven packages from public repositories through a CodeCatalyst repository by configuring it with an upstream connection to the gateway that represents the gateway repository. Packages installed from the gateway repository are ingested and stored in your CodeCatalyst repository.

CodeCatalyst supports the following public Maven package repositories.
+ maven-central-gateway
+ google-android-gateway
+ gradle-plugins-gateway
+ commonsware-gateway

**To install packages from public Maven package repositories**

1. If you haven't already, configure Gradle with your CodeCatalyst package repository by following the steps in [Fetching dependencies from CodeCatalyst](#gradle-fetch-dependencies) or [Fetching plugins from CodeCatalyst](#gradle-fetch-plugins). 

1. Ensure that your repository has added the gateway repository you want to install from as an upstream connection. You can do this by following the instructions in [Adding an upstream repository](packages-upstream-repositories-add.md) and choosing the public package repository you want to add as an upstream.

For more information about requesting packages from upstream repositories, see [Requesting a package version with upstream repositories](packages-upstream-repositories-request.md).

## Publishing packages to CodeCatalyst
<a name="gradle-publish-packages"></a>

This section describes how to publish a Java library built with Gradle Groovy to a CodeCatalyst repository.

**To use Gradle Groovy to publish packages to a CodeCatalyst package repository**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. On the overview page for your project, choose **Packages**.

1. Choose your package repository from the list of package repositories.

1. Choose **Connect to repository**.

1. In the **Connect to repository** dialog box, choose **Gradle Groovy** from the list of package manager clients.

1. You will need a personal access token (PAT) to authenticate Gradle with CodeCatalyst. If you already have one, you can use that. If not, you can create one here.

   1. Choose **Create token**.

   1. Choose **Copy** to copy your PAT.
**Warning**  
You will not be able to see or copy your PAT again after you close the dialog box.

1. Update your gradle properties file with your access credentials. Replace *username* with your CodeCatalyst username and replace *PAT* with your CodeCatalyst personal access token. You can use any value for *spaceUsername* and *spacePassword* as long as you use the same values in the following steps.

   ```
   spaceUsername=username
   spacePassword=PAT
   ```

1. Add the `maven-publish` plugin to the `plugins` section of the project's `build.gradle` file.

   ```
   plugins {
       id 'java-library'
       id 'maven-publish'
   }
   ```

1. Next, add a `publishing` section to the project `build.gradle` file. Replace the following values.
**Note**  
If copying from the console instructions, the following values should be updated for you and should not be changed.
   + Replace *space\$1name* with your CodeCatalyst space name.
   + Replace *proj\$1name* with your CodeCatalyst project name.
   + Replace *repo\$1name* with your CodeCatalyst package repository name.

   ```
   publishing {
       publications {
           mavenJava(MavenPublication) {
               groupId = 'group-id'
               artifactId = 'artifact-id'
               version = 'version'
               from components.java
           }
       }
       repositories {
           maven {
               name = 'spaceName'
               url = uri('https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/')
               credentials(PasswordCredentials)
           }
       }
   }
   ```

   The `maven-publish` plugin generates a POM file based on the `groupId`, `artifactId`, and `version` specified in the `publishing` section.

1. After these changes to `build.gradle` are complete, run the following command to build the project and upload it to the repository.

   ```
   ./gradlew publish
   ```

1. Navigate to your package repository in the CodeCatalyst console to check that the package was successfully published. You should see the package in the **Packages** list of your package repository.

For more information, see these topics on the Gradle website:
+  [Building Java Libraries](https://guides.gradle.org/building-java-libraries/) 
+  [Publishing a project as a module](https://docs.gradle.org/current/userguide/publishing_setup.html) 

## Running a Gradle build in IntelliJ IDEA
<a name="gradle-intellij"></a>

You can run a Gradle build in IntelliJ IDEA that pulls dependencies from CodeCatalyst. To authenticate Gradle with CodeCatalyst, you must use a personal access token (PAT). You can store your CodeCatalyst PAT in `gradle.properties` or a separate file of your choice.

### Method 1: Put the PAT in `gradle.properties`
<a name="gradle-intellij-gradle-properties"></a>

Use this method if you are not using the `gradle.properties` file and can overwrite its contents with your PAT. If you are using `gradle.properties`, you can modify this method to add the PAT instead of overwriting the file's contents.

**Note**  
The example shows the `gradle.properties` file located in `GRADLE_USER_HOME`.

First, create a PAT if you do not have one.

**To create a personal access token (PAT)**

1. In the top menu bar, choose your profile badge, and then choose **My settings**. 
**Tip**  
You can also find your user profile by going to the members page for a project or space and choosing your name from the members list.

1. In **PAT name**, enter a descriptive name for your PAT.

1. In **Expiration date**, leave the default date or choose the calendar icon to select a custom date. The expiration date defaults to one year from the current date.

1. Choose **Create**.

   You can also create this token when you choose **Clone repository** for a source repository.

1. Save the PAT secret in a secure location. 
**Important**  
The PAT secret only displays once. You cannot retrieve it after you close the window. 

Next, update your `build.gradle` file with the following snippet:

```
repositories {
    maven {
        name = 'spaceName'
        url = uri('https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/')
        credentials(PasswordCredentials)
    }
}
```

### Method 2: Put the PAT in a separate file
<a name="gradle-intellij-file"></a>

Use this method if you do not want to modify your `gradle.properties` file.

First, create a PAT if you do not have one.

**To create a personal access token (PAT)**

1. In the top menu bar, choose your profile badge, and then choose **My settings**. 
**Tip**  
You can also find your user profile by going to the members page for a project or space and choosing your name from the members list.

1. In **PAT name**, enter a descriptive name for your PAT.

1. In **Expiration date**, leave the default date or choose the calendar icon to select a custom date. The expiration date defaults to one year from the current date.

1. Choose **Create**.

   You can also create this token when you choose **Clone repository** for a source repository.

1. Save the PAT secret in a secure location. 
**Important**  
The PAT secret only displays once. You cannot retrieve it after you close the window. 

**To put your PAT in a separate file**

1. Update your `build.gradle` file with the following snippet. Replace *space\$1name*, *proj\$1name*, and *repo\$1name* with your CodeCatalyst user name, space name, project name, and package repository name.

   ```
   def props = new Properties()
   file("fileName").withInputStream { props.load(it) }
                     
   repositories {
           maven {
               name = 'spaceName'
               url = uri('https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/')
               credentials(PasswordCredentials)
           }
       }
   }
   ```

1. Write your PAT into the file that was specified in your `build.gradle` file:

   ```
   echo "codecatalystArtifactsToken=PAT" > fileName
   ```

# Configuring and using mvn
<a name="packages-maven-mvn"></a>

You use the `mvn` command to run Maven builds. You must configure `mvn` to use your package repository and provide a personal access token (PAT) for authentication.

**Contents**
+ [Fetching dependencies from CodeCatalyst](#mvn-fetch-dependencies)
+ [Fetching packages from external package repositories through CodeCatalyst](#mvn-install-public)
+ [Publishing packages to CodeCatalyst](#mvn-publish-packages)
+ [Publishing third-party packages](#publishing-third-party-packages)

## Fetching dependencies from CodeCatalyst
<a name="mvn-fetch-dependencies"></a>

To configure `mvn` to fetch dependencies from a CodeCatalyst repository, you must edit the Maven configuration file, `settings.xml` and optionally, your project's Project Model Object (POM) file. The POM file contains information about the project and configuration information for Maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, and goals.

**To use `mvn` to fetch dependencies from your CodeCatalyst package repository**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. On the overview page for your project, choose **Packages**.

1. Choose your package repository from the list of package repositories.

1. Choose **Connect to repository**.

1. In the **Connect to repository** dialog box, choose **mvn** from the list of package manager clients.

1. You will need a personal access token (PAT) to authenticate `mvn` with CodeCatalyst. If you already have one, you can use that. If not, you can create one here.

   1. Choose **Create token**.

   1. Choose **Copy** to copy your PAT.
**Warning**  
You will not be able to see or copy your PAT again after you close the dialog box.

1. Add a profile containing your repository to your `settings.xml` file. Replace the following values.
**Note**  
If copying from the console instructions, the following values should be updated for you and should not be changed.
   + Replace *space\$1name* with your CodeCatalyst space name.
   + Replace *proj\$1name* with your CodeCatalyst project name.
   + Replace *repo\$1name* with your CodeCatalyst package repository name.

   ```
   <profiles>
     <profile>
       <id>repo_name</id>
       <activation>
           <activeByDefault>true</activeByDefault>
       </activation>
       <repositories>
           <repository>
             <id>repo_name</id>
             <url>https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/</url>
           </repository>
       </repositories>
     </profile>
   </profiles>
   ```

1. Add your server to the list of servers in your `settings.xml` file. Replace the following values.
**Note**  
If copying from the console instructions, the following values should be updated for you and should not be changed.
   + Replace *repo\$1name* with your CodeCatalyst package repository name.
   + Replace *username* with your CodeCatalyst user name.
   + Replace *PAT* with your CodeCatalyst PAT.

   ```
   <servers>
     <server>
       <id>repo_name</id>
       <username>username</username>
       <password>PAT</password>
     </server>
   </servers>
   ```

1. (Optional) Set a mirror in your `settings.xml` file that captures all connections and routes them to your repository instead of a gateway repository.
**Note**  
If copying from the console instructions, the following values should be updated for you and should not be changed.
   + Replace *space\$1name* with your CodeCatalyst space name.
   + Replace *proj\$1name* with your CodeCatalyst project name.
   + Replace *repo\$1name* with your CodeCatalyst package repository name.

   ```
   <mirrors>
     <mirror>
       <id>repo_name</id>
       <name>repo_name</name>
       <url>https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/</url>
       <mirrorOf>*</mirrorOf>
     </mirror>
   </mirrors>
   ```

**Important**  
You can use any value in the `<id>` element, but it must be the same in both the `<server>` and `<repository>` elements. This enables the specified credentials to be included in requests to CodeCatalyst.

After you make these configuration changes, you can build the project.

```
mvn compile
```

## Fetching packages from external package repositories through CodeCatalyst
<a name="mvn-install-public"></a>

You can install Maven packages from public repositories through a CodeCatalyst repository by configuring it with an upstream connection to the gateway that represents the gateway repository. Packages installed from the gateway repository are ingested and stored in your CodeCatalyst repository.

Currently, CodeCatalyst supports the following public Maven package repositories.
+ maven-central-gateway
+ google-android-gateway
+ gradle-plugins-gateway
+ commonsware-gateway

**To install packages from public Maven package repositories**

1. If you haven't already, configure `mvn` with your CodeCatalyst package repository by following the steps in [Fetching dependencies from CodeCatalyst](#mvn-fetch-dependencies).

1. Ensure your repository has added the gateway repository you want to install from as an upstream connection. To check which upstream sources are added or to add a gateway repository as an upstream source, followthe instructions in [Adding an upstream repository](packages-upstream-repositories-add.md).

For more information about requesting packages from upstream repositories, see [Requesting a package version with upstream repositories](packages-upstream-repositories-request.md).

## Publishing packages to CodeCatalyst
<a name="mvn-publish-packages"></a>

To publish a Maven package with `mvn` to a CodeCatalyst repository, you must also edit `~/.m2/settings.xml` and the project POM.

**To use `mvn` to publish packages to your CodeCatalyst package repository**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. On the overview page for your project, choose **Packages**.

1. Choose your package repository from the list of package repositories.

1. Choose **Connect to repository**.

1. In the **Connect to repository** dialog box, choose **mvn** from the list of package manager clients.

1. You will need a personal access token (PAT) to authenticate `mvn` with CodeCatalyst. If you already have one, you can use that. If not, you can create one here.

   1. Choose **Create token**.

   1. Choose **Copy** to copy your PAT.
**Warning**  
You will not be able to see or copy your PAT again after you close the dialog box.

1. Configure an environment variable on your local machine with your PAT. You will use this environment variable in your `setting.xml` file.

   ```
   export CODECATALYST_ARTIFACTS_TOKEN=your_PAT
   ```

1. Add a `<servers>` section to `settings.xml` with a reference to the `CodeCatalyst_ARTIFACTS_TOKEN` environment variable so that Maven passes the token in HTTP requests.

   ```
   <settings>
   ...
       <servers>
           <server>
               <id>repo-name</id>
               <username>username</username>
               <password>${env.CodeCatalyst_ARTIFACTS_TOKEN}</password>
           </server>
       </servers>
   ...
   </settings>
   ```

1. Add a `<distributionManagement>` section to your project's `pom.xml`.

   ```
   <project>
   ...
        <distributionManagement>
            <repository>
                <id>repo_name</id>
                <name>repo_name</name>
                <url>https://packages.region.codecatalyst.aws/maven/space_name/proj_name/repo_name/</url>
            </repository>
        </distributionManagement>
   ...
   </project>
   ```

After you make these configuration changes, you can build the project and publish it to the specified repository.

```
mvn deploy
```

You can navigate to your package repository in the CodeCatalyst console to check that the package was successfully published.

## Publishing third-party packages
<a name="publishing-third-party-packages"></a>

You can publish third-party Maven packages to a CodeCatalyst repository with `mvn deploy:deploy-file`. This can be helpful to users that want to publish packages and only have JAR files and don't have access to package source code or POM files.

The `mvn deploy:deploy-file` command will generate a POM file based on the information passed in the command line.

First, create a PAT if you do not have one.

**To create a personal access token (PAT)**

1. In the top menu bar, choose your profile badge, and then choose **My settings**. 
**Tip**  
You can also find your user profile by going to the members page for a project or space and choosing your name from the members list.

1. In **PAT name**, enter a descriptive name for your PAT.

1. In **Expiration date**, leave the default date or choose the calendar icon to select a custom date. The expiration date defaults to one year from the current date.

1. Choose **Create**.

   You can also create this token when you choose **Clone repository** for a source repository.

1. Save the PAT secret in a secure location. 
**Important**  
The PAT secret only displays once. You cannot retrieve it after you close the window. 

**To publish third-party Maven packages**

1. Create a `~/.m2/settings.xml` file with the following contents:

   ```
   <settings>
       <servers>
           <server>
               <id>repo_name</id>
               <username>username</username>
               <password>PAT}</password>
           </server>
       </servers>
   </settings>
   ```

1. Run the `mvn deploy:deploy-file` command:

   ```
   mvn deploy:deploy-file -DgroupId=commons-cli          \
   -DartifactId=commons-cli       \
   -Dversion=1.4                  \
   -Dfile=./commons-cli-1.4.jar   \
   -Dpackaging=jar                \
   -DrepositoryId=repo-name      \
   -Durl=https://packages.region.codecatalyst.aws/maven/space-name/proj-name/repo-name/
   ```
**Note**  
The preceding example publishes `commons-cli 1.4`. Modify the groupId, artifactID, version, and file arguments to publish a different JAR.

These instructions are based on examples in the [Guide to deploying 3rd party JARs to remote repository](https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html) from the *Apache Maven documentation*. 

 For more information, see these topics on the Apache Maven Project website:
+  [Setting up Multiple Repositories](https://maven.apache.org/guides/mini/guide-multiple-repositories.html) 
+  [Settings Reference](https://maven.apache.org/settings.html) 
+  [Distribution Management](https://maven.apache.org/pom.html#Distribution_Management) 
+  [Profiles](https://maven.apache.org/pom.html#Profiles) 

# Publishing packages with curl
<a name="packages-maven-curl"></a>

This section shows how to use the HTTP client `curl` to publish Maven packages to a CodeCatalyst package repository. Publishing packages with `curl` can be useful if you do not have or want to install the Maven client in your environments.

**To publish a Maven package with `curl`**

1. You must store a personal access token (PAT) into an environment variable to authenticate `curl` with CodeCatalyst. If you already have one, you can use that. If not, you can create one and configure the environment variable.

   1. Create a PAT by following the steps in [Grant users repository access with personal access tokens](ipa-tokens-keys.md). Copy the PAT to store it in an environment variable.

   1. On your local machine's command line, configure an environment variable with your PAT.

      ```
      export CodeCatalyst_ARTIFACTS_TOKEN=your_PAT
      ```

1. Use the following `curl` command to publish the JAR to a CodeCatalyst repository. Replace *username*, *space\$1name*, *proj\$1name*, and *repo\$1name* with your CodeCatalyst user name, space name, project name, and package repository name.

   ```
   curl --request PUT https://packages.region.codecatalyst.aws/maven/space-name/proj-name/repo-name/com/mycompany/app/my-app/1.0/my-app-1.0.jar \
        --user "username:CodeCatalyst_ARTIFACTS_TOKEN" --header "Content-Type: application/octet-stream" \
        --data-binary @target/path/to/my-app-1.0.jar
   ```

1. Use the following `curl` command to publish the POM to a CodeCatalyst repository. Replace *username*, *space\$1name*, *proj\$1name*, and *repo\$1name* with your CodeCatalyst user name, space name, project name, and package repository name.

   ```
   curl --request PUT https://packages.region.codecatalyst.aws/maven/space-name/proj-name/repo-name/com/mycompany/app/my-app/1.0/my-app-1.0.pom \
        --user "username:CodeCatalyst_ARTIFACTS_TOKEN" --header "Content-Type: application/octet-stream" \
        --data-binary @target/my-app-1.0.pom
   ```

1. At this point, the Maven package will be in your CodeCatalyst repository with a status of `Unfinished`. To be able to consume the package, it must be in the `Published` state. You can move the package from `Unfinished` to `Published` by either uploading a `maven-metadata.xml` file to your package, or changing the status in the CodeCatalyst console.

   1.  Option 1: Use the following `curl` command to add a `maven-metadata.xml` file to your package. Replace *username*, *space\$1name*, *proj\$1name*, and *repo\$1name* with your CodeCatalyst user name, space name, project name, and package repository name. 

      ```
      curl --request PUT https://packages.region.codecatalyst.aws/maven/space-name/proj-name/repo-name/com/mycompany/app/my-app/maven-metadata.xml \
           --user "username:CodeCatalyst_ARTIFACTS_TOKEN" --header "Content-Type: application/octet-stream" \
           --data-binary @target/maven-metadata.xml
      ```

      Following is an example of the contents of a `maven-metadata.xml` file:

      ```
      <metadata modelVersion="1.1.0">
          <groupId>com.mycompany.app</groupId>
          <artifactId>my-app</artifactId>
          <versioning>
              <latest>1.0</latest>
              <release>1.0</release>
              <versions>
                  <version>1.0</version>
              </versions>
              <lastUpdated>20200731090423</lastUpdated>
          </versioning>
      </metadata>
      ```

   1.  Option 2: Update the package status to `Published` in the CodeCatalyst console. For information about how to update a package version's status, see [Updating a package version's status](working-with-packages-update-version-status.md). 

If you only have a package's JAR file, you can publish a consumable package version to a CodeCatalyst repository using `mvn`. This can be useful if you do not have access to the package's source code or POM. See [Publishing third-party packages](packages-maven-mvn.md#publishing-third-party-packages) for details.

# Using Maven checksums and snapshots
<a name="packages-maven-checksums-snapshots"></a>

The following sections describe how to use Maven checksums and Maven snapshots in CodeCatalyst.

## Using Maven checksums
<a name="maven-checksums"></a>

 When a Maven package is published to a CodeCatalyst package repository, the checksum associated with each *asset* or file in the package is used to validate the upload. Examples of assets are *jar*, *pom*, and *war* files. For each asset, the Maven package contains multiple checksum files that use the asset name with an additional extension, such as `md5` or `sha1`. For example, the checksum files for a file named `my-maven-package.jar` might be `my-maven-package.jar.md5` and `my-maven-package.jar.sha1`. 

 Every Maven package also contains a `maven-metadata.xml` file. This file must be uploaded for a publish to succeed. If a checksum mismatch is detected during the upload of any package file, the publish stops. This might prevent the `maven-metadata.xml` from being uploaded. When that happens, the status of the Maven package is set to `Unfinished`. You cannot download assets that are part of a package with this status. 

Keep the following in mind in the event of a checksum mismatch when you publish a Maven package: 
+  If the checksum mismatch occurs before `maven-metadata.xml` is uploaded, the status of the package is not set to `Unfinished`. The package is not visible and its assets cannot be consumed. When this happens, try one of the following, and then try to download the asset again. 
  + Run the command that publishes the Maven package again. This might work if a network issue corrupted the checksum file during download. If the network issue is resolved for the retry, the checksum matches and the download is successful. 
  +  If republishing the Maven package doesn't work, delete the package and then republish it. 
+  If the checksum mismatch occurs after `maven-metadata.xml` is uploaded, the status of the package is set to `Published`. You can consume any asset from the package, including those with checksum mismatches. When you download an asset, the checksum generated by CodeCatalyst is downloaded with it. If the downloaded file is associated with a checksum mismatch, its downloaded checksum file might not match the checksum that was uploaded when the package was published. 

## Using Maven snapshots
<a name="maven-snapshots"></a>

 A Maven *snapshot* is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix `SNAPSHOT` that is appended to the package version. For example, the snapshot of version `1.1` is `1.1-SNAPSHOT`. For more information, see [What is a SNAPSHOT version?](https://maven.apache.org/guides/getting-started/index.html#What_is_a_SNAPSHOT_version) on the Apache Maven Project website. 

 CodeCatalyst supports publishing and consuming Maven snapshots. You can publish a Maven snapshot to a CodeCatalyst repository or, if you are directly connected, to an upstream repository. However, a snapshot version in both a package repository and one of its upstream repositories is not supported. For example, if you upload a Maven package with version `1.2-SNAPSHOT` to your package repository, CodeCatalyst does not support uploading a Maven package with the same snapshot version to one of its upstream repositories. This scenario might return unpredictable results. 

 When a Maven snapshot is published, its previous version is preserved in a new version called a *build*. Each time a Maven snapshot is published, a new build version is created. All previous versions of a snapshot are maintained in its build versions. When a Maven snapshot is published, its status is set to `Published` and the status of the build that contains the previous version is set to `Unlisted`. 

 If you request a snapshot, the version with status `Published` is returned. This is always the most recent version of the Maven snapshot. You can also request a particular build of a snapshot. 

To delete all build versions of a Maven snapshot, use the CodeCatalyst console.