Deploying JARs where you don’t have the original source

Sometimes you need to use a JAR, but it hasn’t been published to a Maven repository. This sometimes happens with database drivers, reporting tools, or other closed source dependencies. If you have been provided a JAR, and you want to be able to depend on it in your Maven based projects, you can deploy it to Deps.

Configuring Maven settings

Before you start, you need to install Maven. If you don’t have it, then you can download it from the Apache Maven website, or via your package manager.

Once you have it installed, create a file called settings.xml in the same location as your JARs. If you have already configured Deps for Maven based authentication then you can skip this step. Copy the settings.xml file, below, but replace it with your Deps access key.

<?xml version="1.0"?>
<settings>
    <servers>
        <server>
            <id>releases</id>
            <username>YOURDEPSKEY</username>
            <password>YOURDEPSSECRET</password>
        </server>
        <server>
            <id>snapshots</id>
            <username>YOURDEPSKEY</username>
            <password>YOURDEPSSECRET</password>
        </server>
    </servers>
</settings

Once you have it configured, you can run this command, replacing the values in the command with ones appropriate for your JAR.

mvn deploy:deploy-file \
  -DgroupId=com.acme \
  -DartifactId=acme-utils \
  -Dversion=1.1.0 \
  -Dpackaging=jar \
  -Dfile=lib/acme-utils.jar \
  -DrepositoryId=releases \
  -Durl=https://repo.deps.co/{organisation alias}/{repository slug} \
  --settings settings.xml

Repeat as necessary for each JAR you need to deploy.

Further reading

You can read more about this in Maven’s guide on deploying 3rd party JARs to a remote repository.