Skip to content

Getting Started Developing

Sean Owen edited this page Feb 19, 2016 · 28 revisions

Just Need a JAR?

If you just need a pre-built JAR file, you can always find compiled resources from the Maven release repository, including recent snapshot/nightly builds.

Download

Download the latest release, version 3.0.0 or later. Or, retrieve the latest source code from Github.

The code is organized into several subdirectories, corresponding to modules, like core/ and javase/. Within each Java-based module, there is a pom.xml file for use with Apache Maven.

Configure

A few configuration steps are needed, depending on which modules you want to build. From the directory where you unpacked or checked out the source code:

android/

The Android SDK must be installed of course. Run the tool called android and ensure that platform support for the latest Android release is installed. At the time of this writing, that's platform level 22 / Android 5.1.

export ANDROID_HOME=/change/this/path/to/android-sdk

Build

From the root of the project, run mvn install to compile, test and assemble all modules. Add -DskipTests to skip unit tests. Note that Android-related modules and apps will not be built unless ANDROID_HOME is set.

Compiled .jar files are found in submodules after this. For example, the compiled core/ code is available at core/target/core-x.y.z.jar.

android/

To build the Barcode Scanner Android app, a few slightly different steps are needed. From android/, run mvn package android:apk to produce a compile .apk file in target. Use android-x.y.z-aligned.apk.

Other users will not be able to build the signed release version, but the command is: mvn -Pandroid-release -Djarsigner.storepass=... -Djarsigner.keypass=... clean package android:apk.

androidtest/ glass/

Being Android apps as well, the ZXing Test and Barcode Scanner for Google Glass application APKs are built similarly to android/.

zxingorg/

Note that the deployable .war file will be produced in the target/ directory.

Run

Most components are libraries and are not run directly.

android/

  1. Build android/
  2. Connect your device via USB
  3. If you already have the standard version of Barcode Scanner installed, uninstall it
  4. Make sure your device is set to allow apps from untrusted sources
  5. In release 3.0.0 and earlier, run ant installd to install the debug build. In release 3.0.1 and later, run mvn android:deploy.

javase/

Version 3.2.2+

After building, in the javase/ directory, execute mvn -DskipTests package assembly:single to create a single JAR file containing all classes needed to run client command line apps, as target/javase-x.y.z-jar-with-dependencies.jar. Run CommandLineRunner with simply:

java -jar target/javase-x.y.z-jar-with-dependencies.jar [URL | FILE]

Earlier versions

After building, simply run this class with java from the top-level directory:

java -cp javase/target/javase-x.y.z.jar:core/target/core-x.y.z.jar com.google.zxing.client.j2se.CommandLineRunner [URL | FILE]

Path syntax is different on Windows. Here and elsewhere you will need to use ';' rather than ':' to separate classpath elements, and likely need to use the '' path separator.

Maven

core/, javase/, android-integration and zxingorg can be used directly in a Maven-based project without any download or installation. Instead, add as dependencies from groupID com.google.zxing artifactIDs core, javase, android-integration or zxingorg:

<dependencies>
  ...
  <dependency>
    <groupId>com.google.zxing</groupId>
    <artifactId>core</artifactId>
    <version>(the current version)</version>
  </dependency>
</dependencies>

Project Developers Only: Release Process

  1. For the three apps (android, androidtest, glass), update their parent version to be the upcoming release and commit locally
  2. Make sure CHANGES is up to date and everything is committed
  3. Update the current milestone in Github as needed and close it
  4. unset ANDROID_HOME so as to not release Android apps
  5. mvn -s private-settings.xml clean release:clean release:prepare and optionally add -DreleaseVersion=x.y.z -DdevelopmentVersion=a.b.c-SNAPSHOT if the answer is not the one Maven guesses and you want to avoid repeating the answer
  6. If all is well, mvn -Darguments="-Dgpg.passphrase=..." -s private-settings.xml release:perform
  7. Log in to oss.sonatype.org and finish the release (http://central.sonatype.org/pages/releasing-the-deployment.html).
  8. Update the release on Github
  9. Announce the release on the mailing list
  10. To immediately publish a next snapshot, mvn -s private-settings.xml clean deploy
  11. To get the site ready, first go back to the tag, git checkout -f tags/zxing-x.y.z
  12. mvn clean site:site site:stage
  13. In a temp directory somewhere, git clone -b gh-pages https://github.com/zxing/zxing.git
  14. rm -r [temp]/*
  15. cp -r [zxing dir]/target/staging/* [temp]/
  16. In that temp dir, git add -A .
  17. git commit -m 'Update site for x.y.z'
  18. git push origin gh-pages
  19. Delete the temp dir
  20. Sync with git checkout -f master and git pull