views:

400

answers:

2

At work I'm dipping my toes in managing project dependencies with maven. We use Apache Archiva (1.2.1) as a local repository and proxy. I'm adding artifact for open source project, that is not published on any public repository. I've learned that to publish the sources I should use the Classifier field on Upload artifact page. The sources are then listed alongside the jar and pom when I browse the repository.

But when I update my maven dependencies I get only the jar and pom from the repository. I noticed that sources are also missing when the archiva proxies for me the downloads from other public repositories. I didn't find any configuration options in Archiva's admin pages to serve the sources... What am I missing?

Update: I was missing the fact that artifact sources have to be downloaded manually. I.e. the maven client has to request them, which is controlled by command line option -DdownloadSources=true. Maven Integration for Eclipse has a preference setting to always download them as described in Resolving artifact sources. Archiva then serves the sources for local artifacts or proxies the request to remote repositories and caches the sources for future requests.

A: 

The sources aren't required to satisfy compile/runtime dependencies. If you wanted to bundle sources with your app, then you would specify a dependency with a source. Or you would use a plug in like assembly to grab them from archiva.

Cogsy
+2  A: 

Archiva does serve the sources, but Maven does not request them by default. I know since I also use Archiva as my Maven repo. How are you requesting the sources?

If you're using eclipse

Both of them should return the sources if they are available.

Robert Munteanu
I am using the Maven Integration for Eclipse. When it installed artifacts from public repositories, they were downloaded with sources. From Archiva they come without sources. It least that's who I blame based on my observation... Same results from command line.Does that mean I have to teach maven (in my settings.xml) to always request sources? How?
Palimondo
That's quite strange. Any error in the archiva.log file? What about requesting the source file manually - e.g. load in the browser $archiva/repo/internal/$groupId/$artifactId/$version/$artifactId-$version-sources.jar ? (Not 100% of path)
Robert Munteanu
Ahmm... I'm stupid. I did not realize, that I have to request the sources manually or change the preference in the preferences of Maven Integration for Eclipse. Then everything works. I was puzzled that some artifacts in my local repository included sources (for example junit, joda-time), without me ever specifying that manually. Maybe some archetype plugin did that for me...
Palimondo