This blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://blog.xeiam.com
and update your bookmarks.

Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Saturday, February 8, 2014

Introducing Bitcoin Bounties for Open Source Development

Last week, we started experimenting with offering bounties to help speed up the development of one of our open source projects called XChange. Based on initial success, we've decided to offer bounties beyond the XChange project, and therefore created a centralized page on xeiam.com where all current and paid bounties are listed. Following is the text directly from the bounties page:
Welcome to Xeiam's Bounty Program. Below is a listing of all our current open and past paid bounties. All bounties are paid in Bitcoin, and it's by far the simplest and fastest way to transfer money in today's globally connected community. We'll be posting all new bounties on our twitter feed, so please subscribe to be the first to hear about new bounties!
If you'd like to work on an issue for a bounty, the first thing you should do is claim it by adding a comment on the GitHub issue page where the bounty is defined along with how long you need to finish it. In this way, bounties can be claimed on a first-come first-served manner, but others may attempt it if the original claimer cannot finish it in a reasonable time. To claim the bounty, just leave your Bitcoin address as a comment on the GitHub issue page or in the pull request.
100% of donations to open source projects will be directly recycled back into the project as a bounty or bounties. In you're interested in donating or sponsoring a bounty for a specific feature request, please visit the project on GitHub where you can find the Bitcoin donation address and/or post a new issue.
We have plans to offer many more and higher paid bounties in the near future!

Sunday, May 26, 2013

XChart 2.2.0 Released!

XChart, A Simple Charting Library for Java, licensed under the Apache 2.0 license, version 2.2.0 was released today! This release brings many exciting features most notably a MATLAB theme, CSV import/export, and high-resolution chart exporting. The newest features of the XChart library include:
  • Themes - XChart, GGPlot2, MATLAB
  • CSV import and export
  • High resolution chart export

For more features, see XChart 2.0.0 Released! and XChart's home page.

A Swing demo is also available for download along with the main xchart jar here. To run the demo from the command line type the following:
 cd /path/to/xchart-demo/jar/  
 java -cp xchart-demo-2.2.0.jar:xchart-2.2.0.jar com.xeiam.xchart.demo.XChartDemo  

The following three images show the three themes that are currently implemented - XChart, GGPlot2, and MATLAB.





Finally, here's how you can save a chart in high-resolution format specifying the DPI. This is useful when you want your charts to appear in printable material such as PDFs or books.

    BitmapEncoder.savePNG(chart, "./Sample_Chart.png");
    BitmapEncoder.savePNGWithDPI(chart, "./Sample_Chart_300_DPI.png", 300);

The difference is resolution is very clear in the following images.

Friday, May 10, 2013

Configure Travis CI to Deploy Snapshots to a Maven Repo

In order to deal with the amount of different projects Xeiam is currently managing, both open source and commercial, we jumped at the opportunity to move all of our OSS projects over from an in-house Jenkins CI to a free hosted Travis CI service. Doing so frees us up from having to maintain our Jenkins server, deal with it hanging, updating it, etc. This is just one more step in streamlining project development and management. The only disadvantage by doing this was the loss of our Sonar code quality analytics, but I suspect something of the sort will soon become available as a plugin to Travis CI.

What we needed Travis CI to do though was a bit non-standard, and we wanted to write what we learned here for future reference, but also to help other get their Maven builds deploying snapshots to a repository. This article assumes you've already setup your Travis CI account and have followed the standard setup procedures and configurations linking your Travis CI and GitHub accounts and projects. Make sure to enable the Travis CI hook in GitHub too. The example configurations contain stuff relevant to our project XChart, and you'll have to adapt your configurations to your specific project's properties.

References

Our initial inquiry on Travis Google group
Travis gem and secure variables
Xeiam's XChart project on GitHub
XChart's Travis CI page

settings.xml

Simply add another branch to your project called `travis`, remove everything from it, and place the following `settings.xml` file in it.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers>
    <server>
      <id>sonatype-nexus-snapshots</id>
      <username>${env.CI_DEPLOY_USERNAME}</username>
      <password>${env.CI_DEPLOY_PASSWORD}</password>
    </server>
  </servers>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings>

Generate Encrypted Variables

The artifact repo requires a username and password of course, and we don't want to have those as plain-text in the above `settings.xml` file. Therefore we use the following commands to generated the encrypted keys. You'll need to run these commands on a machine where ruby is installed and the travis gem is installed. Obviously replace `timmolter/XChart` with your own github account name and project name.
travis encrypt -r timmolter/XChart "CI_DEPLOY_USERNAME=username"
travis encrypt -r timmolter/XChart "CI_DEPLOY_PASSWORD=password"

