Gradle-如何为maven依赖项指定javadoc位置jar文件



我想将本地javadoc-jar添加到maven依赖项中。有可能吗?如果是,我该怎么做?问题是我有maven依赖项,它包含可传递的jar

dependencies {
    compile 'org.eclipse.persistence:eclipselink:2.5.0'
}

gradle dependencies命令返回以下内容:

compile - Compile classpath for source set 'main'.
+--- org.eclipse.persistence:eclipselink:2.5.0
     +--- org.eclipse.persistence:javax.persistence:2.1.0
     --- org.eclipse.persistence:commonj.sdo:2.1.1

主依赖项eclipselink包含javax.persistence的javadoc,所以我在eclipse编辑器中看不到javadoc提示。我想做的是将eclipselinkjavadoc连接到javax.persistence

这就是我所期望的:

dependencies {
    compile 'org.eclipse.persistence:javax.persistence:2.1.0' {
        javadoc = <path to javadoc>
    }
}

问题已解决。我已经使用gradle eclipse插件编辑了eclipse .classpath文件,它做了它应该做的事情。这是代码:

eclipse {
    classpath {
       downloadSources=true
       downloadJavadoc=true
        file {
            withXml {
                def node = it.asNode()
                // find eclipselink javadoc path
                def eclipselinkPath = configurations.compile.find { it.absolutePath.contains('eclipselink') }
                def javaxPersistenceJavadocPath = ""
                node.each {
                    def filePath = it.attribute('path')
                    if (file(filePath) == file(eclipselinkPath)) {
                        javaxPersistenceJavadocPath = it.attributes.attribute.@value[0]
                    }
                }
                // add eclipselink javadoc path as attribute to javax.persistence
                def javaxPersistencePath = configurations.compile.find { it.absolutePath.contains('javax.persistence') }
                node.each {
                    def filePath = it.attribute('path')
                    if (file(filePath) == file(javaxPersistencePath)) {
                        it.appendNode('attributes').appendNode('attribute', [name:'javadoc_location', value:javaxPersistenceJavadocPath])
                    }
                }
            }
        }
    }
}

我知道它看起来很难看,但我没有更多的时间来解决这个问题。顺便说一句,这不是我问题的根源(我有依赖关系或渐变缓存的问题,我还不知道)。

最新更新