简体   繁体   English

将源添加到.jar以进行gradle构建

[英]Adding sources to a .jar for gradle build

I have a gradle project and I want to add a .jar and attach its source to the "Project and External Dependencies" folder when it builds. 我有一个gradle项目,我想添加一个.jar,并在构建时将其源代码附加到“Project and External Dependencies”文件夹。 Adding the .jar bit is fine, I can do that. 添加.jar位很好,我可以这样做。 Added the line 添加了该行

compile files('lib/choco-solver-4.10.0.jar')

under the dependencies{} section and it does it just fine. dependencies{}部分下,它就可以了。 No problems. 没问题。

I have choco-solver-4.10.0-sources.jar as well, which is the source code for the choco-solver-4.10.0.jar . 我也有choco-solver-4.10.0-sources.jar ,这是choco-solver-4.10.0.jar的源代码。 I want this source code so that i can dig into the code of it when debugging/coding. 我想要这个源代码,以便我可以在调试/编码时深入研究它的代码。

I don't know how and can't find a way (after 45 minutes of googling searching) to attach the source code to this so that it ends up with the .jar in "Project and External Dependencies" attached to choco-solver-4.10.0.jar . 我不知道怎么也找不到一种方法(谷歌搜索45分钟后)将源代码附加到这个,以便最终得到附加到choco-solver-4.10.0.jar “Project and External Dependencies”中choco-solver-4.10.0.jar If someone could point me to a previously answered question or google result that shows me to do this i'd be equally as grateful as if someone gave me an answer here. 如果有人能指出我以前回答的问题或谷歌结果,这表明我这样做,我会同样感激,好像有人在这里给了我一个答案。

I can add choco-solver-4.10.0.jar to the build path of the Eclipse project, but that doesn't seem to help in getting it to sort itself out with Gradle. 我可以将choco-solver-4.10.0.jar添加到Eclipse项目的构建路径中,但这似乎没有帮助它使用Gradle对其进行自我排序。

I'm genuinely at a loss at the moment. 我此刻真的很茫然。 Thanks in advance for any help. 在此先感谢您的帮助。 Bear in mind that I am a Mathematics graduate who has been coding in java less than a year, and this sort of stuff is very new to me. 请记住,我是一名数学专业的毕业生,他在java编写不到一年的时间,这种东西对我来说很新鲜。

Have you tried to add it to your project's properties? 您是否尝试将其添加到项目的属性中?

Go to Properties -> Java Build Path -> Libraries 转到属性 - > Java构建路径 - >库

Then select the library you want to attach the source for in the list, expand it, you should see something like that: 然后在列表中选择要附加源的库,展开它,您应该看到类似的内容:

Source Attachment: (none)
Javadoc location: (none)
Native library location: (none)
Is not modular - non modifiable
Access rules: (No restrictions)

Click on Source attachment: (none) and then Edit... , from this window you should be able to select your source jar and attach it. 单击Source attachment: (none)然后Edit... ,在此窗口中,您应该能够选择源jar并附加它。

I do not know where you got this library, but there is a plugin in the Eclipse marketplace, named Java Source Attacher , which automatically search for the sources of your library in the popular Java repositories on Internet and attach it to your project. 我不知道你在哪里有这个库,但是在Eclipse市场中有一个名为Java Source Attacher的插件,它自动在Internet上流行的Java存储库中搜索你的库的源代码并将它附加到你的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM