Skip to content

Maven repository server

Somkiat Puisungnoen edited this page Nov 16, 2022 · 4 revisions

Use a Apache Maven repository server (Internal server)

Step 1 :: Setup Server

  • username and password
  • Create repository
No Name Type Description
1 maven-snapshots hosted Keep version x.x.x-snapshots
2 maven-releases hosted Keep version x.x.x
3 maven-central proxy Proxy to the remote repository
4 maven-public group maven-snapshots,maven-releases,maven-central

Step 2 :: .m2/settings.xml in local computer

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

  <servers>
    <server>
      <id>maven-snapshots</id>
      <username>admin</username>
      <password>admin</password>
    </server>
    <server>
      <id>maven-releases</id>
      <username>admin</username>
      <password>admin</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>maven-releases</id>
      <url>http://localhost:8081/repository/maven-public/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

</settings>

Step 3 :: pom.xml in Maven project

<repositories>
	<repository>
		<id>maven-public</id>
		<url>http://localhost:8081/repository/maven-public/</url>
	</repository>
</repositories>

<distributionManagement>
	<snapshotRepository>
		<id>maven-snapshots</id>
		<url>http://localhost:8081/repository/maven-snapshots/</url>
	</snapshotRepository>
	<repository>
		<id>maven-releases</id>
		<url>http://localhost:8081/repository/maven-releases/</url>
	</repository>
</distributionManagement>

Step 4 :: Build and deploy

$mvnw deploy

Reference Websites