Apache Archiva for maven pom project - maven

I've implemented Apache Archiva on my server and it runs on jetty (localhost:8888). I've adding my jar and now I've one internal repo (localhost:8888/repository/internal/). Well, now I need to integrate this repo into my project, and I've added it into repositories section of my pom.xml but I can't retrieve any of my loaded jar. I've reindexed external repositories into Maven Repositories view of eclipse and I've checked Enable Full Index for my repo and when I try to go into this repo, through this view, this location is empty. Any suggestions?

If you are using Latest version of Archiva You can add jars manually and it will show you all the added jar in Browse section.

Related

How to download selective dependencies using Maven from JFrog Artifactory?

I have a simple Maven project and its pom.xml has some dependencies to some local jar files inside the project structure. Now I want to upload those local jar files in JFrog Artifactory and change the pom in such a way so as to use selective dependencies from Artifactory and rest of the Pom files remains the same like it was(which includes some spring boot, Junit, surefire dependencies etc etc). How can I alter the pom file so that I can selectively download those jars from Artifactory rather than from my local machine.
I uploaded the local jars in a folder in Artifactory but unable to configure my pom/maven to download those during clean install. I tried as per the documentation in Jfrog to modify the settings.xml and include the server tag and aslo added distribution management in pom.xl to refer to the Jfrog Artifactory. But this is for all the dependencies no? I want selective dependencies to be downloaded from Artifactory.

To create a repository for 3rd party jars using Maven in Nexus

I am new to Maven.
I need to create a repository in Nexus for all 3rd party jars used in our project. These 3rd party jars should be pushed to Nexus repository from the maven repository.
When compiling the java code the 3rd party jars should be downloaded to the .m2 folder (local repository) and the code should be complied.
Could you share the sample pom.xml?
I think you are misunderstanding how things are working. Nexus can proxy the Central Repository and others. When configured correctly Maven will download all needed plugins and jar dependencies via Nexus into the local Maven repository and make them available on the classpath during the build as needed.
See more in the documentation. Esp check out the concepts and the Maven section:
http://books.sonatype.com/nexus-book/reference/concepts.html
http://books.sonatype.com/nexus-book/reference/config.html
You can also try it with the eval guide and the example projects.
http://books.sonatype.com/nexus-book/reference/eval.html

How to deploy JAR to Maven remote repository

Is there any way to put my JAR file in remote repository, so my maven project can get this JAR file from any place via Internet?
I have downloaded and did some fixes in the ReportNG project: https://github.com/dwdyer/reportng .
Using ANT I have compiled this project into JAR, now I want to put it into remote Maven repository, but don't know how I can do that.
Could somebody please suggest me the way, how I can perform that?
If it is a released version you want to make available in maven central follow this guide: http://maven.apache.org/guides/mini/guide-central-repository-upload.html
I'm no github professional but since a maven repo is just a file structure with some meta-data you can put it anywhere maven can read it (ftp, http, ...). so you could create a git repo to host your maven artifacts. see http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/ for an example. (it may be outdated - github may have something like maven repo hosting, I just dont know)
A lightweight way to create your own maven repository is to store it on github. See Hosting a Maven repository on github for more details
I followed sonatype open source project maven deployment guide https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide and successfully deployed the latest version of reportNG into maven central repository. Now maven have both 1.1.3 and 1.1.4
http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.uncommons%22%20AND%20a%3A%22reportng%22
You should do a pull request to the github project. If the maintainer likes your fix he will put it in the next version.
If you need your fix in a remote repo NOW then you'll have to setup your own maven repository.

Maven beginner question, get m2eclipse to download jar and add to build path?

From what I have read, after adding the relevant maven repositories, maven should automatically download the necessary jars to satisfy dependencies in the pom.xml file.
However, no jars ever get downloaded for me after I add dependencies in eclipse. Am I missing some glaringly obvious step?
I'd recommend to start from creating your project with m2eclipse. See more details in this article.
Basically, you need to make sure the following:
your Eclipse project has a valid pom.xml and all dependencies are available (you should see errors on Maven console, in the Problems or Markers view or when opening pom.xml in m2eclipse's POM editor)
Maven support is enabled for this project (you can use Maven / Enable Dependency Management from popup menu on that project)
project configuration is in sync with pom.xml (you can use Maven / Update Project Configuration from the project popup menu)
you can also use Maven / Update Dependencies to refresh your dependencies (e.g. when you got them in your Local Maven repo from the command line)
Dependencies jars aren't in your project but in your local maven repository.
These jars will be automatically used when you compile you project with maven (or m2eclipse).
If you don't have the needed jar yet, maven will download it for you.

Publishing artifacts with sources on archiva

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.
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
you can run mvn eclipse:eclipe -DdownloadSources=true in the project directory;
you can install the Maven Integration for Eclipse.
Both of them should return the sources if they are available.
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.

Resources