Play framework 2.0 unresolved dependencies - eclipse

I have created a scala project with play framework 2.0.
The project compiles and runs fine both with sbt and play commands.
However, the problems started when I tried to add another play project as a dependency to my project, because I needed to reuse some of its classes.
sbt compile succeeds, but play compile/run does not.
They give me the following error:
sbt.ResolveException: unresolved dependency: name_of_old_project_play_dependency: not found
I am also not able to run the project with sbt run; whenever I do a request to the play framework, I get a null pointer exception.
Is that because both the projects are play projects and maybe there is a conflict somewhere?
Any insight would be appreciated!

Please be sure to view the play version since sbt (the build system play uses) may have different versions.
Please verify the build.properties and plugins.sbt play version.
A technique I use to solve unresolved dependencies is to check the links that sbt tries to access.
I manually try to fetch the file by visiting the failed sites. I usually discover I have a version mishap.

Related

intellij/activator/sbt are downloading dependencies previously downloaded by the other

I'm not an expert with sbt so probably my question is a bit noob, but I've notice than when I create a project and download its dependencies with sbt, if I open the project with intellij, all the dependencies are redownloaded again, the same happen in the inverse orden intellij->sbt and also activator..
my (poor) knowledge about sbt is than this use ivy and the dependencies are downloaded in ~/.ivy2/ folder...that is where sbt is downloading my deps, but seems than intellij is using other folder.
personally I don't use so much activator, but I would like configure sbt and intellij for use the same ivy path...
2)recently I publish finagle-postgre to my local ivy using sbt +publishLocal, I can check in my ivy folder
/home/yo/.ivy2/local/com.twitter/finagle-postgres_2.11/0.1.0-SNAPSHOT
but unfortunately intellij is unable to resolve this dependency, I try adding this line to my build
resolvers += Resolver.file("Local", file( Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)
but seems not works
3) the path where is downloaded the dependencies is related to which sbt-launch.jar file is used? How can I know what sbt-lauch.jar file is using sbt right now...
thanks guys!
If we're talking about IntelliJ appearing to download artifacts after they've already been downloaded by SBT/Activator, then it turns out that it's probably just that IntelliJ is downloading the sources - it's not redownloading the binary artifacts, just the source artifacts that accompany them.
This isn't readily apparent when you're looking at the Refreshing SBT project task in the Background Tasks popup, because the full download path is truncated, so you see something like this:
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcompo...
..it's natural to assume that this is the same binary artifact you already saw SBT download on the console, but you can see the full story if you check the full log (go Help -> Show Log in files and open sbt.last.log in the file browser).
You'll see that the only artifacts getting downloaded end with -sources.jar:
$ grep repo1.maven.org /home/roberto/.IntelliJIdea2016.3/system/log/sbt.last.log
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.3.6/httpclient-4.3.6-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/com/googlecode/javaewah/JavaEWAH/0.7.9/JavaEWAH-0.7.9-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/org/pegdown/pegdown/1.2.1/pegdown-1.2.1-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3-sources.jar ...
```
If you don't have the Sources checkbox checked when you're doing Import project, these source downloads won't happen.
tested using IntelliJ 2016.3.5 and Scala plugin v2016.3.9
First, the activator is just a launcher for SBT itself, so there should be no difference in behaviour.
Second, IntelliJ also uses the files in ~/.ivy2 by default if you have not told it otherwise (by setting SBT_OPTS environment variable for example, but that depends on your IntelliJ version).
A difference might result if you're using different scala versions (e.g. 2.10.x vs. 2.11.x) when you do not have set the scalaVersion in your project explicitly. Then, each tool would download the corresponding libraries for the appropriate scala version it has configured by default.
Another thing is that IntelliJ will download source and javadoc jars for each dependency if you have enabled that in your settings which might look like it downloads the dependencies again.
Note, I'm wildly guessing here because you have not included any output of the programs you're using, so it's hard to say what the real problem is.

In an sbt 0.13.7 project, compile the compiler-interfaces without compiling the project code

In a freshly checked out sbt ( 0.3.7 ) project and empty ivy cache, is it possible to trigger compilation of the compiler-interface(s) needed without compiling the project itself? I have poked around but haven't found a way.
Currently if a compiler-interface is required it will be created during compilation of the project. I would like to have this compiled directly in a separate command if possible. This would allow CircleCi to cache it saving 1-3 minutes with every build because it could be cached in the dependencies section of the circle.yml.
In sbt 0.13.12 compile:compileIncremental seems to do the trick. I ran inspect compile and inspected its dependencies to find the command.

SBT Xsbt-web plugin not finding annotations

I have created an atmosphere framework application. When I use Xsbt container:start it does not scan the assembly and find the annotations on my classes.
However, when I package the project as a war and deploy to tomcat, it works perfectly.
It looks like there is a classpath issue but I am not sure how to start diagnosing this. I'm not finding much by googling or tinkering
If I manually copy the classes into webapp/WEB-INF/classes and the libs into webapp/lib/ then the application works, but the debugging for atmosphere does not.
I know that sbt is adding my dependencies in /home/me/.ivy2
I fixed my problem by telling sbt to output my class files to the web-inf directory where atmosphere requires them to be put:
classDirectory in Compile := file("src/main/webapp/WEB-INF/classes")

can't compile play showcase html

I installed playN however I get this error:
[INFO] --- gwt-maven-plugin:2.4.0:compile (default) # playn-showcase-html ---
[ERROR] Error: Could not find or load main class com.google.gwt.dev.Compiler
I checked the m2 repository, and the gwt jars for 2.4 2.5 gwt seem to be there.
If I try to use GWT 2.5 in the project then I get this
The GWT SDK 'C:\Users\user.m2\repository\com\google\gwt' on the project's build path is not valid (Version is not supported, must be 2.0.0 or later)
playn-showcase-html
Unknown Google Web Toolkit Problem
Does this make sense at all?
How to fix it?
Thanks
It seems that some gwt jars in the maven repository were corrupted. I deleted them, i run the playN sample again, the jars were downloaded correctly, and the whole think worked
C:\Users\user.m2 <-- this is very strange. it looks like somehow your maven repository path is munged up.
Check your environmental variables for MAVEN_REPOSITORY and see if its set to C:\Users\user. Also, find your maven installation directory, and look under the conf directory for a settings.xml, and see if you have <localRepository>${env.MAVEN_REPOSITORY}/.m2/repository</localRepository>.

How do I run a maven/eclipse/GWT/playN app in production mode?

There seems to be an issue if you want to launch a playN/GWT/maven app from eclipse in production mode using the following procedure:
Right click on playn-showcase-html and select Goolge-GWT Compile
Compiling module playn.showcase.Showcase
Resolving com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator
Found type 'com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator'
Found type 'javax.validation.constraints.DecimalMax'
[WARN] Detected warnings related to 'javax.validation.Constraint'. Is validation-<version>.jar on the classpath?
Specify -logLevel DEBUG to see all errors.
[WARN] Ignoring unresolvable annotation type javax.validation.Constraint
Compiling 1 permutation
Compiling permutation 0...
Compile of permutations succeeded
Linking into /Users/bryan/dev/playn-samples/showcase/html/target/playn-showcase-html-1.0-SNAPSHOT/showcase
Link succeeded
Compilation succeeded -- 19.459s
Anyone know what these warnings are about?
Right click on playn-showcase-html and select Run As web application
Go to URL http://127.0.0.1:8888/Showcase.html in your browser and you'll get an error that says GWT module 'showcase' may need to be (re)compiled.
The only way around this appears to be if you swap steps 1 & 2, but that just seems backwards. I think the problem is that the when you run the web app from eclipse that the gwt maven plugin is compiling/deploying the artifacts again which step on your previous GWT compile step.
Anyways, this isn't a huge deal since you can reverse the order of steps to get it to work, but I was just curious if anyone has found a solution to this.
I suggest that you try to compile/run it with maven directly, not through Eclipse, first go to the root directory of your game and do the following:
mvn clean package
that should compile your game without problems, and then
mvn test -Ptest-html
and that should run your game in http://localhost:8080/
Hope this helps, and I strongly suggest that use maven directly whenever you can, because Eclipse has a lot of incompatibility problems with some things.