简体   繁体   中英

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

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 ?

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>

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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