Switch to maven-publish because maven plugin is deprecated.
diff --git a/Makefile b/Makefile
index 8fd4db2..f82301a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
 lint:
 	./gradlew --warning-mode=all lint
 archive:
-	./gradlew --warning-mode=all uploadArchives
+	./gradlew --warning-mode=all publishReleasePublicationToLocalRepository
 sync: archive
 	rsync -av --chmod=g+w --chown=:gs-priv $(HOME)/MAVEN/com/ ghostscript.com:/var/www/maven.ghostscript.com/com/
 
diff --git a/build.gradle b/build.gradle
index 80e6f2f..4a43a3a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,10 @@
 buildscript {
 	repositories {
+		if (project.hasProperty('MAVEN_REPO')) {
+			maven { url MAVEN_REPO }
+		} else {
+			maven { url "file://${System.properties['user.home']}/MAVEN" }
+		}
 		google()
 		mavenCentral()
 	}
@@ -12,6 +17,8 @@
 	repositories {
 		if (project.hasProperty('MAVEN_REPO')) {
 			maven { url MAVEN_REPO }
+		} else {
+			maven { url "file://${System.properties['user.home']}/MAVEN" }
 		}
 		maven { url 'https://maven.ghostscript.com/' }
 		google()
diff --git a/lib/build.gradle b/lib/build.gradle
index 84b6efc..680c2d5 100644
--- a/lib/build.gradle
+++ b/lib/build.gradle
@@ -1,5 +1,5 @@
 apply plugin: 'com.android.library'
-apply plugin: 'maven'
+apply plugin: 'maven-publish'
 
 group = 'com.artifex.mupdf'
 version = '1.19.0'
@@ -18,26 +18,49 @@
 		minSdkVersion 21
 		targetSdkVersion 31
 	}
+	publishing {
+		singleVariant("release") {
+			withSourcesJar()
+		}
+	}
 }
 
-uploadArchives {
-	repositories {
-		mavenDeployer {
-			if (project.hasProperty('MAVEN_REPO')) {
-				repository(url: MAVEN_REPO)
-			} else {
-				repository(url: "file://${System.properties['user.home']}/MAVEN")
-			}
-			pom {
-				artifactId = 'viewer'
-				project {
+project.afterEvaluate {
+	publishing {
+		publications {
+			release(MavenPublication) {
+				artifactId 'viewer'
+				artifact(bundleReleaseAar)
+
+				pom {
+					name = 'viewer'
+					url = 'http://www.mupdf.com'
 					licenses {
 						license {
-							name 'GNU Affero General Public License'
-							url 'https://www.gnu.org/licenses/agpl-3.0.html'
+							name = 'GNU Affero General Public License'
+							url = 'https://www.gnu.org/licenses/agpl-3.0.html'
 						}
 					}
 				}
+				pom.withXml {
+					final dependenciesNode = asNode().appendNode('dependencies')
+					configurations.implementation.allDependencies.each {
+						def dependencyNode = dependenciesNode.appendNode('dependency')
+						dependencyNode.appendNode('groupId', it.group)
+						dependencyNode.appendNode('artifactId', it.name)
+						dependencyNode.appendNode('version', it.version)
+					}
+				}
+			}
+		}
+		repositories {
+			maven {
+				name 'Local'
+				if (project.hasProperty('MAVEN_REPO')) {
+					url = MAVEN_REPO
+				} else {
+					url = "file://${System.properties['user.home']}/MAVEN"
+				}
 			}
 		}
 	}