Giter VIP home page Giter VIP logo

scala-skeleton-project-simplified's Introduction

Sample Scala Project with Simplified Structure

What is it

This program is Java Swing Window and an embedded Groovy console where the user can run scripts and manipulate the window interactively.

The purpose of the project is to demonstrate how to create a sample scala project with simplified structure not following Maven boilerplate layout and making the assumptions that it is Scala-only, that there is no java source code and there is only one base package, aka namespace, which is omited.

In a standard Scala project the directory layout of the project would be like as shown in the schema below with lost of nested directories and the sub directories /com/org/apptest for the package com.org.apptest:

src/
  main/
   scala/
     com/org/apptest/
                Main.scala 
                UserInterface.scala 

   java/        

This project simplifies the directory structure to:

src/
   Main.scala 
   UserInterface.scala 

This was tested sucessfully with jetBrains’s InteliJ Idea and Scala’s sbt tool.

Build, Running and Deploying

To build the project go to its root directory and run:

$ sbt run
[info] Loading settings from idea.sbt,plugins.sbt ...
[info] Loading global plugins from /home/archbox/.sbt/1.0/plugins
[info] Loading settings from assembly.sbt ...
[info] Loading project definition from /home/archbox/workspace2/sample-project2/project
[info] Loading settings from build.sbt ...
[info] Set current project to myApplication (in build file:/home/archbox/workspace2/sample-project2/)
[info] Running com.org.apptest.Main 
Initializing groovy Console

To create a standalone program, uber jar with all dependencies bundled run:

$ sbt assembly
[info] Loading settings from idea.sbt,plugins.sbt ...
[info] Loading global plugins from /home/archbox/.sbt/1.0/plugins
[info] Loading settings from assembly.sbt ...
[info] Loading project definition from /home/archbox/workspace2/sample-project2/project
[info] Loading settings from build.sbt ...
[info] Set current project to myApplication (in build file:/home/archbox/workspace2/sample-project2/)
[info] Including from cache: scala-library.jar
[info] Including from cache: groovy-all-2.4.15.jar
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'META-INF/INDEX.LIST' with strategy 'discard'
[warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to 2 files
[info] SHA-1: d0b553caeeec05b9a8c4a3e1222864c1a75a1277
[info] Packaging /home/archbox/workspace2/sample-project2/target/myApplication-assembly-1.0.jar ...
[info] Done packaging.
[success] Total time: 4 s, completed Jun 16, 2018 7:44:31 PM

To create the uber jar and copy it to the project’s root directory run:

$ sbt copyUber
[info] Loading settings from idea.sbt,plugins.sbt ...
[info] Loading global plugins from /home/archbox/.sbt/1.0/plugins
[info] Loading settings from assembly.sbt ...
[info] Loading project definition from /home/archbox/workspace2/sample-project2/project
[info] Loading settings from build.sbt ...
[info] Set current project to myApplication (in build file:/home/archbox/workspace2/sample-project2/)
[info] Including from cache: scala-library.jar
[info] Including from cache: groovy-all-2.4.15.jar
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'META-INF/INDEX.LIST' with strategy 'discard'
[warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to 2 files
[info] Assembly up to date: /home/archbox/workspace2/sample-project2/target/myApplication-assembly-1.0.jar
Created  = myApplication-uber.jar
[success] Total time: 1 s, completed Jun 16, 2018 7:45:17 PM

The created uber jar, namely myApplication-uber.jar can be run by just double clicking on it or running the command:

 $ java -jar myApplication-uber.jar 
 Initializing groovy Console
 i = 1
 i = 2
 i = 3
 i = 4
 i = 5
 i = 6
 i = 7
 i = 8
 i = 9
 i = 10
  was clicked
  was clicked
... ... .... 

Screnshot:

images/screenshot1.png

scala-skeleton-project-simplified's People

Contributors

caiorss avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.