IntelliJ IDEA: How can I make sources of dependent libraries to be available in classpath on compilation?

社会主义新天地 提交于 2019-12-11 00:22:35

问题


How can I make sources of dependent libraries to be available in classpath on compilation ?

I'm using IntelliJ IDEA 11.

When I add Global Library to module and artifact IDE never copies sources and javadocs. That makes sense because they are not needed in runtime. But I need them in compile time.

Interestingly though IDEA makes sources available if I add dependency as folder. I guess in this case it doesn't differentiate what sits in that folder. Odd.

Thoughts ?


回答1:


i solved this issue in maven config by specifying another dependency to hibernate-validator one with sources and one without.

the one with sources i defined:

classifier: sources scope: provided

EX:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.1.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.1.0.Final</version>
        <classifier>sources</classifier>
        <scope>provided</scope>
    </dependency>



回答2:


It's a bug that sources attached to a library are not used on GWT compilation. This bug is fixed in IDEA 11.1 EAP.



来源:https://stackoverflow.com/questions/9630298/intellij-idea-how-can-i-make-sources-of-dependent-libraries-to-be-available-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!