понеделник, 15 август 2016 г.

Presentation about Babel

I will lead a presentation about Babel in Questers.
Babel is a in fact coverter from ECMAScript 6 to ECMAScript 5. If you want to use ES6 features you can use it into your code and after this you can transpile
it for production. Everione who is interested is welcome. The presentation will be conducted in the Bulgarian language. You can register here.

събота, 16 юли 2016 г.

How to have value like baseDirectory into singleton object in Sbt?


I am currently a lamer in sbt technology. Sbt stands for Simple build tool. This is a build system that is highly developed, modern and is the de facto standard build tool in the Scala world. Currently I'm using sbt for several job tasks and last week I came across a rather unpleasant problem that probably is very easy to solve for experienced Scala and sbt developer. I am writing this article to help people with a similar problem in the future. Sbt has several global settings. One of this global settings is
baseDirectory. Depending on the scope, this is the base directory for the build, the project, the configuration, or the task. You can easy get value of project base directory from sbt console. Just type
baseDirectory and you will get the value of this setting.
You can also use inspect baseDirectory and you will get additional information.
In sbt is a good practice to isolate long tasks into singleton object and keep build.sbt much shorter. This is very cool but in order to have some global settings into this singleton object there are several tricky things that you must to do. The same thing is true if you want to have streams available to the singleton object. My job task involved to process a certain way all the files that meet certain criteria. For this purpose, I had to have baseDirectory for project. When I tried to pass baseDirectory as a method argument in this way:
And this:
Every time I got error like this:
I tried several things. For example to pass baseDirectory.value in this way:
But I got errors that .value cannot be used in this way. In the end, I managed to solve the problem with using ".." into the singleton object, that means "the parent directory". But this solution is not good at all. What will happen if the location of .scala file is changed? I love stackoverflow. Sometimes you can ask and get valuable help and explanations. Also you can answer questions and thereby helping others. I asked the question and received a helpful guidance. So If you want to have baseDirectory or similar value into singleton object, you must define the object like this.
And into build.sbt this:
Or this:
I like second solution because looks much clearer.
You can also check example repository into github here. If you want you can check the stackoverflow question.

понеделник, 4 юли 2016 г.

Install latest maven 3 under Ubuntu.

Maven is the de facto standard build tool for Java. There is something that extremely annoys me under Ubuntu. That every time you need to install the latest maven 3 manually and never got it in the standard Personal Package Archives ('PPAs'). Of course there are external PPA, but always the question arises how much can be trusted their contributors. Today I again needed to update maven into one vagrant box so I repeat the exercise again. Maybe this bash script will be useful for the people with a similar problem in the future. The script just install the latest - 3.3.9 version of Maven. The idea is to can be modified easily in the future - just to change variables with name and path. I do not pretend that the script is good - I'm not bash programmer.