Maven dependency version, use one version or the other - maven

I am building a Dev version of my app that have multiple dependencies. All dependencies are set up as 1.0.0-SNAPSHOT.
However, as i build some of the dependencies, the version would be similar to “DEV-SNAPSHOT”. What I need is the ability to pass in that version(DEV) and have each dependency pull it if that version exist, otherwise pull 1.0.0-SNAPSHOT. Everything I have found gets me both of they both exist-I only want those that have a dev to pull dev and the others to pull 1.0.0.
Is that possible?
If exist version A:
Pull version A
Else:
Pull version B

Related

How can I ensure that newest version of Gradle resolve all dependencies

I need to update Gradle version in kotlin project. Have I any option to check if all dependencies support new version of Gradle or I need to check all dependencies release nots to make sure.
Actually for me it's not pretty clear how dependencies can't support new version of Gradle.
For instance:
Have I any option to check if all dependencies support new version of Gradle
There two sets of dependencies:
Application dependencies -- https://docs.gradle.org/current/userguide/declaring_dependencies.html
Applications dependencies have no correlation with Gradle whatsoever. These are dependencies needed to build your application and has no impact on Gradle's build environment.
Build dependencies
https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
https://docs.gradle.org/current/userguide/plugins.html
These dependencies, commonly Gradle plugins, do have an impact of your build. Whether or not a plugin supports a version of Gradle is only known by going to the source and checking release notes, if any. If it is not clear if a plugin supports a particular version of Gradle, then your only option is to upgrade your version of Gradle and see if anything breaks.

mvn clean install pulls in old snapshot version that don't exist

I am trying to compile my code and with the latest version. I see that the old SNAPSHOT version is being picked up as well when I check the .war file. I ran the dependency:tree and checked if it had anything to do with it but nothing came up which said so.
Is there a way I can change the pom.xml to ensure this doesn't happen.?
Run the build with -U and you get the newest SNAPSHOT versions.

Not seeing latest dependency version when I run versions:display-dependency-updates

I am trying to update dependencies in my java mvn project to latest version. When I run below command I see latest versions displayed, but I see different versions in central repository.
mvn versions:display-dependency-updates -DskipTests=true --update-snapshots install
For example, when I ran above command I got this for commons-collections
commons-collections:commons-collections ............ 3.2.1 -> 20040616
But when I browse it in the central repository - commons-collections:MVN Repo,
I see many updates after 20040616
Can someone clarify which is the latest version and MVN command to get the latest?
The display-dependency-updates command assumes that versions are numbered according to a very specific <Major>.<Minor>.<Incremental>-<Qualifier> structure, per the versions-maven-plugin Version Number Rules. It determines "newest" by sorting according to those criteria, and not via some sort of timestamp. When using dependencies that follow different rules, it's not likely to be able to tell you which version is actually newer. Sadly, this makes display-dependency-updates not nearly as useful as one might hope, but I still find it useful as a starting point to check and see what dependencies may need to be updated.
Unfortunately Maven does not know when the dependency was published, it just compares text.
In your case, the latest version of commons-collections:commons-collections is 3.2.1, but if you compare the text, 20040616 is bigger.
So basically 20040616 > 3.2.1 becuase it thinks 20040616 is a major version and it is bigger than 3.
Read more here: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN402
I generally use http://mvnrepository.com to find the latest version of an artifact, while you have used http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22commons-collections%22%20AND%20a%3A%22commons-collections%22. However, I see similar problems. 20040616 is not the date of the artifact, it is the version of the artifact. Since 20040616 is greater than 1, 2, 3, or 4, version 20040616 will always be viewed as the latest version. It would appear that this artifact should be removed from the repository since it does not obey the numbering rules. I have seen a few other problems like this in the repository, but I'm not sure who to contact to get it corrected.
http://www.mojohaus.org/versions-maven-plugin/display-dependency-updates-mojo.html
description of display-dependency-updates

