views:

22

answers:

2

I'm having some issues with a third party library that I'd like to step into. Netbeans provides a "Download Sources" option when the libraries node is right clicked. This downloads the sources from svn correctly, a source icon is attached to the dependency node, all is peachy. However, when I open one of the classes it gives me a generated skeleton just as it would if there was no source attached. Further more when there is a maven source present it seems there is no option to attach a local source manually so I can't work round this.

What are everyone else's experiences of this feature?

FYI the library in question is smack 3.1.0 http://www.igniterealtime.org/projects/smack/index.jsp

+2  A: 

Netbeans provides a "Download Sources" option when the libraries node is right clicked. This downloads the sources from svn correctly, a source icon is attached to the dependency node, all is peachy.

If we're talking about Maven here, I don't think that this is what is happening. The Download Sources feature tells Maven to download a sources artifact (e.g. foo-1.0-SNAPSHOT-sources.jar) for a given dependency from a Maven repository. And obviously, this only works if a given dependency is providing a -sources jar. But that's not the case of smack-3.1.0.

Pascal Thivent
Seems to be correct, The part that confused me is that the pom has a scm element which contains a svn repo. Netbeans also provides a check out sources option on individual dependencies so I thought it was the same mechanism for the download sources option.
Ollie Edwards
+2  A: 

As Pascal writes, the resolution of source artifacts happens via convention, so if the dependency is at:

<dependency>
    <groupId>com.yourcompany</groupId>
    <artifactId>yourartifact</artifactId>
    <version>1.2.3</version>
</dependency>

it will look for the source artifact at:

<dependency>
    <groupId>com.yourcompany</groupId>
    <artifactId>yourartifact</artifactId>
    <version>1.2.3</version>
    <classifier>sources</classifier>
</dependency>

So what you can do is download the source from the source download page, create a jar from it and run install:install-file as seen on the usage page:

mvn install:install-file -Dfile=your-created-source.jar \
                         -DgroupId=jivesoftware \
                         -DartifactId=smack \
                         -Dversion=3.1.0 \
                         -Dclassifier=sources \
                         -Dpackaging=jar \
                         -DgeneratePom=false

That way the convention will work and netbeans will find your sources automatically.

EDIT: added packaging

seanizer
+1 for providing a step by step practical workaround (and thus really answering the question)
Pascal Thivent
Did the trick, though I needed to add -Dpackaging=jar to get it to work. Thanks.
Ollie Edwards
thanks, I added that info now
seanizer