.travis.yml

Place a file called `.travis.yml in the root of the project on the branch you want to be deployed. You'll need to modify this .travis.yml file as shown here. The whitelist specifies that we only want the build to run on the `develop` branch. Replace the keys below with your generated codes from the previous step.
language: java
before_install: "git clone -b travis `git config --get remote.origin.url` target/travis"
script: "mvn deploy --settings target/travis/settings.xml"

# whitelist
branches:
  only:
    - develop

env:
  global:
    - secure: "R7i6miE4AIbj1o6E8fwWvKwjvygha172QSdKM0Jto/Qq3AyLuWMCthYAxevq\nX+I64lw3exhmEiOHXHjh1lGTnGZ9kXklIU+q4vo9QfdYH7WU47chE0KZfQtd\n64EoFo8KmSD4VQjyiNv7ReLdoqksRAj2dL386fWrBAUWkwhxD4w="
    - secure: "UL4rCDPPBrk7cju9f+fNi1qfGWb+q/36wJYUEeuINDa2a4c4oHvdOX0aYOIV\nbBDeaReKMtl6mpjG2uxCZwaz7N3/VADDMrqA+wbTbWKgyWeTACzAz/Z/6w8E\noOAkS8EUCZgDiXeHuirYvQQ47KbzYmf2m4/EUAQm+VIHFbO1ssE="

Test It

Now that everything is setup, all you need to do is push a change on the `develop` branch to GitHub, and Travis CI will build the Maven project and deploy the artifacts to a snapshot repo automatically!

Piece of Cake!!!


Other Travis CI Tidbits

1. Pushes that have [ci skip] anywhere in one of the commit messages will be ignored.
2. Embed a Travis CI build badge in REAME.md file: `[![Build Status](https://travis-ci.org/timmolter/XChart.png?branch=develop)](https://travis-ci.org/timmolter/XChart.png?branch=develop)`

Wednesday, March 6, 2013

A Practical Guide to Uploading Artifacts to Maven Central

This blog post takes you through the steps you need to take to get your Java artifacts (Jars, JavaDocs, Sources, etc.) uploaded to Maven Central. A lot of the steps are already well documented on Sonatype's Maven Repository Usage Guide, and this post will refer to it heavily but fill in the spots where that guide is a bit weak. First off, here are the main references you will need:

References

https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven

Heads Up Mac Users!

If you get a complaint from Maven about Java Home not being properly set on your Mac do this at the CLI:
 echo $JAVA_HOME  
 export JAVA_HOME=$(/usr/libexec/java_home)  

Instructions

Follow the instructions in the first reference up to, but not including step 7a.3 Stage a Release. At this point you've already gotten a Sonatype account, pushed snapshots to Sonatype's snapshots repo, and got your PGP keys setup on your machine. Now to upload your non-snapshot releases to Maven Central, you need to run some Maven commands from the CLI. Make sure you have Git installed on your machine as well. The following Maven commands work for multi-module Maven projects as well as single-jar projects. You'll need to adapt these commands to your specific project. These instructions are just a supplement to step 7a.3 on Sonatype's guide. Here are the CLI commands I ran to release XChange version 1.3.0...

Tip!

Leave the -SNAPSHOT in your pom.xml. The release plugin removes it and increments to the next snapshot version for you automatically. It also tags the commit for you too.

First Do a Dry Run

note: replace "xchange" with your own artifactId, replace 1.3.0 with your current version.
 mvn clean  
 mvn release:clean  
 mvn --batch-mode -Dtag=xchange-1.3.0 -DreleaseVersion=1.3.0 -DdevelopmentVersion=1.3.1-SNAPSHOT -DdryRun=true release:prepare  
 mvn release:rollback  

Then Do the Real Thing

note: replace "xchange" with your own artifactId, replace 1.3.0 with your current version.
 mvn release:clean  
 mvn --batch-mode -Dtag=xchange-1.3.0 -DreleaseVersion=1.3.0 -DdevelopmentVersion=1.3.1-SNAPSHOT release:prepare  
 mvn release:perform -Darguments=-Dgpg.passphrase=PASSPHRASE  

The Final Stretch

The last thing to do now is to use the Sonatype web interface to release the artifacts. Just follow the instructions starting at Step 8a on Sonatype's Guide.

Done!

After a couple hours of waiting, your artifacts will be available on Maven Central. I found that it takes even longer for them to be available on search.maven.org, but as soon as they show up in the repository, you and others can access the artifacts by adding a dependency to the pom.xml file in a Maven project.