Working with Maven
Publish Maven Package
-
Add the following inside the
<project>element of yourpom.xml(replace<project path>before use):<repositories><repository><id>onedev</id><url>https://onedev.example.com/<project path>/~maven</url></repository></repositories><distributionManagement><repository><id>onedev</id><url>https://onedev.example.com/<project path>/~maven</url></repository><snapshotRepository><id>onedev</id><url>https://onedev.example.com/<project path>/~maven</url></snapshotRepository></distributionManagement>Param Explanation <project path> path of a project with package management enabled -
Add below to
$HOME/.m2/settings.xmlif you want to deploy from command line:<settings><servers><server><id>onedev</id><username>onedev_account_name</username><password>onedev_password_or_access_token</password></server></servers></settings>If
settings.xmlalready exists, merge the server entry into its existing<settings>element. The server ID must match the repository ID inpom.xml. Keep credentials out of source control. -
Publish from the directory containing
pom.xml:mvn --settings /path/to/settings.xml clean deploy -
For CI/CD job, it is more convenient to use a custom settings.xml, for instance via below code in a command step:
cat << EOF > settings.xml<settings><servers><server><id>onedev</id><!-- Use job token as user name so that OneDev can know which build is deploying packages --><username>@job_token@</username><!-- Job secret 'access-token' should be defined in project build setting as an access token with package write permission --><password>@secret:access-token@</password></server></servers></settings>EOFmvn --settings settings.xml clean deploy
Consume Published Maven Package
Open the package's detail page for its repository and dependency XML. Add the repository and dependency to the consuming project's pom.xml, and configure the matching server ID in its Maven settings with package read permission.
Resolve from a separate consumer project or clean local Maven repository when verifying publication; mvn deploy also installs the artifact locally, which can otherwise hide registry problems.

Query Published Maven Package
When query maven package from package list page, Name should be specified in form of <group id>:<artifact id>. Wildcard can be used for name query, for instance io.onedev.server:* will match all packages with group id io.onedev.server