如何使用Gradle将源发布到本地Maven存储库中? [英] How to publish source into local maven repository with Gradle?
问题描述
我正在开发两个相关的项目.其中一个是助手",另一个是主要"助手.我不断地更新主",但是我也时不时地更新助手".之后,我在gradle的maven插件中运行install
目标,并在本地maven存储库中获取jar.之后,我在主"项目中进行了gradle更新,并链接了更新的jar.
I am developing two related project. One of which is "helper" one and another is "main" one. I am constantly updating "main", but from time to time I am also updating "helper" one. After then I am running install
goal in gradle's maven plugin and get jars in local maven repo. After that I do gradle update in "main" project and have updated jars linked.
有两个问题.
1)如果仍然使用Maven插件,那么如何将源代码也发布到本地Maven存储库中?
1) If staying with maven plugin, then how to publish source code into local maven repo too?
2)我可以在没有maven插件的情况下做类似的事情,只留在Gradle上吗?
2) Can I do similar without maven plugin, staying only with Gradle?
推荐答案
使用"maven-publish"插件发布源代码很容易:
It's easy to publish sources with the "maven-publish" plugin:
apply plugin: "maven-publish"
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
}
然后发布到本地Maven运行:gradle publishToMavenLocal
Then go publish to local maven run: gradle publishToMavenLocal
文档中的更多信息: https://docs. gradle.org/current/userguide/publishing_maven.html#gsc.tab=0
这篇关于如何使用Gradle将源发布到本地Maven存储库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!