Showing posts with label gradle. Show all posts
Showing posts with label gradle. Show all posts

Wednesday, February 5, 2020

Java 13 with Gradle 6

Java still used for many digital product companies even today. Currently, Java is on version 13. Today I want to show how to use JDK13 with Gradle6. JDK13 has some improvements on GC(as usual), minor new methods for Strings and IO and there are 2 interesting new Experimental Features. So let's get started.


Gradle Project

Let's take a look at the build.gradle file.

Besides using the Java plugin. We need to set the source code compatibility and target to 13. We also need to pass additional parameters for compile, testing and running in order to enable experimental features. Now we can go to the new Experimental features in Java 13.

Java 13 Code


So here we have 2 features. First, we have a multi-line string with """ and then we can pass a Json object without annoying scaping "\" like we had to do it before. The other cool feature is that we can use switch statements directly in a variable which makes the switch more similar to a pattern matcher.

Here is the complete code on my GitHub.

Cheers,
Diego Pacheco

Thursday, July 6, 2017

Global Gradle Config for Remote Debug and IDE support

Gradle right now is the standard tool for Java builds. Before gradle, pretty much everybody was using maven.

Working with cloud computing very often we need do remote debugging. In this blog post, I will show how to configure remote debugging for all your gradle projects.  The nice thing about the approach I will show is that you don't need to change your build.gradle files since we will do it as a global config this will be valid for all.

We also will setup configs for Eclipse and IntelliJ IDE support in the same file. Since we will configure remote debug you need to keep in mind that debug port need to be open in all security groups and firewalls in order to work.  Keep in mind remote debug is slow especially with Amazon.

We will open port 9009, but you can change the port if you like. This config works with Jetty and also with Java main classes as well.





Configuring Remote Debug and IDE Support in Gradle

Cheers,
Diego Pacheco

Sunday, August 30, 2015

Is Gradle Dynamic resolution strategy safe?

Gradle Dynamic Resolution strategy a.k.a use a + on the dependency is a usable feature. This is handy because you can do something like spring:spring-core:4.0.+ and gradle will always get the latest snapshop for you - but them to make this work fine you need people have discipline to do proper major/minor versioning. 

Its easy to mess with this. In paper this is good in practice it creates lots of Configuration Management problems like: 
  • Breaking Changes: It`s easy to people break your code with because they could easy introduce breaking changes and you will get automatically.
  • CM HELL: You dont know with version your code works and with version your code do not work since you dont know with exactly version your are using and when people introduced problems.
  • No Control: When you put something like 1.0.0 you know what you are doing and if you update to 1.1.0 and does not work is easy to roll it back but since you dont know what exactly you are using is harder to know what made the change and create the issue.
Maybe Snapshot Dynamic Version is evil maybe not - but it required lots of maturity and discipline to use it right, in DevOps we have immutable infrastructure and everything you do is a new version - a new EXPLICIT version, so i think explicit versioning it the right thing todo, so people have release notes and proper communication to know when there are changes and pick when and if yes or not change thats give you more control and more 
flexibility with you dont have with the +. 
Cheers,
Diego Pacheco

Sunday, June 21, 2015

Setting up a full JVM Env with Vagrant: Java 8, Scala 2.11, Groovy 2.4, Clojure 1.6, Maven 3.3, Gradle 2.4, Sbt 0.13 and Lein

On the previous posts i show how to use docker, docker-compose and nodejs with vagrant now let`s do a full jvm env :-)

This setup is pretty easy and straightforward for you however it could take some time depending of your internet bandwidth because we gonna download several components.

Remember you need to have Vagrant installed already, this time we gonna need more than just the Vagrant file because java, scala, clojure for instance require we setup environment variables so we gonna need change some files for clojure and sbt  in order to make everything work smoothly.

What Languages will be installed?
What Build Systems will be installed?

You will need to use this vagrantfile, here i do all the provisioning necessary to have this components installed and proper configured ready to you use and have fun.


As i said you will need custom bashrc file and also a script to run clojure all this file you can get on my github here: https://github.com/diegopacheco/Diego-Pacheco-Sandbox/tree/master/DevOps/vagrant-jvm look for the conf directory.

Now we are ready to run $ vagrant init && vagrant ssh 
Vagrant will download and provision all installations we need, as i said this cloud take some time.

Cheers,
Diego Pacheco

Chuyên mục văn hoá giải trí của VnExpress

.

© 2017 www.blogthuthuatwin10.com

Tầng 5, Tòa nhà FPT Cầu Giấy, phố Duy Tân, Phường Dịch Vọng Hậu, Quận Cầu Giấy, Hà Nội
Email: nguyenanhtuan2401@gmail.com
Điện thoại: 0908 562 750 ext 4548; Liên hệ quảng cáo: 4567.