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

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.

Related

how to use mvnw command for first project setting

I am new to maven and have some basical questions.
When I see some projects, there is mvnw file included.
What I know is I dont need to install maven on my local if I use mvnw.
My question is:
what will happen when I firstly execute mvnw install?
maven with certain version is automatically installed on my local?
can I use like mvn compile instead of mvnw compile after executing mvnw install?
Thanks in advance.
what will happen when I firstly execute mvnw install? maven with certain version is automatically installed on my local?
The mvnw command will look for maven-wrapper.jar in the .mvn/wrapper directory. It will automatically download this jar file if it is not present there. We can consider this step as installing maven in the local machine just for this project. And the version of maven-wrapper.jar installed depends on the configuration in the mvnw command. On the other hand, if the maven-wrapper.jar is already present in the ./mvn/wrapper directory, the mvnw command simply uses it.
can I use like mvn compile instead of mvnw compile after executing mvnw install?
If you have maven installed in your local machine, you certainly can use mvn compile instead of mvnw compile, as long as the version of maven installed in the local machine is compatible with the project. However this can cause problems if the maven installed in the local machine is an older version and the project requires a newer version, or the the other way around.

How can I install older version (0.13.x) sbt on my MAC?

I need sbt version 0.13.x for a course in Scala and I am having difficulties installing it. I tried with the brew install sbt#0.13 command, but when I then check with sbt about it gives a message No such file or directory. 
However, if I again try and do brew install sbt#0.13, it gives Warning: sbt#0.13 0.13.16 is already installed, although sbt about does not find anything.
In addition to that, I tried installing the latest version of sbt with brew install sbt and then manually changing the version each of my projects is using by entering sbt.version=0.13.12 in a given build.properties file. This seemed to work initially, when I check with the terminal the version of sbt inside the project. However, I am still not able to import already existing projects.
Finally, I downloaded the version from http://www.scala-sbt.org/download.html but then I need to do some corrections to my PATH from what I've read online and I am not sure what that means.
So, I would be grateful if someone could help me with the installation of an older version.
The way sbt works is that it will look in project/build.properties for the sbt version to use to build your project. So the way you described - installing the latest sbt and set the version you want to use for the build in project/build.properties - should work just fine.
Regarding
not able to import already existing projects
these existing projects also should have project/build.properties indicating the sbt version.
Note that even with installing 0.13.12 locally, when building your project sbt will still use the version specified in project/build.properties, it will just download it as necessary.
If you absolutely want to run a specific version from the command line, as you already discovered, you can download it. Regarding updating your PATH - PATH is an environment variable that tells your command line where to look for executable files. It's a list of directories, so if you unpacked the downloaded file in say "$HOME/tools", you have so say something like export PATH=$HOME/tools/sbt/bin:$PATH. See https://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/ for a more detailed description.

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

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

Can't get plugins to install on my Hudson CI server

I'm trying to stand up a Hudson CI server.
I'm following an article written here.
I've gotten the server to stand up successfully by itself, but when I go to install the plugins all the plugins fail to install.
This happens the second time I run
java -DHUDSON_HOME=data -jar hudson.war
when I have all my plugins in the /plugins folder.
The errors I'm getting are
No 'Plugin-Class' entry in the manifest of ...msbuild.hpi
No 'Plugin-Class' entry in the manifest of ...nunit.hpi
Dependency analysis-core doens't exist (related to task.hpi)
I grabbed the latest stable release of them, so I'm thinking it has something to do with how I set up my hudson instance. The only different thing that I have done from the article is that I set up the installation in C:\Hudson.
Does anyone know why these plugins are all failing?
The problem was that for some reason I downloaded version 1.1 of hudson. I'm not sure how that happened since I clicked on the latest link, but I went back and downloaded the real latest version and the plugins are installing fine now.
The tasks plugin still doesn't install, but I don't really have to have that one, I was just curious what it was.

Resources