3

I want to add local javadoc jar to maven dependency. Is it possible? If yes, how can I do it? The problem is that I've got maven dependency which contains transitive jars

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

gradle dependencies command returned this:

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

Main dependency eclipselink contains javadoc for javax.persistence so I can't see javadoc hints in eclipse editor. What I want to do is to connect eclipselink javadoc to javax.persistence.

This is what I expect:

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

1 回答 1

2

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

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])
                    }
                }
            }
        }
    }
}

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

于 2013-08-30T18:08:32.660 回答