【问题标题】:Gradle - how to specify javadoc location jar file for maven dependency?Gradle - 如何为 Maven 依赖项指定 javadoc 位置 jar 文件?
【发布时间】:2013-09-02 07:18:30
【问题描述】:

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

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 提示。我要做的是将eclipselink javadoc 连接到javax.persistence

这是我所期望的:

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

【问题讨论】:

    标签: java maven eclipselink gradle


    【解决方案1】:

    问题解决了。我已经使用 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])
                        }
                    }
                }
            }
        }
    }
    

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

    【讨论】:

      猜你喜欢
      • 2016-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-27
      • 1970-01-01
      相关资源
      最近更新 更多