pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Build against 2.11 #46

Closed kenbot closed 10 years ago

kenbot commented 10 years ago

One of our teams is using 2.11 and it would be super peachy if we had a pact-jvm build against it :)

uglyog commented 10 years ago

So we have to produce a different set of artifacts. Is that easy to do with SBT?

kenbot commented 10 years ago

Should be. There's some sort of command to do cross builds; can't remember what it is off the top of my head. There may be source changes required though; I can't be sure. In that case a branch would be needed. :(

uglyog commented 10 years ago

Cross builds seem easy enough: http://www.scala-sbt.org/release/docs/Cross-Build.html

uglyog commented 10 years ago

It is also easy to do with gradle as well, so it should not be a big problem. I'll try set it up this weekend.

CaseyLeask commented 10 years ago

@uglyog Thanks for the link! @carolliu and I will take a look, but we are complete Scala novices.

kenbot commented 10 years ago

I'll review if you like :)

On 16 July 2014 16:38, Casey Leask notifications@github.com wrote:

@uglyog https://github.com/uglyog Thanks for the link! @carolliu https://github.com/carolliu and I will take a look, but we are complete Scala novices.

— Reply to this email directly or view it on GitHub https://github.com/DiUS/pact-jvm/issues/46#issuecomment-49128860.

CaseyLeask commented 10 years ago

Here's how far we got #47

uglyog commented 10 years ago

travis ci build was green, so i merged the pull request

uglyog commented 10 years ago

Looks like the SBT modules have to be compiled against the version of Scala that SBT is compiled against, which is 2.10. I'm trying to force those modules to always use 2.10, but I'm not having much luck.

Another option would be to exclude them if the version is 2.11, but I'm not sure how to do that. Maybe a filter after the aggregate in the build.sbt?

I'm also going to try setup a gradle cross build, because that will be easy to exclude those two modules when compiling with 2.11 with gradle.

uglyog commented 10 years ago

I've managed to get gradle to cross compile. if you want to use it to build the 2.11 versions, I've setup some aggregate tasks. You can run

$ ./gradlew build_2_11

to build all the 2.11 artifacts, and

$ ./gradlew install_2_11

to install them into your local maven repo.

uglyog commented 10 years ago

I have published all the artifacts to maven central using gradle. Both 2.10 and 2.11 versions should be available (except the SBT plugins, they're only built against 2.10)

thetrav commented 10 years ago

Do we really need to maintain two different build tools?
I would have expected sbt to satisfy anything you'd need to use gradle for

CaseyLeask commented 10 years ago

@uglyog Thanks Ronald! That's some amazingly quick work! I'm learning a lot by just reading the commits you made :+1:

uglyog commented 10 years ago

@CaseyLeask No worries, glad to help

uglyog commented 10 years ago

@thetrav Sadly sbt being able to satisfy anything you'd need to use gradle for is not true. We've had some issues with it.

  1. sbt can only build java and scala modules. This seems to be by design.
  2. we could not get it working behind a corporate proxy
  3. I could not get it to not cross-compile the SBT modules (this is more a problem with me using it)

So it's more of a case that gradle can do anything sbt can, plus more

ShaneDelmore commented 10 years ago

Given that the SBT plugins are only build against 2.10 is there any way to get this working with Scala 2.11 and SBT?

bethesque commented 10 years ago

I'd really like to get the scala mock server to be runnable from a jar, for people who have java installed (most people) but who wouldn't install sbt/scala on top of all their other project dependencies just to run pact (again, most people). How much work would that be?

uglyog commented 10 years ago

@ShaneDelmore The SBT plugins are built against the version of Scala that SBT is built against (2.10 for SBT 0.13). They should work with a project using Scala 2.11, but I have not tried this.

@CaseyLeask is using 2.11, so I'll try find out how it's working for them.

uglyog commented 10 years ago

@bethesque there is the pact-jvm-server which is a standalone mock server. I'll update the docs on running it standalone.

Or where you thinking of something else?

bethesque commented 10 years ago

Can you run it from a jar? With no sbt?

On Saturday, August 16, 2014, Ronald Holshausen notifications@github.com wrote:

@bethesque https://github.com/bethesque there is the pact-jvm-server which is a standalone mock server. I'll update the docs on running it standalone.

Or where you thinking of something else?

— Reply to this email directly or view it on GitHub https://github.com/DiUS/pact-jvm/issues/46#issuecomment-52374544.

ShaneDelmore commented 10 years ago

@uglyog I downgraded my project to 2.10 for now. Still trying to get my first test working but once I have something I will convert my project back to 2.11 and verify it still works. I do not know that there actually was any problem with 2.11, it may have just been a mistake on my end related to https://github.com/DiUS/pact-jvm/issues/50 which you have already resolved.

uglyog commented 10 years ago

@bethesque Yes you can, I tested it. But you need all jars it depends on for it to work. I updated the readme on how you can do it with gradle.

ShaneDelmore commented 10 years ago

I just verified 2.11 works fine with sbt now that @uglyog published 2.0.3.