iT邦幫忙

0

用 GitHub Packages 發佈 Maven repository

  • 分享至 

  • xImage

請問有人近期成功地將套件 deploy 到 GitHub Registry 嗎?參考資料來源:

~/.m2/settings.xml (BTW,也試過了全域的):

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

	<profiles>
		<profile>
			<id>github</id>
			<repositories>
				<repository>
				<id>central</id>
				<url>https://repo1.maven.org/maven2</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
			<repository>
				<id>github</id>
				<name>GitHub OWNER Apache Maven Packages</name>
				<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
				</repository>
			</repositories>
		</profile>
	</profiles>

	<servers>
		<server>
			<id>github</id>
			<username>OWNER</username>
			<password>${env.GITHUB_TOKEN}</password>
		</server>
	</servers>
</settings>

其中<activeProfiles/><profiles/>經爬文後確認可省略,但有沒有這兩個 elements 結果都還是一樣。

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>group-id</groupId>
	<artifactId>artifact-id</artifactId>
	<version>version</version>
	<packaging>jar</packaging>

	<distributionManagement>
		<repository>
			<id>github</id>
			<name>GitHub OWNER Apache Maven Packages</name>
			<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
		</repository>
		<!--
		<snapshotRepository>
			<id>github</id>
			<name>GitHub OWNER Apache Maven Packages</name>
			<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
			<uniqueVersion>false</uniqueVersion>
		</snapshotRepository>
		-->
	</distributionManagement>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<!--<github.global.server>github</github.global.server>-->
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.1</version>
				<configuration>
					<showDeprecation>true</showDeprecation>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-deploy-plugin</artifactId>
				<version>2.8.2</version>
			</plugin>
		</plugins>
	</build>
</project>

從註解可看出我爬過一些非官方的文並做過其它嘗試。

下面是錯誤訊息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project PROJECT: Failed to deploy artifacts: Could not find artifact group-id:artifact-id:jar:version in github (https://maven.pkg.github.com/OWNER/REPOSITORY) -> [Help 1]

估計欲發佈的路徑不存在(http response status code 404),please help!

(以上PROJECTgroup-idartifact-idversionOWNERREPOSITORY等值,為刻意遮罩)

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答