Visar inlägg med etikett maven. Visa alla inlägg
Visar inlägg med etikett maven. Visa alla inlägg

2018-09-20

Updated Scala Stack With Angular

News

Updated Scala Stack with Angular and made it cleaner. It uses a servlet with a Scala JS compiler to compile ScalaJS code on the fly!

About

Scala Stack is using Google App Engine, Maven and AngularJS, but only with Scala code! Both backend and frontend is written in Scala. HTML and CSS is generated from Scala code.
Note that no pre-processors or SBT are used. Backend compiles at publish and Javascripts at startup.
You can read more at my earlier blog post:

Repository

Check it out:

2018-01-02

Compiling JavaScript on Serverside With Scala and ScalaJS using Google Standard App Engine

Compiling JavaScript on Serverside With Scala and ScalaJS using Google Standard App Engine 

Since my experience with the JavaScript world and exploration of ScalaJS I felt compelled to move from Node and Grunt and try to fully utilize Scala for both front and back.
I reached a goal with Scala Stack, a concept of creating all web content on serverside using only Scala code. The concept is extended to keep everything in code including configuration to be fully testable.

Obvious Advantages

My main purpose was to skip the JavaScript world but it moved on to something much larger. If all code is shared there are quite a few advantages
  • Single, isomorphic source which ease work and can share logic
  • Share data by keeping it in code. For instance languages could be defined with a Enum type
  • Fully testable code
  • No JavaScript package manager like NPM or WebPack
  • No pre processor like Gulp or Grunt
  • No SBT since the compilation is with a simple Servlet  

Risks

There are some traps though 
  • Security, some code should not be shared between backend and frontend
  • Long term effects, demands an experienced architect 
  • Shared code needs to be ScalaJS compatible and cannot use backend dependencies since it's compiled and used on frontend

Scala Stack

Map of Scala Stack

I've made three implementations using Google Standard Environment with Java 8. Implemented in native JavaScript, jQuery and AngularJS.
Goal is to keep everything in code and to avoid configuration, annotations and settings in Strings.
By only using Scala on serverside, it produce HTML, CSS and JavaScript which is all components for a webpage. 

Scala Stack with Angular

You find links to code and running example below

Servlet Compiler

Scala Stack is using a Servlet compiler with different logging:

2016-05-30

Uppdated! "Cannot determine the default location of the Google Cloud SDK" Solved

Error

Got a really annoying error while trying to run my local Flexible Environment with GCloud 
$ mvn -Dgcloud.gcloud_directory="c:\path\to\gcloud-sdk\" gcloud:run
[ERROR] Cannot determine the default location of the Google Cloud SDK.
[ERROR] If you need to install the Google Cloud SDK, follow the instructions located at https://cloud.google.com/appengine/docs/java/managed-vms
[ERROR] You can then set it via <gcloud_directory> </gcloud_directory> in the pom.xml
[ERROR]
org.apache.maven.plugin.MojoExecutionException: Unkown Google Cloud SDK location:C:\...\gcloud_sdk
        at com.google.appengine.gcloudapp.AbstractGcloudMojo.setupInitialCommands(AbstractGcloudMojo.java:170)
        at com.google.appengine.gcloudapp.GCloudAppRun.getCommand(GCloudAppRun.java:306)
        at com.google.appengine.gcloudapp.GCloudAppRun.execute(GCloudAppRun.java:292)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.441 s
[INFO] Finished at: 2016-05-30T20:21:34+02:00
[INFO] Final Memory: 24M/380M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.appengine:gcloud-maven-plugin:2.0.9.74.v20150814:run (default-cli) on project scala-js-compiler: Execution error: org.apache.maven.plugin.MojoExecutionException: Unkown Google Cloud SDK location:C:...\gcloud_sdk -> [Help 1]

Solution

It was much easier to solve! Just add Python to path (which is bundled in the Gcloud SDK).
But managed to use the locally installed python to run the python script which starts development server:
$ cd project
$ c:\...\gcloud_sdk\google-cloud-sdk\platform\bundledpython\python.exe c:\...\gcloud_sdk\google-cloud-sdk\bin\dev_appserver.py src\main\webapp

2016-04-02

Webapp with HTML, CSS and JavaScript written in Scala

ISO Scala

This is an example of HTML, CSS and JavaScript written in Scala.

Technics

Different parts are written in different ways
  • Backend, Scala implementation of a Java Servlet
  • HTML and CSS, using ScalaTags to generate HTML in a String
  • JavaScript, built with ScalaJS

Two Builds

There are two different builds
  1. Backend, using plain Maven to build and setup the project
  2. JavaScript, built with SBT and using ScalaJS dependencies

Example

View a whole example at

2015-11-09

Google App Engine + Scala + ScalaJS + Objectify

Created a single Maven project combining Google App Engine, Scala, ScalaJS and Objectify.

Description

A Scala implementation of Filter using Objectify, a separate source directory for ScalaJS which is generating JavaScript with SBT.