Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my play framework build sometimes fetching oss-parent dependency?

I have an server that does automatic builds of a play framework 2.3.4 project and can successfully build my development branch. However when I build different branch, using the same script on the same server, I'm getting some strange behaviour.

The build for some reason fetches dependencies called [actual dependency]-parent, which doesn't happen on the other branch nor when I build the problematic branch on my local machine.

For example:

On my local:

[info] Resolving org.elasticsearch#elasticsearch;1.4.0 ...
[info] Resolving org.apache.lucene#lucene-core;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-analyzers-common;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-queries;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-memory;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-highlighter;4.10.2 ...
...

On CI build:

[info] Resolving org.elasticsearch#elasticsearch;1.4.0 ...
[info] Resolving org.sonatype.oss#oss-parent;7 ...
[info] Resolving org.apache.lucene#lucene-core;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-parent;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-solr-grandparent;4.10.2 ...
[info] Resolving org.apache#apache;13 ...
[info] Resolving org.apache.lucene#lucene-analyzers-common;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-parent;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-queries;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-parent;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-memory;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-parent;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-highlighter;4.10.2 ...
[info] Resolving org.apache.lucene#lucene-parent;4.10.2 ...
...

The dependency org.sonatype.oss#oss-parent;7 is completely new, in a working build there is no org.sonatype.oss dependency.

This is then followed by tests failing after not being able to start the fake application, which I assume is because of the bad dependencies.

Does anyone know what can cause this?

Here is what the resolvers in my build.sbt look like:

resolvers := Seq(
  "Sonatype repo" at "https://oss.sonatype.org/content/repositories/releases/",
  "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
  "Maven central repo" at "https://oss.sonatype.org/content/repositories/central/",
  "Maven central repo2" at "https://repo1.maven.org/maven2/",
  "Typesafe Repository" at "https://repo.typesafe.com/typesafe/releases/",
  Resolver.url("Objectify Play Repository", url("http://schaloner.github.io/releases/"))(Resolver.ivyStylePatterns),
  Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.io/snapshots/"))(Resolver.ivyStylePatterns),
  Resolver.url("Edulify Repository", url("http://edulify.github.io/modules/releases/"))(Resolver.ivyStylePatterns),
  Resolver.file("Local Repository", file(sys.env.get("PLAY_HOME").map(_ + "/repository/local").getOrElse("")))(Resolver.ivyStylePatterns),
  Resolver.mavenLocal
)

This morning, February 6th 2015, the two branches were merged so there are no differences. However one branch still builds but the other fails (on the same elastic instance). Each build has its own instance of activator and do not share repository folders, but the two repository folders are the same.

like image 895
Sindri Traustason Avatar asked Oct 20 '22 18:10

Sindri Traustason


1 Answers

The underlying cause is probably that the oss.sonatype.org repo was moved from http to https not long ago, so sbt is trying to fetch that dependency over https, getting a 301 redirect and bombing out on that. I suspect that the reason you don't see this on your local is that you have a cached version, possibly?

I think one of two approaches will help you get past it:

  1. If you have access to your CI server's maven repository, try copying in the correct dependency from your local maven repo (after deleting the current cached version, if any). This would typically be located in the home directory of whichever user is running the CI server or build process, in ~/.m2/repository/org/sonatype/oss/oss-parent/7

    I recommend deleting that entire directory (if there is one) and copying that entire directory from your local known-good copy.

  2. If that doesn't work or isn't possible, you might consider adding the correct https URL of the sonatype repo, which in sbt would look something like:

    resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
    

    in the appropriate part of your Build.scala... but you may still need to delete the directory of any corrupted cached version, if it exists and and persists across builds.

like image 177
Alex Nauda Avatar answered Oct 22 '22 07:10

Alex Nauda