使用gradle这个上传罐子本地Maven仓库 [英] Use gradle to upload jar to local Maven repository
问题描述
这个问题已经被问了好几次,但不知何故,我没有得到这个工作。摇篮是一个伟大的工具,但它的文档是什么,但伟大的。没有例子使它几乎无法理解的人谁不使用它每天的基础上。
This question has been asked several times, but somehow I don't get this to work. Gradle is a great tool, but its documentation is anything but great. No examples make it almost impossible to understand for someone who doesn't use it on a daily basis.
我使用Android的工作室,我想我的模块输出的jar上传到我的本地仓库。
I am using Android Studio and I want to upload my module output jar to my local Maven repository.
apply plugin: 'java'
dependencies {
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
}
apply plugin: 'maven'
configure(install.repositories.mavenInstaller) {
pom.project {
groupId 'com.example'
artifactId 'example'
packaging 'jar'
}
}
当我开始Android Studio中的生成,我可以在摇篮选项卡上看到,
When I start a build in Android Studio, I can see on the Gradle tab that
:install
被调用。我也得到我的build文件夹中一个新的jar,但罐子没有上传到Maven的。 [Maven的回购存在,而且谷歌的AppEngine插件的gradle其上传罐子从同一项目就好了另一个模块。]
is invoked. I also get a new jar in my build folder, but that jar is not uploaded to Maven. [The Maven repo exists and the Google appengine gradle plugin uploads its jar from another module of the same project just fine.]
我是什么失踪?
推荐答案
我怀疑的问题是,你只能编辑POM(通过 pom.project
),而不是配置的用于安装的实际Maven的坐标。而不是尝试以下操作:
I suspect the problem is that you are only editing the POM (via pom.project
), instead of configuring the actual Maven coordinates used for installation. Try the following instead:
// best way to set group ID
group = 'com.example'
install {
repositories.mavenInstaller {
// only necessary if artifact ID diverges from project name
// the latter defaults to project directory name and can be
// configured in settings.gradle
pom.artifactId = 'myName'
// shouldn't be needed as this is the default anyway
pom.packaging = 'jar'
}
}
PS:在在充分摇篮分配样本
目录中包含大量的实例建立,也为行家
插件。
PS: The samples
directory in the full Gradle distribution contains many example builds, also for the maven
plugin.
这篇关于使用gradle这个上传罐子本地Maven仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!