Skip to content

Building bb4 Projects

Barry G Becker edited this page Oct 2, 2016 · 89 revisions

These are detailed instructions on how to build bb4 projects.

Prerequisites

If you have not already done so, install the following

  • Java SE Development Kit (JDK). Make sure you get the 1.7 JDK (not the JRE) or later. After installing set the JAVA_HOME environment variable to point to the install location. Setting JAVA_HOME is not strictly necessary, but it will save you from having to tell Intellij where it is later.
  • Git - When installing, you should be able to just accept all the defaults. Though not required, you should consider creating your own GitHub account. I think it is simpler to install Git instead of the Windows GitHub app, though both should work - since GitHub has git.exe, but it puts it in a strange place.
  • The bb4 projects now use the Gradle wrapper, so gradle does not have to be explicitly installed.
  • Intellij IDEA - The free community edition is fine. Eclipse will work also, but Intellij is a better IDE.

Building

Once you have the prerequisites, these are the steps to build.

  1. Clone the git repository using a command like git clone https://github.com/barrybecker4/bb4-common.git You can also clone using the Windows GitHub app, if you have it, or clicking the "clone to desktop" button in GitHub.
  2. Run "gradle build" at the root. This will compile and test all the code.
  3. Run "gradle tasks" to see what tasks are available. If it is not a library project, there should be tasks that will run applications directly. Also try running "gradle --gui" to open an application showing all gradle tasks.
  4. If you want to view and edit files in Intellij, run "gradle idea". Next, open Intellij IDEA and open the top level folder containing the bb4 project. It is also possible to open the project by just to opening the build.gradle file in Intellij. If you see a message about an unregistered git root, this is easy to fix, by just clicking "configure" and adding the root. All gradle tasks can be run from within Intellij (using Gradle window on the right). It's possible that you will have to configure gradle in Intellij initially. To do so, point the gradle project to the build.gradle file, and check the option to use the gradle wrapper. Also set the service directory to <path to bb4 project>/.gradle.

Releasing New Versions

  • Each module is versioned. During development, SNAPSHOT versions are used.
  • When ready to release, remove the -SNAPSHOT suffix from the version (in gradle file) and push the artifacts to the Sonatype maven repository for general consumption (if you have the authorization to do so - see below). Once the staged jars have been published they need to be promoted on Sonatype. Under staging repositories, look for com.barrybecker4. Close it in order do validation, then release it to the wild if everything is OK.
  • Prior to release, while SNAPSHOTs are being used, the flow will go something like this: When you need to update one of the framework modules (e.g. core, ui, etc) use
    gradle clean build publishArtifacts --info
    to build and publish the SNAPSHOT version. Then to build the downstream dependent module(s) use
    gradle clean build idea --refresh-dependencies
    The idea task will rebuild Intellij project files, and --refresh-dependencies ensures that you get the artifact just deployed and not a cached version.

Additional notes

  • If you are an admin and have permissions to release new versions (rare), then you will need to specify your credentials in a ~/.gradle/gradle.properties files. This file should not be checked into version control. The contents are in KeyPass and the secring.gpg is in box.net.
  • Intellij hints
    • If you change gradle configuration, you may need to run "gradle cleanIdea idea" to make sure Intellij configuration is up to date.
    • Update Project Structure | Project SDK so that the JDK points to the install location of your JDK. This usually happens automatically.
    • In Intellij | project structure, select SDK and compiler output path to be something like "output".
    • If there are red errors in the code, go into project structure | libraries. Select them all and do right click "add to modules".
    • In Intellij | settings |compiler, verify ?*.au is in the patterns list, and -ea (enable assertions) is in the JVM param list.
    • All runnable classes can be run or debugged from within Intellij by right clicking on them.
  • Linux tips:
    • Install oracle java. As root, save or move the downloaded jdk1.7.tar.gz to the installation location (e.g. /usr/local/java). Install with tar -xzvf jdk1.7.tar.gz.
    • Install Intellij community edition. As root, save or move the downloaded idealC-.tar.gz to the installation location (e.g. /usr/local/IDEA). Install with tar -xzvf idealC-.tar.gz.
    • Set JAVA_HOME and add to path. Most applications that use java will look for it in JAVA_HOME. Adding executables to your path means you can run them without specifying the full path. Try adding the following to your ~/.bashrc file and then run source .bashrc. Make sure the locations and jdk version match what you have installed.
      export JAVA_HOME=/usr/local/java/jdk1.7.0_45 export PATH=$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin:/usr/local/IDEA/idea-IC-129.1359/bin:$PATH
    • If it says you do not have permission to execute a file, as root, enter "chmod +x " to add executable permission.
    • If using cygwin you may need to run "dos2unix" on the gradlew file before it will work.
  • Contact barrybecker4<at>yahoo.com if you have questions or comments.

Clone this wiki locally