How to install an updated version of a Dart package?

When a new Dart package is published, how can I install the updated version?
The DartEditor calls pub get automatically when the file pubspec.yaml is updated.
You may call it manually (e.g. when you for example checked out a project from GitHub without modifying any file)
by using the context menu Pub Get in DartEditor on the file pubspec.yaml
by calling pub get on the command line in the package directory where the file pubspec.yaml is stored.
pub get downloads the package version noted in the file pubspec.lock (in the package root directory) or the most recent version that fulfills your version constraint (0.0.1 in your example could be any for 'most recent') if pubspec.lock doesn't exist. pub get/pub upgrade create the file pubspec.lock if it doesn't yet exist and save the versions of the downloaded packages it just downloaded.
Check for updated packages and download them using
context menu Pub Upgrade in DartEditor on the file pubspec.yaml
pub upgrade on the command line in the package directory where the file pubspec.yaml is stored.
pub upgrade downloads the most recent version that fulfills your version constraints and stores the downloaded version in the file pubspec.lock.
pub get/pub upgrade prefers stable releases (version numbers that don't contain a -) like 0.0.1 or 1.2.0+1 over pre-releases like 0.0.2-1 or 1.2.1-1 if any is available that fulfulls your version constraint.
If you want a pre-release you have to tighten the version constraint so that only the pre-release fulfills your constraints (like angular: '>=1.2.1')
pub upgrade may show an output like
analyzer 0.10.5 (9 newer versions available)
Which indicates that there are 9 prerelease builds available that are newer than the downloaded stable build.
The version constraint for your dependency needs to fulfill the version constraints of all your dependencies dependencies (E.g. if you add the dependencies observe and polymer where polymer depends on observe itself).
You can force pub get/pub upgrade to a version that violates your dependencies dependency by defining the dependency with a version constraint under dependencies_override: instead of dependencies: in pubspec.yaml.
You may also add dev_dependencies (e.g. unittest) which are only downloaded when they are defined in your package but ignored when they are only defined in one of your dependencies.
You see, this is an advanced topic even for seasoned Dart developers.
If you are a seasoned Dartisan, this question might seem so trivial to not be worth asking, but coming from a Java world (where my students and I are used to downloading .jars manually and then (sometimes) having to copy them over into our projects) it is a greenhorn question that is natural to ask. Here is the context: two days ago v0.9.5 of angular came out and so I made a mental note to upload the libraries in our local projects.
Well, it seems that all we need is an appropriately defined pubspec.yaml file, and the Dart pub package manager does the rest. In the Dart Editor, I guess that dependencies get updated on a project refresh or when it is (re-)built. In our projects we happened to have, e.g., a pubspec.yaml file like this:
name: angular_dart_demo
version: 0.0.1
dependencies:
angular: any
(as opposed to, say, angular: ">=0.9.0 <0.10.0") which allowed the Pub manager to go fetch the latest angular. Effortless. Nice.

Maven archetype fetching old version

I am generating a maven project using an archetype that I've uploaded to the central repository.
mvn archetype:generate \
-DarchetypeGroupId=org.opencoweb \
-DarchetypeArtifactId=coweb-archetype
The latest version is 0.8.3.1, but the version I get instead is 0.8.3. I have cleared out my cache ~/.m2, and running the above command stil downloads 0.8.3 instead of the latest version. Does anyone know why? Did I forget to specify something when I uploaded/created the 0.8.3.1 module? I uploaded the module earlier this month (Oct 3), and according to http://search.maven.org/remotecontent?filepath=org/opencoweb/coweb-archetype/maven-metadata.xml, the "latest version" is 0.8.3.1.
Edit:
I can download the latest 0.8.3.1 version, but only if I specify -DarchetypeVersion=0.8.3.1. However, this is clearly undesirable.
check this answer. maybe the Latest-part is helpful for your needs.
https://stackoverflow.com/a/13058666/1602465

Resources