wingnut
wingnut

Reputation: 1193

How to get eclipse+maven to find and use servlet api source code or javadoc

Recently, I downloaded the latest elcipse with everything in it, and added the sonatype maven plugin.

We setup a number of servlet projects using the mavel eclipse plugin web archtypes to generate the poms etc.

It adds:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.4</version>
  <scope>provided</scope>
</dependency>    
<dependency>

However, it doesnt include the source or javadocs, so developing with this is a lot of groping in the dark and constant hunting of javadoc web pages.

I have scoured the maven website http://maven.apache.org/, but cant find how to get it to include the source or javadoc as well as the actual dependant jar.

I saw this article, but it doesnt have a solution:

How to add Javadoc for Servlet API in Eclipse

And this tip: http://tedwise.com/2010/01/27/maven-micro-tip-get-sources-and-javadocs/ but last time I used a mvn command outside of eclilpse, it destroyed the whole eclipse environment and I spent 2 days rebuiling it from scratch (now I know not to do that).

Or do i have to manually add a jar of the source which exactly matches the java jar to ecilpse as source in the java build path? (i.e. not use maven). I found a copy of the source here: http://mirrors.ibiblio.org/pub/mirrors/maven2/javax/servlet/servlet-api/2.4/

Upvotes: 1

Views: 3066

Answers (1)

Ali Shakiba
Ali Shakiba

Reputation: 21257

Have you tried adding classifier inside dependency tags:

<classifier>sources</classifier>

OR changing Eclipse preferences:

Eclipse > (Toolbar) > Window > Preferences > Maven:
Download Artifact JavaDoc
Download Artifact Source

(And then touch your pom file in Eclipse to make new Maven build.)

Edit: source in classifier tag corrected to sources

Upvotes: 3

Related Questions