这个问题已经被问过好几次了,但不知何故我没有得到这个工作。 Gradle 是一个很棒的工具,但它的文档却不是很好。对于不每天使用它的人来说,没有任何示例几乎不可能理解。
我正在使用 Android Studio,我想将我的模块输出 jar 上传到我的本地 Maven 存储库。
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 中开始构建时,我可以在 Gradle 选项卡上看到
:install
被调用。我还在构建文件夹中获得了一个新 jar,但该 jar 未上传到 Maven。 [Maven repo 存在,Google appengine gradle 插件从同一项目的另一个模块上传它的 jar 就好了。]
我错过了什么?
请您参考如下方法:
我怀疑问题在于您只是在编辑 POM(通过 pom.project ),而不是配置用于安装的实际 Maven 坐标。请尝试以下操作:
// 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:
samples完整 Gradle 发行版中的目录包含许多示例构建,也适用于
maven插入。


