I'm new to Maven, but the big picture is that I need to download (in command line) the POM file of a certain artifact which is in a remote maven repository (Artifactory) using just it's artifact name and making it dynamically (by giving only the repository root path and the name of the artifact, so I can change it's location inside the repository and still download it).
My first question is: is that possible, or I have to detail the whole artifact path, groupId, artifactId and version?
Second point:
I managed to download the artifact using this maven command but it only gets the .jar, not the POM file:
mvn dependency:get -DrepoUrl=MY_REPO_LOC
-Dartifact=MY_ARTIFACT_LOC:MY_ARTIFACT_NAME:ARTIFACT_VERSION
Any idea on how can I do that?
First, you don't need maven for that. You choose a binary repository, which can give you the solution directly. Here's how:
Since you don't know the location of the artifact (I'd assume in terms of repository name? Because all the rest is pretty much locked by Maven and you do know all the path if you know the GAVC) and you don't want to list the groupId and version, you have to search and be prepared to receive multiple results, on which you'll have to imply some logic to determine which one you need.
Here's how you search in Artifactory from command line: http://wiki.jfrog.org/confluence/display/RTF/Artifactory%27s+REST+API#Artifactory%27sRESTAPI-SEARCHES
I'd recommend GAVC Search, since you know the artifactId.
If it's only the version which is unknown, and you just want to get the latest version, you can just use the latest artifact retrieval call or latest version search.
Related
Are https://mvnrepository.com/repos/central and http://central.maven.org/maven2/ the same maven repository (called Maven Central)?
Also there is https://repo.maven.apache.org/maven2/ which also calles itself a Central Repository.
I use mvnrepository.com as I find it more convenient, but many referencies to Maven Central in Internet lead to http://central.maven.org
Besides both sites above are for Maven2, right?
What are the analogues for Maven3?
Besides is Maven3 widely used?
As far as I know, mvnrepository is just a search site that is not maintained by the maven people directly. It's a search site as I see it. It has been around for a while. Since it contains multiple repository source to search in and lets you select which one you work with its pretty transparent and I don't see any harm there.
If you execute mvn help:effective-settings you should be able to determine what repositories are used, in case some changes where made. The current central default in maven seems to be https://repo.maven.apache.org/maven2/ - the official search interface being https://search.maven.org/
You can also look into the maven sources of the pom what config you running on.
The /maven2/ part in the Uri only means what repository format is used within. This has not changed for maven 3 (it was different for maven 1). So it's the correct and current one today, there is no maven 3 repository format. Everything new could be added to the maven 2 format (for example some search index files or checksum files).
I need a tool that will help to find all artifacts that reference another artifact.
When I rebuild an artifact, I need to update/rebuild all artifacts that were using the old version. But I work in a big organisation, and nobody knows really where the artifact is spread in the organisation, so nobody is ever completely sure that everybody use the latest versions.
What I need would be a tool - maybe an artifactory plugin or feature, or a maven plugin doing a lookup in the repository - that indexes all the known poms, and is able to make a listing of all artifacts that have the updated artifact in their dependencies, either directly and transitively. Thus a list of artifacts I would need to rebuild. Quite the opposite of dependency:tree.
Filtering that list by repository, groupId, packaging, etc. is a nice to have. But I can live without.
Any idea?
You can use the Artifactory Query Language with the REST API to do that. For example, if you want to find all builds that use "MySuperAwesomeDependency-1.0.2" your AQL statement would be something like:
//Find builds that use a dependency that is a snapshot
builds.find({"module.dependency.item.name":{"$match":"MySuperAwesomeDependency-1.0.2*"}})
The key in the above statement would be the module.dependency.item.name, which allows you to search for dependencies by name, assuming you store the dependencies in Artifactory.
i'm using Intellij IDEA 12.1.6, almost everyone in my company use Eclipse and dont notice my problem. We have a local nexus repository where we deploy artifacts, but some of them are systematically created with an invalid maven-metadata.xml (the latest snapshot timestamp and build number does not match the effective artifact name on repo) and intellij ends up telling me those libraries have broken classpath.
Is there a way to force intellij on hooking the maven jars on my local repository without worrying about those metadata additional information? Eg eclipse hook the jar in his classpath taking the version which does not include those data (in my m2 repo dir i see both 2 jars downloaded, the one with full data and the other one without them)
eg.
library-0.0.6-SNAPSHOT.jar
library-0.0.6-SNAPSHOT-20131028.111135-10.jar
Thank you for your help.
If Importing the eclipse project did not work. You should be able to Configure the library contents . The step for Configure Library Dialog should allow you to point the library to a different location.
I searched a lot in apache documentation and ibiblio.org and I could not find a decent straight answer.
My questions:
When I download a jar using maven dependency (setup in pom), how can I be sure that the file does not change on the remote repository? for example, if I'm using log4j version 1.2.3, downloaded from ibiblio.org (or any other repo for that matter), how can I be sure I'm getting the exact same jar each time?
Does maven delete jars from the local repository? let's assume I'm not clearing the repository at all, will it fill up eventually? or does maven have some kind of mechanism to clear old jars?
In Maven conventions a released version like log4j 1.2.3 will never be changed. It will be left in your locale repository until you manually delete it. It can't be changed by anyone except for the admins on maven central, but i suppose they don't do such a stupid thing.
Furthermore the download by default is done from maven central (repo1.maven.org/maven2 instead of ibiblio).
One of the "tricks" in Maven is download an artifact (released) only once...that improved your build performance in contradiction to the SNAPSHOT dependencies.
You could configure your own repository, and point all your project poms at that. It's easy to configure your poms to use a different (private) repository, but I've never set one up myself. Doesn't seem too hard, other than managing it to keep all the needed artifacts available.
I have a little problem that´s occurs in my computer, when I make deploy to artifactory, the name of the library changes as follows:
servico-disponibilizacao-2.0.0.0-20120117.194415-1.ear
In my project on Eclipse, I can see normally how this is:
servico-disponibilizacao-2.0.0.0-SNAPSHOT.ear
I really don´t know how to fix this, anyone have some ideia?
Thank´s so much for any help!
When publishing to a snapshot repository Maven will substitute the "SNAPSHOT" part of the revision with a timestamp, to create a unique version for that build.
See the Maven documentation on the distributionManagement section of your POM.
Additionally checkout this answer:
Maven Snapshot Repository vs Release Repository
Update
The Nexus book has a section describing the differences in artifact handling between snapshot and release repositories. I should think this information also applies to Artifactory, considering Nexus is the reference Maven repository manager.