Set version aliases in nexus maven repository - maven-2

I have own maven2 repository in nexus, for publishing build artifacts.
I'm using maven deploy plugin for uploading artifacts there
Is it possible somehow to add custom aliases(links) to versions inside my repo, so project/script/whatever will use artifacts from repository, can refer to some static version-name(e.g. stable,earlier,development)
And during each publishing of new version to repo, I will update those aliases.

No, there's no version aliasing in maven. However, you can use version range for your dependency or use profiles to specify different versions for your builds.
Have a look at this question, so you get the idea what is possible: How do I tell Maven to use the latest version of a dependency?

Related

Gradle distributions repository in artifactory outdated?

I set up my virtual repository in artifactory to cache gradle distribution libraries by adding a remote repository called 'gradle-distributions' as described here. This remote repository points to this repository
As it looks like, the stated remote repository is not up to date any more because the latest version offered is gradle-1.0-milestone-8-bin.zip.
Is there a workaround for this issue, like pointing to a different remote repository or whatsoever?
Thanks in advance.
Gradleware now distributes Gradle from http://services.gradle.org/distributions/
But I am not sure that's what you are looking for. If you need some Gradle modules to depend on (like the api), you should use gradleApi() dependency, as described here.
If you're looking for other dependencies, you can configure your Gradle to use standard Artifactory remote repositories like lib-releases and make sure that Bintray's JCenter is configured as a remote repository and included in remote-repos virtual repository.
Gradle has moved the repository to http://services.gradle.org/distributions/

Maven: trigger task to upload dependency into Nexus if dependency is not there at the build time

I have Maven2 project. This project have 1 internal dependency which stored in internal (for our company) Sonatype Nexus. I setup the dependency version in pom.xml as parameter which I provide via Jenkins.
Sometimes I do not have proper dependency version in Nexus so my build can fail on donwload dependency step. I want to add ability to trigger special task (script) if dependency is not found to upload this dependency into Nexus and continue the build.
Can I do so?
I think about fake build for version exists always in Nexus which will check if given version is in Nexus, upload it and launch real build. But such way looks terrible.
Thanks In Advance!
You do NOT need to upload anything. You just need to access Nexus via the public group and the download from the Central repository, that is part of that group will happen automatically.

Purpose of internal archiva "snapshot" repository?

I get what internal libraries are. But what is the purpose of a snapshot repository in archiva?
Libraries - private releases
Snapshots - private builds?
I have archiva set up and working with LDAP, but I am wondering why I need a snapshot repository. What purpose does this solve? Why is this used in development?
Also, lets say I update a library in the internal repo. Does this automatically update in the project POM files which use Maven, or I must update those poms to use the new JAR version?
Usually before releasing a maven project, the version is -SNAPSHOT.
So with such repositories you can share fresh SNAPHOT of your project for other people in your team to test or with a ci server.
Snapshots is maven idea to give version number as -SNAPSHOT , its under development it can be change any time.
Internal repository is the release repository with fixed version number. You can modify the SNAPSHOT, but That artifact never changes after it is released.
When we use internal, if dependency does not found inside it, then it will download it from central repository of maven. where as in snapshot it does not.

Local repository use

While building Maven projects (Spring and jbpm 4.4 to be specific),
I see that the libraries that I already have in Maven local repository, gets downloaded again or the console log suggests so.
Say my local repo already have the commons-collection3.1 in my library, is it necessary to download from the maven repository?
Is there a setting that can let maven know to look in the local repo first?
Thanks,
Ayusman
You might have the updatePolicy for SNAPSHOT repository set to always in your settings.xml. See this guide to settings.xml.
Maven will look in the local repository first by default.
Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository.
http://maven.apache.org/guides/introduction/introduction-to-repositories.html

How to find the artifacts that depend on another artifact?

We are using Maven to build our projects and Nexus as repository manager.
Is there a way to know where an artifact is a dependency of another artifact?
For example, we want to know which of the artifacts in our Release repository have a dependency on commons-io 1.2, or version x.y of our framework2, or ...
mvn dependency:tree should help you get this info.
Have you looked at the Maven Site plugin in conjunction with the dependencies and dependencies-convergence report from the Maven Project Info Reports plugin?
This will generate an html report that shows all the artifacts that the project uses and what other artifacts that are dependent on that artifact.
The Maven client will only tell you the dependencies of a single project. I'd recommend using Sonar as part of your build process. It's primarily used for source code analysis, but it will also report usage of a particular library by other projects in the same Sonar database.