如何用gradle构建源jar? [英] How to build sources jar with gradle?
问题描述
我正在使用gradle构建一个开源项目.我想生成一个(project)-sources.jar文件,可以将其加载到我的IDE(IntelliJ IDEA)中并通过该项目进行调试.如果可以生成文件,我知道如何加载.
I am working with an open source project that is built with gradle. I would like to generate a (project)-sources.jar file that I can load into my IDE (IntelliJ IDEA) and debug through the project. I know how to load the file if I can generate it.
我已经浏览了该项目可用的gradle任务,但没有一个生成source jar文件.
I have looked through the available gradle tasks for the project and there isn't one that generates a sources jar file.
为该项目生成源jar文件的最简单方法是什么?
What is the easiest way to generate a sources jar file for this project?
将源代码添加到包含已编译的类文件的jar文件中也可以.
Adding the source into the jar file that contains the compiled class files would be fine as well.
推荐答案
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
这篇关于如何用gradle构建源jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!