Results 1 to 5 of 5
  1. #1
    targeteco is offline Member
    Join Date
    Jan 2015
    Posts
    3
    Rep Power
    0

    Default Force latest dependencies and plugins

    I have, just recently, started with Maven. Watched a couple of tutorials and read a book on it. I have one question and would greatly appreciate your response.

    On the latest Maven, 3.2.5, I created a project using the "mvn archetype:generate" command and archetype="maven-archetype-quickstart". It created the project, however, by default, it adds version 3.8.1 of junit while the latest release version of 4.12 is available in the central repository. Similarly, it seems to pick up older versions of other dependencies and plug-ins that it adds, by default. I noticed, e.g., from the Effective POM that it picks up older versions of even "maven-compiler-plugin".

    Though, I can, manually, edit the POM file to change the versions of plugins and dependencies, however, for every new project, Maven seem to go back to older versions.

    1) What do I need to do in order to ask Maven to always pick up the latest release versions of all the dependencies and plugins from the central/local repository?

    2) The second part of this question, I guess, is-Suppose, if I have an existing Maven project that has been there for some time now. Now, I wish to upgrade the dependencies/plug-ins to the latest versions for testing purposes before releasing a new version of this project. Given, that maven maintains the dependencies/plugins and their versions, is there an easy way to ask Maven to upgrade the project to the latest release versions of all the dependencies/plugins?

    Thanks very much.

    PS: I have Java 8 JDK and JRE installed on this machine.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Force latest dependencies and plugins

    1) that is automated chaos, you don't want updates to dependencies to mysteriously slip into your project from one day to the next and thus introduce possible regression bugs - all without you even seeing it happen. I can already see your next question: "my application worked just fine yesterday and it doesn't work today, what is wrong with Java? I'm in panic mode because I need this application deployed yesterday and my boss is breathing down my neck!"

    Rather than wanting Maven to do all the work for you, look for ways to make it easier for you to manage it yourself. I put all the versions at the top of the parent pom in properties myself to make them easily manageable.

    Java Code:
        <properties>
            <richfaces.version>3.3.3.Final</richfaces.version>
        </properties>
    
        ...
    
        <dependency>
           <groupId>org.richfaces.framework</groupId>
           <artifactId>richfaces-api</artifactId>
           <version>${richfaces.version}</version>
        </dependency>
    If you must go for automated chaos then Maven does support dependency version ranges: Maven: The Complete Reference - 3.4.*Project Dependencies - Sonatype.com

    2) exactly the same question as 1) only worded differently
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    targeteco is offline Member
    Join Date
    Jan 2015
    Posts
    3
    Rep Power
    0

    Default Re: Force latest dependencies and plugins

    I am sorry, if my intent didn't come out, clearly. Please allow me explain again. I didn't mean to have a background service that would update your dependencies/plugin silently. Of course, for someone who been programming for more than a decade would know that is not a good idea. My problem is, if I may rephrase is, by default, for a NEW PROJECT, Maven picks up OLD dependencies, when generally, there is little reason to start with old dependencies/plugins on a new project. Eg. If I am starting with a brand new project in Java SE, am I more likely to use JDK 6 or JDK 8?

    The latest version, 3.2.5 of Maven, still seems to prefer JDK 6, which is very old given JDK 8 has been out already and in practice people are using it.
    http://maven.apache.org/docs/history.html

    Another way to explain is, like Windows informs you of newer updates through Automatic updates. However, it doesn't silently updates the Windows or doesn't migrates to newer Windows, by default. It gives you a choice.
    It would be wonderful to have an OPTION to say, for all the NEW projects, since Maven is managing dependencies, start with the latest release versions. An Option. if you want to start with older dependencies, then your choice.

    If buying a new Mobile phone, would you choose Android 5 - Lollipop or Android Gingerbread 2.3? That, probably, summarises my situation better.


    2) For my second question, again, let's say you start with the latest and the greatest versions of plugins today. After sometimes, BEFORE releasing a new version of your project, it could be a good idea to TEST how it behaves on the newer versions of dependencies/plugins. Now, I can manually search for new versions and update to their latest versions, but, that kind of defeats the purpose of dependency management. So, WHEN I am ready to TEST the new dependencies/plugin, I click on a button that tells Maven to go and fetch the latest versions of plugins etc. so that I could TEST my project on the new versions and release it after a successful regression and integration testing.

    Not sure, if I was able to convey the message better this time?

    PS: the version isn't deterministic. I would like to start with a specific version, usually the latest.
    Last edited by targeteco; 01-28-2015 at 04:33 PM.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Force latest dependencies and plugins

    Yes for a new project you create fresh poms and you revise all versions used. There is no problem to solve.

    Your only problem is that you lazily use archetypes to make maven do all the work for you - always a recipe for things automatically going wrong. But if you take my suggestion and make a pom easier to manage by hand, you can adopt the poms from a previous project and easily manage the versions. Including for a next snapshot version.

    Maven does NOT manage dependencies. You do. Maven only manages the downloading and packaging of the dependencies that you choose, as well as automatically pull in transitive dependencies. Stop trying to make Maven do your job.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    targeteco is offline Member
    Join Date
    Jan 2015
    Posts
    3
    Rep Power
    0

    Default Re: Force latest dependencies and plugins

    @gimbal2, Thanks for the suggestions and help, which might suit your needs very well, however, one size doesn't always fit all.

    I will wait for another response, who might see that no two projects/teams/companies are a replica of another and requirements might be different.


    PS: It doesn't hurt to be nice to others and usually, there is no bill at the end for being a nice human being.

Similar Threads

  1. ConvexHull by brute force
    By blaqkout in forum New To Java
    Replies: 0
    Last Post: 10-03-2011, 04:49 AM
  2. Force Graphics Sync (?)
    By Acidic in forum Java 2D
    Replies: 5
    Last Post: 04-18-2011, 03:07 AM
  3. How to force applet to use libraries?
    By Arvutis6ber in forum Java Applets
    Replies: 1
    Last Post: 09-20-2010, 02:24 PM
  4. Howto force to use an external jar
    By riccardo_b in forum Eclipse
    Replies: 0
    Last Post: 12-11-2008, 10:08 AM
  5. Force Caps in JTable...
    By markw8500 in forum Advanced Java
    Replies: 0
    Last Post: 07-09-2008, 02:27 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •