Reputation: 2098
I have a play project, composed of sub projects, that I use on Heroku. I am using Play 2.3 with Scala 2.11.4
Goal
Approach
My approach has been to 'publish' the project jars to Maven and then ship a project that just uses the published artifacts. This works on my machine, but when I deploy it to Heroku it fails to compile: it cannot find the 'controllers.ReverseXXX'.
My actual application is now thousands of files, but I have managed to recreate the problem with a much smaller project available on github. I am deploying to a local self contained maven repository to ease duplication of this problem. The two projects required to recreate the issue are https://github.com/stave-escura/mainChildPlayApp and https://github.com/stave-escura/deploy
Steps to reproduce the problem
git clone https://github.com/stave-escura/mainChildPlayApp.git
cd mainChildPlayApp
git clone https://github.com/stave-escura/deploy.git
sbt
>publish
>run
{At this point if you go to localhost:9000 you should see Main Hello world and localhost:9000/child should produce Child Hello World}
{terminate the run with Ctrl-d}
exit
cd deploy
sbt
>run
{At this point if you go to localhost:9000 you should see Main Hello world and localhost:9000/child should produce Child Hello World}
{terminate the run with Ctrl-d}
>exit
heroku git:remote -a <put in here the git repository details for your heroku app>
git add --all :/
git commit -m "Initial Commit"
git push --force heroku master
Even though the project worked locally (checked by the runs) it fails on Heroku with messages like
[error] /tmp/scala_buildpack_build_dir/target/scala-2.11/src_managed/main/controllers/routes.java:16: error: package controllers.ref does not exist
[error] public static final controllers.ref.ReverseApplication Application = new controllers.ref.ReverseApplication();
Summary of what is going on:
My project directory is
Project
app
...
conf
...
public
...
deploy
modules
child
conf
public
main
conf
public
During the publish I have made an SBT plugin to copy the conf and public directories to deploy (merging them), and I publish the maven artifacts to a sub directory under deploy as well. Thus the deploy structure after the publish becomes
Project
...
Deploy
Conf
Public
Maven
My sbt in the deploy directory looks like this
organization := "org.myorg"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.4"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Local" at new File("maven").toURI.toURL+"snapshots"
libraryDependencies += "org.myorg" %% "proj" % "1.0-SNAPSHOT"
lazy val deployedWebsite = (project in file(".")).enablePlugins(PlayScala)
It is the git repository in the deploy directory that is sent to Heroku.
Disclaimer
I've managed to duplicate the error on my machine following these instructions. If they don't work for you (either instructions are wrong, or you get a different result) please let me know. It's complicated reporting issues like this!
Upvotes: 0
Views: 283
Reputation: 10318
The best solution for this is the sbt-heroku plugin. It is support by Heroku. It does not handle sub projects well yet, but there is and open issue for sub project that will hopefully be fixed soon.
Upvotes: 1