简体   繁体   English

当源附件不可修改时,如何将源附加到Gradle Eclipse Project中的jar中?

[英]How to attach the source to the jar in the Gradle Eclipse Project when the source attachment is not modifiable?

There is a similar question ( How do I attach source code into a project's library in Eclipse? ). 还有一个类似的问题( 如何在Eclipse中将源代码附加到项目的库中? )。

However, in my case the jar has the description non modifiable and the option Edit is not possible. 但是,在我的情况下,该jar的描述不可修改,并且无法使用选项Edit。 What to do in this case? 在这种情况下该怎么办?

Here is the picture. 这是图片。
在此处输入图片说明

For homegrown projects the solution is to create a source jar for the library that you use. 对于本地项目,解决方案是为您使用的库创建一个源jar。 This can be done by adding to build.gradle 这可以通过添加到build.gradle中来完成

task sourceJar(type: Jar, dependsOn: classes) {
    classifier 'sources'
    from sourceSets.main.allSource
}

And then add to publications: 然后添加到出版物:

artifact sourceJar

Publish the jars to the local Maven repository, then the source will be attached in Eclipse while referring this library. 将jar发布到本地Maven存储库,然后在引用该库时将源附加在Eclipse中。

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

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