Gradle告诉我'必须指定一个部署存储库'

时间:2016-05-31 07:26:32

标签: maven gradle android-gradle gradle-plugin

我尝试编写gradle插件,我想将它部署到localMaven。 我写这样的代码

group='cn.sola.gradle'
version='1.0-SNAPSHOT'
uploadArchives {
repositories {
    mavenDeployer {
        mavenLocal()
     }
   }
}

然后我运行此命令 gradle -q upload 但是像这样的gradle打印:

* What went wrong:
  Execution failed for task ':uploadArchives'.
  > Could not publish configuration 'archives'
    > Must specify a repository for deployment
enter code here

但是我的文件已经存在了。 目录下的文件是这样的。

ls ~/.m2/repository/cn/sola/gradle/HelloGradlePlugin/1.0-SNAPSHOT/

HelloGradlePlugin-1.0-SNAPSHOT.jar       ivy-1.0-SNAPSHOT.xml
HelloGradlePlugin-1.0-SNAPSHOT.jar.sha1  ivy-1.0-SNAPSHOT.xml.sha1

异常是什么意思?文件好吗?

----添加信息----

:uploadArchives (Thread[main,5,main]) started.
:uploadArchives
Executing task ':uploadArchives' (up-to-date check took 0.001 secs) due to:
  Task has not declared any outputs.
Publishing configuration: configuration ':archives'
Publishing to Maven repository 'MavenLocal'
Published HelloGradlePlugin.jar (cn.sola.gradle:HelloGradlePlugin:1.0-SNAPSHOT) to file:/Users/sola1tmy/.m2/repository/cn/sola/gradle/HelloGradlePlugin/1.0-SNAPSHOT/HelloGradlePlugin-1.0-SNAPSHOT.jar
Published ivy.xml (cn.sola.gradle:HelloGradlePlugin:1.0-SNAPSHOT) to file:/Users/sola1tmy/.m2/repository/cn/sola/gradle/HelloGradlePlugin/1.0-SNAPSHOT/ivy-1.0-SNAPSHOT.xml
Publishing to org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer@b46e103
:uploadArchives FAILED
:uploadArchives (Thread[main,5,main]) completed. Took 0.516 secs.

1 个答案:

答案 0 :(得分:1)

如果你想"部署"你的jar(或其他)到本地maven资源库,maven插件提供了install任务。你唯一要做的就是打电话:

gradle install

参考:https://docs.gradle.org/current/userguide/maven_plugin.html#uploading_to_maven_repositories(见32.6.3)