Search code examples
jarplayframeworkclassloader

Play!: Use different version of jar than local repository


Play! framework comes with tons of jar libraries. I am using version 1.7 of apache commons-codec for my Play! application. But Play! is already shipped with version 1.4 and some other older versions. I have placed my commons-codec-1.7.jar in the lib folder, and 'eclipsified' so the jar file is in the class path. But when I expand the Project Explorer in Eclipse I see that both version 1.7 and 1.4 are referenced by the application. My questions are

  1. How do I remove version 1.4 from being referenced?
  2. Why did the app choose version 1.4 even though version 1.3 and 1.2 are present in the [PLAY_HOME]/repository/local
  3. It is a collaborative project. I want to make sure that once I push the code in git and my colleagues pull it, they need not to do the same 'hack', just 'clean' and 'compile'. How can it be done?

BTW, I am using Play! 2.0.4


Solution

  • Add commons-codec to your Build.scala and you'll be fine. The dependencies will be correct since the specified dependency will override the ones that are default.

    val appDependencies = Seq(
      "commons-codec" % "commons-codec" % "1.7"
    )
    
    1. You don't have to remove version 1.4. Version 1.7 will be in effect now.
    2. That is caused by the order they are presented in the classpath.
    3. play compile will do it. And you'll have to eclipsify the project again.

    Don't forget to remove the commons-codec from the lib folder. As said it will be downloaded and put in the classpath automatically.