Archive
My favorite Free/Open Source Intellij Community plugins
Suggestions for other/better Free/Open Source plugins for current Intellij CE are welcome:
- Maven Helper
- Git .ignore support
- Bash Support
- PlantUML integration
- String Manipulation
- YAML/Ansible support
- AsciiDoc support
- BrowseWordAtCaret
- Grep Console
Continuous delivery using github, travis-ci and bintray
Let’s say you work on a Java application and want to frequently make it available for download so that user’s can easily try the latest version.
Let’s say you work primarily on your laptop or personal computer using a Java IDE and commit code changes, but you don’t want to spend time manually building jars, packaging war or zip files, testing your application or uploading files to a website, etc.
Instead you want to have a fully automated process that compiles your source code, runs automated tests and other quality control mechanisms, builds your application and uploads the result to a public website.
But you don’t want to install any infrastructure for this and not run anything besides Java and your IDE on your own machine(s).
Basically you want to use developer-friendly reliable cloud services but you don’t want to pay a single cent.
All of this is possible, as long your code is Open Source:
- Host your source code on github
- Let travis-ci run vour build process
- Let travis-ci upload the build result to bintray
For details, you can take a look at one of my github projects.
Relevant config files:
Build Java Maven github project on travis-ci
Update 14/Aug/2018: I no longer use an FTP space for the build artifacts, instead I use bintray.
I used to use Cloudbees’ buildhive for continuous builds of my Java/Maven based github projects. But buildhive currently does not offer JDK 8. So far that hasn’t been a problem, but I recently started using lambdas and default methods in interfaces and other Java 8 goodness. And now buildhive does not work for me anymore.
So I looked for alternatives and tried travis-ci.org. It was easy enough to set up a free account: You just authorize their service through your github login. Then all your projects will be listed on travis and you just click a switch to enable a build.
.travis.yml with FTP upload
To actually activate a build, you have to add a .travis.yml file at the root of your project.
The builds then happen automatically whenever you commit changes to github. This is the build list for one of my projects.
My build produces a distributable zip file, using Maven assembly plugin, that contains all the jars and start scripts of my application. I want to make the latest stable version of that zip file available for public download. With buildhive I used the permanent URL of the build artifact within the workspace of the last stable Jenkins build. But travis does not store anything after the build.
To make travis-ci build artifacts available, a deploy step is required. Many cloud storage systems are supported, but I opted for a custom deploy via FTP to my web space at dev.doepner.net.
So to build my Java Maven project with JDK 8 and do the FTP upload of the zip artifact, I ended up with these lines:
language: java jdk: oraclejdk8 env: global: - secure: L2lr/F0gIvyVUl0nJ7w9saGV7wZkL6nO61IxilDY/76iTlnhrFXn5Q8vATGbiRYdDW/tG1kyDUbKaWSkYrpV2Agm4wV/KmMg2CWRiIcQPPqwSEENx/1UZ/dBnCQGcRkkYApu5ayjGnX3Srg3ty1zvdud/O8tiKtWkkBDipJSpfY= - secure: OekVM5ZyLGHpqurOUWJcq0kKBA78WKZdXaA9aylwrjjQFeVoZxyxeZTYbhLajN4Ggg4Th58QwjUHpwcgZlnsxx4heDo1wyHxXojJd0H1LWKXJwet82IXaFJbl+Yz/htr7uWSFTUF6Szx70cpMxlGe3qsIFlgViEo9UGhHHdrjdY= after_success: ./.travis/artifact-upload.sh
The env – global – secure entries are the encrypted username and password for my FTP server. Details about the encryption steps are at the end of this blog post.
Artifact upload script
The .travis/artifact-upload.sh script performs the actual upload. The .travis directory is in the root of my github project. The script looks like this:
#! /bin/bash local_file="$(ls $TRAVIS_BUILD_DIR/typepad-dist/target/*.zip | head -n 1)" target_url='ftp://doepner.net/~/public_html/dev/dist/ci-builds/typepad.zip' echo "Uploading $local_file to $target_url" curl -u $FTP_USER:$FTP_PASSWORD -T "$local_file" "$target_url"
I am only interested in the latest zip and I want the URL to be permanent, that’s why the filename is hardcoded as typepad.zip.
Build status and download links
Similar to buildhive, travis-ci provides nice build status icons that automatically show the current status of your build.
The README.adoc of my github project now contains these build status and download links:
== Build status image:https://travis-ci.org/odoepner/typepad.svg?branch=master[ link="https://travis-ci.org/odoepner/typepad"] http://dev.doepner.net/dist/ci-builds/typepad.zip[Download latest build]
If you are not used to this syntax: It is AsciiDoc, not the default Markdown format of github READMEs.
Encryption of FTP credentials
Travis supports encryption of environment variables. This makes sense, because you probably don’t want to expose your FTP username/password to the world.
To perform the encryption, a local travis command-line installation is required. On Debian it can be setup like this:
1) Install JRuby (but not Rails)
2) gem install travis
3) cd to local working copy of your project
4) travis encrypt FTP_USER=yourusername --add
5) travis encrypt FTP_PASSWORD=yourpassword --add
The --add
tells the travis command to add the resulting config directly to the .travis.yml file in your project directory. That’s why you first need cd to the base dir of your project.
Jenkins Maven builds on OpenShift
Short version: If you want proper Maven builds with Jenkins on OpenShift, please vote for change request JENKINS-19844.
Full story:
Today I installed Jenkins on my OpenShift account to use it as Maven release build server for some of my Java based github projects. I ran into various obstacles and partially misleading information.
Installing the Jenkins “cartridge” on the OpenShift web console was the easiest part.
Then I logged into my new Jenkins using the auto-generated “admin” login. I created a “New Item” to “Build a maven2/3 project”, i.e. a new Maven build job, and configured it: Selected “Git” SCM and pasted the github URL of the project I want to build.
At first all “Build Now” attempts failed silently, until I realized I had to go into “Manage Jenkins” – “Configure System” page to change the “# of executors” from 0 to 1.
Next thing was that the Maven installation was not found. I set up ssh access to my OpenShift Jenkins (paste contents of ~/.ssh/id_rsa.pub from my Linux laptop into web console, then find the ssh hostname to connect) and ran a “find -name mvn /usr” on the host which located a Maven installation at /usr/share/java/apache-maven-3.0.4. I entered this in the “Maven installation” section on the Jenkins “Configure System” page.
Now I got at least some “Console output” when I clicked “Build Now” and navigated to the page of that build. The next error, however, has so far been a blocker for me. It is described here and seems to be a limitation of the Maven agent binding address in Jenkins.
I found several blogs recommending the “free-style” Jenkins job type as a workaround, instead of “maven2/3 project”. But that has many limitations and is not an acceptable solution for me.
Finally I noticed that the issue has already been reported in 2013 as JENKINS-19844 “Maven agent socket bind too inflexible (allow Jenkins in virtualized environment)”, but was closed by mistake due to a mix-up of JIRA issue numbers (19844 vs 19884).
I used my account at jenkins-ci.org and reopened the Jenkins issue. Now I can only hope that someone from Jenkins committers team will care enough about this and apply the suggested code changes. Then we have to wait until OpenShift provides a Jenkins version that contains the fix.
Additional Note: I also read about other issues with Maven on OpenShift, e.g. Jenkins having no write access to ~/.m2/repository. I could not verify those problems but they seem to be fixable in ~/.m2/settings.xml, using $OPENSHIFT_DATA_DIR. Via ssh, I was able to create and edit ~/.m2/settings.xml.
Java software engineering – reference resources
Official Java and JEE
Java language spec and JVM spec
Java community
Trending Java projects on github
JEE and Java web servers
Build and test automation
Source and version control
Java IDEs
Using libgdx for cross-platform app development
I am looking for a framework that allows me to develop modern apps (mobile, web, desktop) all from one Java codebase. I prefer Java because I know it very well, it is already cross-platform and a statically typed language that allows IntelliJ, Eclipse and Netbeans to be better than any dynamically typed scripting language editor could ever be.
Currently my favorite is libgdx. I am planning to use it with IntelliJ Community Edition and with Maven.
By using RoboVM, libgdx even supports iOS.
For user input (forms) libgdx provides the scene2d.ui widgets. I hope that will be sufficient for most of my UIs. Now I just have to get OpenGL to work on my Linux box …
Recent Comments