问题
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