mvn deploy:deploy-file with WebDAV
Deploying third party artifacts to an internal Maven repo
Though most of the Java libraries are already in the official Maven repository you will from time to time encounter artifacts that are not available there. Reasons for this include licensing issues (e.g. Oracle JDBC drivers and some Sun Java APIs) and a lack of maintainers.
Most users of Maven run an internal repository for those artifacts and to distribute their own work products.
Recent versions of Maven support uploading artificats along with their sources directly into your internal repo through WebDAV:
mvn deploy:deploy-file \
-DrepositoryId="internal" \
-Durl="dav:https://server/repo" \
-Dfile="oracle-jdbc.jar" \
-DgroupId="com.oracle" \
-DartifactId="oracle-jdbc" \
-Dversion="1.2.3" \
-Dpackaging=jar \
-DgeneratePom=true
The -DgeneratePom=true option tells Maven to generate a basic but fully functional POM without any dependencies.
Using -Dclassifier=sources allows you to upload a corresponding -sources.jar file.
You can also easily automate downloading the original artifact (precompiles jar file, sources, whatever), compiling or repacking and uploading to your repo.
This is what I use for Openfire:
#!/bin/bash
if [ "$#" != "1" ]
then
echo Usage: $0 openfire_version
echo Example: $0 3.6.0
echo
exit 1
fi
GROUP_ID="org.igniterealtime.openfire"
ARTIFACT_ID="openfire"
VERSION="$1"
BASE_URL="http://www.igniterealtime.org/downloadServlet?filename=openfire/"
BIN_URL="${BASE_URL}openfire_${VERSION//\./_}.tar.gz"
SRC_URL="${BASE_URL}openfire_src_${VERSION//\./_}.tar.gz"
REPO_ID="reucon"
REPO_URL="dav:https://secure.reucon.net/maven/public"
wget -O "openfire-${VERSION}.tar.gz" "$BIN_URL"
wget -O "openfire-${VERSION}-sources.tar.gz" "$SRC_URL"
tar xvfz "openfire-${VERSION}.tar.gz"
unpack200 openfire/lib/openfire.jar.pack "openfire-${VERSION}.jar"
tar xvfz "openfire-${VERSION}-sources.tar.gz"
jar cvf "openfire-${VERSION}-sources.jar" -C openfire_src/src/java .
mvn deploy:deploy-file \
-DrepositoryId="$REPO_ID" -Durl="$REPO_URL" \
-Dfile="openfire-${VERSION}.jar" \
-DgroupId="$GROUP_ID" -DartifactId="$ARTIFACT_ID" -Dversion="$VERSION" \
-Dpackaging=jar -DgeneratePom=true
mvn deploy:deploy-file \
-DrepositoryId="$REPO_ID" -Durl="$REPO_URL" \
-Dfile="openfire-${VERSION}-sources.jar" \
-DgroupId="$GROUP_ID" -DartifactId="$ARTIFACT_ID" -Dversion="$VERSION" \
-Dpackaging=jar -Dclassifier=sources