How to export Maven dependencies or assembly artifact URLs - maven

I have a large maven project with several dependencies. There is also an assembly that contains all files I want to deploy - which is not necessarily identical to the dependencies.
My question: How can I generate a textfile that contains all URLs to JAR-files maven usually downloads the artifacts from? Ideally only from those files in the assembly, but of all dependencies would do as well.
[Update]
My project consists of a root project which has several artifacts from subprojects and external artifacts as dependencies. All dependencies are either stored in my private Artifactory repository or can at least accessed via it using Artifactory as a proxy.
When I roll out a new release, I want to be able that the root project writes all it dependencies in a file, suitable that a client can download those dependencies. The client has no idea about repository structures (I'd like to avoid that), so I need full URLs or at least full pathes within an repository root.

Related

Maven build using embedded JAR in project pom

I am working on a Maven project where a build is done through Jenkins, and 1 particular JAR has been removed from corporate repository recently.
So my build is failing as parent pom.xml is referring to a JAR not available in the repo.
But I have the old certified copy downloaded in my local repo, and I want to use the same JAR during build copying in the project folder and want to use the local copy of dependent JAR in pom.xml instead of downloading from corporate repository embedded in the project structure.
How can I do this?
Frankly, this does not sound like a good idea.
While it is possible to reference jars with the <systemPath> entry, it is generally considered bad practise.
By "corporate repository", do you mean a repository of your own company or of some other company? In the first case, you should request that the jar is put back in. In the second case, it would be better not to use the external corporate repository directly, but to set up your own Nexus/Artifactory through which you use (different) external repositories. This Nexus/Artifactory can then host additional artifacts like the one you need (you can e.g. upload them through the UI).

What should be stored in a maven repository?

Should I store artifacts that are final products, not to be used as a dependency of another project within a maven repository? i.e. EAR, WAR, zip, tar, etc.
I've been unable to find any documents that explicitly state whether this is the proper usage or not but I see that there are EAR/WAR/zip/tar files in Maven Central: http://search.maven.org/#search%7Cga%7C1%7Cp%3A%22war%22
Is anyone aware of any documentation to support either position?

Obtaining all parent poms in a repository

I have a huge local repository, which also contains unneeded jars (they are needed for other projects, but not for the task at hand). I've extracted the dependencies of my project using the maven dependency plugin and parsed that information into deploy commands in order to deploy those jars to another, remote repository. I couldn't have copied directly, because of access restrictions.
However, now compilation fails and I discovered that many of the issues I've already solved were due to the fact that the parent poms for some of the jars I was using were missing.
Is there a way to programmatically obtain all the parent poms of the dependencies of a certain project, similar to finding the dependencies themselves?
I would try parsing the directory tree directly and deploying every pom which doesn't have a jar counterpart, but I really hope there are better alternatives.

Find Maven repository where a dependency is stored

I'm working on a project with several corporate remote Maven repositories, each hosting many dozens of dependencies. The entire project uses hundreds of dependencies and I need a way to quickly determine which remote repository a dependency is stored on.
Does Maven provide an easy way to do this or do I need to search through each repository's dependency listing myself?
The project dependencies report has the information you want. You can quickly generate just this report using
mvn project-info-reports:dependencies
and open the target/site/dependencies.html file. Look at the last section in this report (dependency repository locations) for the info you want.
A sample of this report is here.

How to make my maven project depend on non maven projects?

I want to create a maven project, which has to depend on a non maven project which in turn depends on 2 other non maven projects. I do not have ownership of any of the other projects and it would not be possible for me to change anything in those projects let alone the structure to conform to the maven structure.
I asked if I could just get jars -- but was told that because of multiple levels of dependency, it would be "difficult" -- although I haven't understood why.
Is this possible or should I just abandon the use of maven to create my project and go with a regular project with jars in the lib folder?
Inxsible
If you can go with a regular project build that means you must have access to the other project's jar files?
It doesn't really matter how the other project builds them, you can still gain more control over your own build process by loading the jars you depend on into a Maven repository.
I'd suggest using one of the following repository managers:
Nexus
Artifactory
Archiva
They'll give you management screens to uploading 3rd party jars, they'll also a more efficient way to use other Maven repositories like Maven Central.
Once you've got your Maven build process working, you could encourage the other projects to automatically publish their versions into your Maven repo.
They could use the ANT tasks provided by the Maven or Apache ivy projects. Worst case you just continue to load their libraries until they see the light :-)

Resources