通过gradle将本地JAR发布到nexus存储库

通过gradle将本地JAR发布到nexus存储库,gradle,Gradle,我在本地系统中有一些jar文件,我想用Gradle脚本发布这些文件,但到目前为止我还没有找到任何解决方案。 我可以发布构建生成的工件,但我想发布本地系统中的JAR。 我试图声明工件,如下所示,但它抛出错误: publishing { publications { mavenJava(MavenPublication) { artifact projJar //This is jar file other than my built file which I

我在本地系统中有一些jar文件,我想用Gradle脚本发布这些文件,但到目前为止我还没有找到任何解决方案。 我可以发布构建生成的工件,但我想发布本地系统中的JAR。 我试图声明工件,如下所示,但它抛出错误:

publishing {
  publications {
    mavenJava(MavenPublication) {
        artifact projJar

    //This is jar file other than my built file which I want to upload (there are same files more in number to be uploaded):
        artifact 'D:/myworkspace/Test/LocalJar.jar'
        artifact source: projJar, classifier: 'src', extension: 'jar'

    }
}
repositories {
    maven {
        credentials {
            username 'user'
            password 'password'
          }
        url "http://IP:Port/repository/RepoName/"
    }
}
}

错误消息为:

 *What went wrong:
  Execution failed for task:publishMavenJavaPublicationToMaven2Repository'.
  > Failed to publish publication 'mavenJava' to repository 'maven2'
  > Invalid publication 'mavenJava': multiple artifacts with the identical extension and classifier ('jar', 'null').

请用一些示例指导我如何将我的本地jar文件发布到nexus存储库(我的本地存储库中有很多文件我想发布)

您看过中的答案了吗?根据错误消息,我认为您需要删除
工件projJar
工件源代码:projJar,分类器:'src',扩展名:'jar'
定义。尝试了这两种方法,但没有帮助。首先,我遵循链接,build正在成功运行,但它没有上传我明确定义的jar,而是只上传从我的build生成的jar。其次,我删除了您要求我删除的行,但我收到了相同的错误消息:-(