Carlos Chacin

Software Engineering Experiences


🏆 Default 🔗 Maven and ☕ Java settings per project

Posted at September 23, 2021 /

github-actions

I generally use many different options on maven projects to set up things like memory lower and upper limits, fail at the end, the process in batch, use x number of threads, etc. In addition to this, sometimes I need to pass flags to the JVM like add modules, garbage collector flags, etc., and it is difficult to remember and also error-prone to have something like this:

$ JAVA_OPTS="-Xms512m -Xmx1024m -Djava.awt.headless=true" \
  mvn -B -T 4 -fae -P ci verify

or even worst with the extended version of the flags:

$ JAVA_OPTS="-Xms512m -Xmx1024m -Djava.awt.headless=true" \
mvn --batch-mode --threads 4 -fail-at-end --activate-profiles ci verify

Fortunately for us, since maven 3.3.1, we now can setup this per project, including the flags in these two files relatives to the project directory:

Read more ...

☕🚢 Maven Build in < 20 lines of yaml 🕟

Posted at September 22, 2021 /

github-actions

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

Create the directory

$ mkdir -p .github/workflows

Create the yaml file

$ touch .github/workflows/maven.yml

Copy this content

name: Maven Build
on:
  push:
    branches:
      - main
jobs:
  build:
    name: "Maven Build"
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout Sources"
        uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - name: "Set up JDK"
        uses: actions/setup-java@v2
        with:
          distribution: "temurin"
          java-version: 11
          cache: "maven"
      - name: "Build with Maven"
        run: mvn verify

Commit and push to Github

$ git add .github && \
  git commit -m "maven build action"

Enjoy your builds

Go to the actions tab for your repository over github.com:

https://github.com/${USER}/${PROJECT}/actions/workflows/maven-build.yml

maven-build

Read more ...

💾 Java Records 💿 with Jackson 2.12

Posted at March 04, 2021 /

java-records-jackson

In the previous article about Java 14 Records, we saw how to start creating Records to avoid writing much boilerplate code that the compiler would generate for us.

Now the next steps are to see how we can serialize records to JSON and deserialize JSON to records to be able to use them as a request/response representation for microservices.

In this case, we would use the Jackson 2.12+.

Read more ...

🌒 JakartaEE JSON-B 🐝 Retrofit2 Converter

Posted at September 23, 2020 /

java-records-jsonb

Retrofit is pluggable allowing different serialization formats and their libraries to be used for converting Java types to their HTTP representation and parsing HTTP entities back into Java types.

These are called converters, and Retrofit includes a few first-party modules for popular frameworks

Just for fun, I created a Retrofit2 Converter.Factory for JakartaEE Json-B.

Read more ...

🔌 Restore IntelliJ Idea settings ⛽

Posted at April 30, 2020 /

intellij-restore-settings

After a long day trying to figure out how to reset all my IntelliJ settings, I decided to write this to document the obvious solution that was not that obvious to me.

I was using the 🔥 JetBrains Toolbox App 🔥 for a while to manage my IntelliJ Idea Ultimate installation along with other tools like Rider, WebStorm, and the Early Access Preview for IntelliJ Community Edition.

toolboxapp

After several installations and reinstallations of IDEs and different Java/JDK versions (8, 9, 11, 14), the IDE was not able to import my maven projects. The IntelliJ IDEA was acting as a simple text editor at this time 😟.

Read more ...