I am trying to learn Scala by implementing a simple API in Play framework. I am creating an app by command
activator new app play-scala
Then in app folder I'm doing activator run then it starts downloading tons of data from internet. I tried offline:=true in build.sbt and using the offline version activator instead of minimal one but with no success.
[info] Loading project definition from /home/amit/Codes/scala/app/project
[info] Updating {file:/home/amit/Codes/scala/app/project/}app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to app (in build file:/home/amit/Codes/scala/app/)
[info] Updating {file:/home/amit/Codes/scala/app/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-omnidoc_2.11/2.5.3/play-omnidoc_2.11-2.5.3.jar ...
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbtrc/client-2-11/0.3.1/jars/client-2-11.jar ...
[info] [SUCCESSFUL ] com.typesafe.sbtrc#client-2-11;0.3.1!client-2-11.jar (102499ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.11.5/scala-reflect-2.11.5.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.11.5!scala-reflect.jar (136599ms)
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/serialization_2.11/0.1.0/jars/serialization_2.11.jar ...
[info] [SUCCESSFUL ] org.scala-sbt#serialization_2.11;0.1.0!serialization_2.11.jar (12655ms)
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/io_2.11/0.13.8-M3/jars/io_2.11.jar ...
I have a very slow connection and I am stuck with it. I don't know something that easy in python-flask can be so difficult in scala-play or am I missing something?
By issuing activator new app play-scala activator only creates a copy of template (usually located at ~/.activator//templates). Of course template itself has to be downloaded first but it is normally tiny.
Effect what you are seeing is that when you run activator run the SBT first time resolves dependencies of your application created according to template. Two situations can happen:
you have already a lot of dependencies in your ~/.ivy2 directory because e.g. you have created project according to the template before or project with similar dependencies via SBT (not strictly with activator). Then the dependencies will be resolved and not downloaded.
you have no dependencies at all in ~/.ivy2 or your template uses such different ones that they have to be downloaded.
Your milage may vary, but important point is that your dependencies are related to your template not activator itself. Another important thing to note is that they have to be definitely downloaded at least once to be used (this is strongly dependent from state of your ~/.ivy2 directory).
I guess that you are trying activator for the first time, or at least play-scala template, thus you have to wait and definitely use better internet connection :)
Related
I'm new to sbt. I'd like to know how to get dependent jar files by Scala code, not executing sbt plugin.
In Gradle, it supports to get dependent jar files by Java code like the following (project is an instance of Project class):
Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration();
Set<File> jars = config.resolve();
I'd like to know a way to do like that in sbt and Scala. Does anyone know this? I tried to use sbt.Project#dependencies, but it seems that one doesn't meet for this purpose.
You are looking for dependencyClasspathAsJars:
sbt > inspect dependencyClasspathAsJars
[info] Task: scala.collection.Seq[sbt.internal.util.Attributed[java.io.File]]
[info] Description:
[info] The classpath consisting of internal and external, managed and unmanaged dependencies, all as JARs.
[info] Provided by:
[info] ProjectRef(uri("file:/home/claudio/foo"), "foo") / Compile / dependencyClasspathAsJars
[info] Defined at:
[info] (sbt.Classpaths.classpaths) Defaults.scala:1800
[info] Dependencies:
...
As you can see, this is a Task that returns a scala.collection.Seq[sbt.internal.util.Attributed[java.io.File]] where Attributed is just a simple wrapper around arbitrary data: https://www.scala-sbt.org/1.x/api/sbt/internal/util/Attributed.html
sbt > show dependencyClasspathAsJars
[info] List(Attributed(/home/claudio/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.13.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/twirl-api_2.13/jars/twirl-api_2.13-1.5.0.jar),
Attributed(/home/claudio/.ivy2/cache/org.scala-lang.modules/scala-xml_2.13/bundles/scala-xml_2.13-1.2.0.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play-server_2.13/jars/play-server_2.13-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play_2.13/jars/play_2.13-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/build-link/jars/build-link-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play-exceptions/jars/play-exceptions-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play-streams_2.13/jars/play-streams_2.13-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/org.reactivestreams/reactive-streams/jars/reactive-streams-1.0.3.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.akka/akka-stream_2.13/jars/akka-stream_2.13-2.6.3.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.akka/akka-actor_2.13/jars/akka-actor_2.13-2.6.3.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe/config/bundles/config-1.4.0.jar)
...)
If you want to process the value in any way, you probably want to write a custom task: https://www.scala-sbt.org/1.x/docs/Tasks.html
I have imported the Twitter Cassovary into Eclipse form Git Hub but not sure how to run the examples.Please advise as I am new to eclipse as well as scala
I imported the project, opened a benchmark (cassovary-benchmarks/src/main/java/GraphGenerationBenchmarks) and used Run as->Scala application.
You can also do this from the command line. Start sbt in the main project directory, choose subproject cassovary-benchmarks and then use run. You will be asked which benchmark to run.
➜ twitter-cassovary git:(master) ✗ ls
README.md cassovary-examples project
cassovary-benchmarks cassovary-server sbt
cassovary-core lib_managed target
➜ twitter-cassovary git:(master) ✗ sbt
Loading /Users/szymon/bin/sbt-launch-lib.bash
[info] Loading global plugins from /Users/szymonmatejczyk/.sbt/0.13/plugins
[info] Loading project definition from /Users/szymon/oss/twitter-cassovary/project
[info] Set current project to cassovary (in build file:/Users/szymon/oss/twitter-cassovary/)
> project cassovary-benchmarks
[info] Set current project to cassovary-benchmarks (in build file:/Users/szymon/oss/twitter-cassovary/)
> run
[info] Compiling 12 Scala sources to /Users/szymon/oss/twitter-cassovary/cassovary-core/target/scala-2.11/classes...
[info] Compiling 56 Scala sources to /Users/szymon/oss/twitter-cassovary/cassovary-core/target/scala-2.11/classes...
[info] Compiling 2 Scala sources to /Users/szymon/oss/twitter-cassovary/cassovary- benchmarks/target/scala-2.11/classes...
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
Multiple main classes detected, select one to run:
[1] com.twitter.cassovary.PerformanceBenchmark
[2] com.twitter.cassovary.SubsetSamplingBenchmarks
[3] com.twitter.cassovary.GraphGenerationBenchmarks
[4] com.twitter.cassovary.utils.FastUtilsWrappingBenchmark
Enter number:
Follow steps in this post,
I use gwt-maven-plugin 2.6.0, when I run mvn gwt:run-codeserver it compiled successfully:
[INFO] binding: user.agent=safari
[INFO] Compiling module com.example.myModule
[INFO] Validating units:
[INFO] Ignored 3 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO] ...
[INFO] Compiling 1 permutation
[INFO] Compiling permutation 0...
[INFO] Source Maps Enabled
[INFO] Compile of permutations succeeded
[INFO] Linking into C:\Users\admin\AppData\Local\Temp\gwt-codeserver-5664784549647002986.tmp\com.example.myModule\compile-4\war\myModule;
Writing extras to C:\Users\admin\AppData\Local\Temp\gwt-codeserver-5664784549647002986.tmp\com.example.myModule\compile-4\extras\myModule
[INFO] Link succeeded
[INFO] Compilation succeeded -- 3.401s
[INFO] Compile completed in 3496 ms
Then I started the dev server using mvn install gwt:run, made changes on my source file and click the Dev Mode On bookmark. After compiling the changes cannot reflect to UI: the UI always show old values.
Any ideas on this problem?
There's a bug in gwt-maven-plugin up to (including) 2.6.0; you have to run mvn process-classes gwt:run-codeserver instead of just mvn gwt:run-codeserver. This is fixed in 2.6.1.
Also, if you change anything in src/main/resources, you'll have to run mvn process-resources to make your changes available to Super Dev Mode (this is because you might use resource filtering, so Super Dev Mode doesn't directly look at src/main/resources).
Similarly, if you use plugins that generate resources or Java sources, you'll have to run them manually (e.g. mvn generate-sources or mvn generate-resources; or just use the same mvn process-resources as above, which will do everything at once). This will be necessary for example if you use gwt:generateAsync and change your GWT-RPC interface (note that you'll also have to redeploy your server-side code).
Note: I just updated my answer in the linked post for GWT 2.6.0, and added a note about GWT-RPC, and the gwt-maven-plugin bug.
I'm totally flummoxed by a GWT problem, and have no clue how to interpret the GWT log or how to troubleshoot the problem. I'm working on a fairly trivial template project. I upgraded to GWT 2.3.0 and am now running into the following issue when compiling the module using the maven-gwt-plugin:
[INFO] --- gwt-maven-plugin:2.3.0:compile (default) # gaewebtemplate ---
[INFO] auto discovered modules [stuff.gaegwttemplate.Main, stuff.gaegwttemplate.security.SecurityRequest]
[INFO] Loading inherited module 'com.google.gwt.activity.Activity'
[INFO] Loading inherited module 'com.google.gwt.place.Place'
[INFO] Loading inherited module 'com.google.gwt.user.User'
[INFO] Loading inherited module 'com.google.gwt.animation.Animation'
[INFO] Loading inherited module 'com.google.gwt.core.Core'
[INFO] Loading inherited module 'com.google.gwt.core.CrossSiteIframeLinker'
[INFO] [ERROR] Unable to load class 'com.google.gwt.core.linker.DirectInstallLinker'
[INFO] java.lang.ClassNotFoundException: com.google.gwt.core.linker.DirectInstallLinker
< Huge stack-trace removed >
[INFO] [ERROR] Failure while parsing XML
[INFO] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
< Huge stack-trace removed >
[INFO] [ERROR] Unexpected error while processing XML
[INFO] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
The two stack traces and cryptic error messages above is then repeated creating page after page of (as far as I can tell) completely useless log information.
Does anyone know what might be going on here? Any idea what logging "strategy" Google is using here :).
Gunnar,
I ran into a similar issue. If you are trying to use a GWT SDK newer than the maven plugin, you have to also point the maven plugin to that SDK, like this:
http://mojo.codehaus.org/gwt-maven-plugin/user-guide/using-different-gwt-sdk-version.html
Otherwise, I believe the maven plugin will still use the GWT version that matches it (if you were to delete your GWT jars from your maven repo, you could confirm this by seeing it downloading the older version.)
The DirectInstallLinker class doesn't appear to be present in GWT 2.3, but I do see it in trunk - are you sure you are using 2.3.0? To get this error, it seems likely that you have at least one copy of something newer than 2.3.0 on your classpath.
GWT 2.3.0 was released on May 2, while the DirectInstallLinker doesn't appear to have been added to source until May 6.
The GWT compiler is using the TreeLogger class, built in to GWT as a way for the compiler and generators to nest debug/error/info messages.
I got the same error when upgrading from gwt 2.3 to gwt 2.4. I was being silly and updated the version on the gwt-user dependency but not on the gwt-dev dependency. So, check that you aren't also being silly.
Maven won't overwrite the built version of an eclipse project in my local repository. I only changed a META-INF/MANIFEST.MF file, but Maven doesn't seem to recognize that and therefore doesn't overwrite the artifacts in the local repository. How can I force it to overwrite? This is the maven log:
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # message ---
[INFO]
[INFO] --- maven-install-plugin:2.3:install (default-install) # message ---
[INFO] **Skipped re-installing C:\dev\ws\Message\target\message-0.0.1.jar to C:\Users\Tim\.m2\repository\samba\message\message\0.0.1\message-0.0.1.jar, seems unchanged**
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.915s
[INFO] Finished at: Fri Sep 03 15:22:12 CEST 2010
[INFO] Final Memory: 7M/175M
[INFO] ------------------------------------------------------------------------
Okay, I think I just saw that Maven doesn't deploy the METAINF/MENIFEST.MF file with the other files in the targets. Seems I have to work on that somehow. Sorry, I'm new to Maven.
Be careful when using RELEASE Versions with maven. You should not "redeploy" them - as the contract is that they will never change anymore. If you deploy a RELEASE Version to a global Maven repository (e.g. Nexus) you will not be able to redeploy it again. You have to build a new Version if changes are necessary.
In phases of development use SNAPSHOT Versions (0.0.1-SNAPSHOT). These can be changed and redeployed.
If you are only working with your local repository the rules are not that strong but you should know about the RELEASE / SNAPSHOT version differences.
The problem was that I used the bundle plugin to generate osgi bundles. With these, the bundle plugin generates it's own MANIFEST.MF file and doesn't use the file that I put into my resources. In fact I also got some error when I tried to use my own MANIFEST.MF file in addition to the one generated by the bundle plugin.