GitHub Release Pipeline for Java

Goals Set up Maven build pipeline for a Java 11 app Release Maven artifact on GitHub using GitHub actions Setup Maven Assuming that we have a project named sample-app released for my hascode GitHub account: We’re adding some release information to our project’s pom.xml: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode</groupId> <artifactId>sample-app</artifactId> <version>1.0.0-SNAPSHOT</version>bookmark-manager <name>sample-app</name> <description>hasCode.com Bookmark Manager</description> <scm> <developerConnection>scm:git:https://github.com/hascode/sample-app.git </developerConnection> </scm> <distributionManagement> <repository> <id>github</id> <name>GitHub</name> <url>https://maven.pkg.github.com/hascode/sample-app</url> </repository> </distributionManagement> <properties> <java.version>11</java.version> <project.scm.id>github</project.scm.id> </properties> [..] </project> ...

May 14, 2021 · 2 min · 398 words · Micha Kops

Prettier Code Formatter Configuration

Goals Setup Prettier for different environments / IDEs Run Prettier via git hooks Install Prettier Install via npm npm install --save-dev --save-exact prettier Add empty configuration file echo {}> .prettierrc.json Create Prettier ignore file .prettierignore: # Ignore artifacts: build coverage Format all project files with Prettier: npx prettier --write . Git Hooks Adding the following lines to the project’s package-json makes ESLint and Prettier run before each commit: { "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "**/*": "prettier --write --ignore-unknown" } } ...

May 14, 2021 · 1 min · 90 words · Micha Kops

Continuous Deployment using GlassFish, Jenkins, Maven and Git

Recently I needed a quick solution to deploy a Java EE 6 web application on a GlassFish instance automatically and subsequent to a successful build of the project on the integration server. It took only a few steps using Jenkins, Maven and the Cargo plugin and I’d like to share this quick solution with you here. Prerequisites We need the following software installed and configured: Git Jenkins / Hudson + Git Plugin installed Maven 3 GlassFish 3.1 JDK 7 ...

May 29, 2013 · 6 min · 1202 words · Micha Kops

Creating Pre-Commit-Hooks in Git and Mercurial: Prefix Commit Messages for Feature/Story Branches

Managing my projects’ source code I am using Git also as Mercurial. Therefore I often encounter the situation where I am creating a special branch to implement a specific user story or feature request. Now when working on such a story branch I often enter the issue-key or a short title as a prefix for each commit message. Doing this by manually is a waste of time and error-prone and luckily for us, each of both DVCS offers us an easy API to add custom hooks to the different life-cycle events. ...

December 16, 2012 · 4 min · 784 words · Micha Kops

Git Snippets

Show commits from another branch not contained in current branch git cherry -v otherbranch + f7d6a569bb6912aac97fce9ac92c4302863fb0d9 thecommit Cherry pick without commit git cherry-pick -n HASH Using vimdiff for diff set it via git config git config --global diff.tool vimdiff git config --global merge.tool vimdiff set it via ~/.gitconfig [diff] tool = vimdiff [merge] tool = vimdiff Using vscode as diff and mergetool You need to have the shell integration installed (code binary in PATH) ...

March 1, 2010 · 4 min · 827 words · Micha Kops

GitLab Snippets

Generate AsciiDoc Documentation and Publish it with GitLab Pages We setup a repository and add a directory named docs there .. this is the home of our AsciiDoc files. We’re using asciidoctor/docker-asciidoctor as Docker image for tool provisioning This is the .gitlab-ci.yml, we’re running the stage only when something in the docs directory has changed. stages: - "Build docs" # The name of the job activates the GitLab pages publication pages: image: asciidoctor/docker-asciidoctor stage: "Build docs" tags: - build script: - sh ./gen_docs.sh - mv output public only: refs: - master changes: - /docs/* artifacts: paths: - public expose_as: 'Documentation Archive' ...

March 1, 2010 · 1 min · 186 words · Micha Kops

Maven Snippets

Extract Coordinates from the POM Helpful for build and integration environments, pipelines etc. Exctract the Project version from the pom.xml mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout Override a Property via local configuration e.g. to override the property xxx from your project’s pom.xml Create a directory .mvn in your project directory root Create a file named maven.config in this directory Insert -Dxxx=newvalue into the file to override this property Don’t forget to add .mvn to your .gitignore! ...

March 1, 2010 · 2 min · 401 words · Micha Kops