我正在尝试使用 Gradle 将工件发布到 Maven 存储库。请注意,这是一个预构建的工件,没有任何 Maven 依赖项。它只是一个 tar.gz。
所以我有这个:
def testArchive = layout.projectDirectory.file('src/resources/my.tar.gz')
apply plugin: 'maven-publish'
publishing {
def cloudRepoCredentials = {
username System.env['MAVEN_USER']
password System.env['MAVEN_KEY']
}
repositories {
maven {
credentials cloudRepoCredentials
url "https://****"
}
}
publications {
maven(testArchive) {
artifactId '***'
version 1.0
artifact testArchive
}
}
}
我收到了这个错误:
Exception thrown while executing model rule: PublishingPlugin.Rules#publishing(ExtensionContainer)
> Could not find method maven() for arguments [/Users/***/src/resources/my.tar.gz, build_9znt9jm2cpjsuhvf4yccz6ocn$_run_closure1$_closure4$_closure6@786a2956] on Publication container of type org.gradle.api.publish.internal.DefaultPublicationContainer.
我尝试from components.java
在 Maven 块内添加,但我得到了同样的错误。
谢谢你们的帮助!