我正在尝试将我的库推送到GitHub Packages。 我已经配置了个人访问令牌,并且在根文件夹中有github.properties文件。
使用gradle assemble
来组装aar文件。
当我运行gradle publish
命令时。
我收到此错误Received status code 400 from server: Bad Request
* What went wrong:
Execution failed for task ':library_to_publish:publishProductionPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'Production' to repository 'GitHubPackages'
> Could not write to resource 'https://maven.pkg.github.com/<user>/GitHubPackagesDemo/com/avp/test/lib/githubpackages/library_to_publish/1.0.6/library_to_publish-1.0.6.aar'.
> Could not PUT 'https://maven.pkg.github.com/<user>/GitHubPackagesDemo/com/avp/test/lib/githubpackages/library_to_publish/1.0.6/library_to_publish-1.0.6.aar'. Received status code 400 from server: Bad Request
这是我在build.gradle
文件中的配置
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
def githubProperties = new Properties()
githubProperties.load(new FileInputStream(rootProject.file("github.properties")))
def getVersionName = { ->
return "1.0.6"
}
def getartificatId = { ->
return "library_to_publish"
}
publishing {
publications {
Production(MavenPublication) {
groupId 'com.avp.test.lib.githubpackages' // Replace with group ID
artifactId getartificatId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getartificatId()}-release.aar")
pom.withXml {
def dependenciesnode = asnode().appendNode('dependencies')
// Iterate over the implementation dependencies (we don't want the test ones),// adding a <dependency> node for each
configurations.implementation.allDependencies.each {
// Ensure dependencies such as fileTree are not included in the pom.
if (it.name != 'unspecified') {
def dependencyNode = dependenciesnode.appendNode('dependency')
dependencyNode.appendNode('groupId',it.group)
dependencyNode.appendNode('artifactId',it.name)
dependencyNode.appendNode('version',it.version)
}
}
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/<user>/GitHubPackagesDemo")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}
有人知道为什么会这样吗?