Skip to content

SolarNode Build Guide

Matt Magoffin edited this page Aug 29, 2016 · 1 revision

If you haven't read the Building SolarNetwork applications page, please read that and then return here.

Building individual bundles

Each bundle includes an Ant build script with the following targets:

target Description
clean Delete any build artifacts.
jar Compile the bundle classes and assemble into a JAR file.
src-jar Assemble a JAR with the bundle's source files.
publish Publish the binary and source JARs to the SolarNetwork repository.

Build the SolarNode base Equinox system

A SolarNode base system is a package of bundles and configuration files organized in a way that forms a minimal SolarNode application. You must build a base system at least once, and afterwards you can skip this part when you just want to deploy new or updated feature bundles to your SolarNode system. The Equinox base system is a SolarNode application that runs on the Eclipse Equinox OSGi container.

Base system dependencies

You must create a equinox/ivy.xml file to pull in the necessary dependencies for the base system to run. Copy the equinox/example/ivy.xml file to equinox/ivy.xml as a starting point. Most likely you can use this copy without making any modifications.

Base system build properties

You can modify some of the settings in the generated base system by creating a equinox/build.properties file, using the following (an example file exists in equinox/example):

Property Value Default
log.file Path to the SolarNode application log file. /run/shm/solar/log/solarnode.log

Building the base system

To build the base system, run the archive task on the equinox/build.xml Ant script. For example:

$ cd solarnetwork-build/solarnode-deploy/equinox
$ ant archive

Buildfile: build.xml

assemble-prepare:

app-boot:

ivy-init:

app-main:
[ivy:resolve] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
...
archive:
	  [tar] Building tar: build/base-equinox-node.tgz

BUILD SUCCESSFUL
Total time: 3 seconds

That produces the equinox/build/base-equinox-node.tgz archive, which you can then expand into the directory you want to run the SolarNode application from. For example:

$ cd ~solar
$ tar xzf /tmp/base-equinox-node.tgz

That will result in a base system directory structure like this:

<SolarNode home>
|
+-- app/
| |
| +-- base/
| +-- boot/
| +-- core/
| +-- main/
|
+-- bin/
+-- conf/
|  |
|  +-- services/
|  +-- tls/
|
+-- var/

Running the base system

The system starts up bundles in stages. The stages, which are divided into directories, and the order they are loaded, are:

  1. app/boot - low level supporting bundles started directly by Equinox via conf/config.ini
  2. app/core - application supporting bundles started directly by Equinox via conf/config.ini
  3. conf/services - configuration properties files started dynamically by Felix FileInstall
  4. app/base - application core bundles, started dynamically by Felix FileInstall
  5. app/main - application bundles, started dynamically by Felix FileInstall

The app/base and app/main directories are populated with bundles created by the application setup script, discussed later on.

You can start up the base system to verify it runs correctly (note that the version number of the latest org.eclispse.osgi jar file is likely to have changed since these instructions were written, check what version number you have and update appropriately during execution). From the base system directory, execute:

$ java -Xmx48m -Dsn.home=${PWD} -Dderby.system.home=${PWD} \
	-Dsolarnetwork.pidfile=/tmp/solarnode.pid -jar \
	app/org.eclipse.osgi-3.8.1.v20120830-144521.jar \
	-configuration conf -console 4202 -clean
Listening on port 4202 ... 
PID file created: /tmp/solarnode.pid
-> DEBUG: EventAdmin: org.apache.felix.eventadmin.CacheSize=30
DEBUG: EventAdmin: org.apache.felix.eventadmin.ThreadPoolSize=10
DEBUG: EventAdmin: org.apache.felix.eventadmin.Timeout=5000
DEBUG: EventAdmin: org.apache.felix.eventadmin.RequireTopic=true
Nov 1, 2012 10:48:10 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Nov 1, 2012 10:48:10 AM org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
Nov 1, 2012 10:48:10 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Nov 1, 2012 10:48:10 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
Nov 1, 2012 10:48:10 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080

Here you can see the base system started up. You can also inspect the system log file, which is located at the path specified by the log.file build property when you built the base system.

Assemble a SolarNode application

Once you've set up a base Equinox system, you'll run the archive task of the generic/build.xml Ant build script. This task will assemble the necessary SolarNode bundles tailored specifically for the components you need to deploy to your node.

Application build properties

You must create a generic/ivy.xml file that specifies what SolarNode bundles you want to include in your application. Copy the generic/example/ivy.xml file to generic/ivy.xml as a starting point. Add <dependency/> elements as needed to add in the bundles you want to deploy. For example, to support collecting power data from an EnaSolar inverter, you'd want to add:

<dependency org="net.solarnetwork.node" name="net.solarnetwork.node.power.dao.jdbc" rev="latest.release"/>
<dependency org="net.solarnetwork.node" name="net.solarnetwork.node.power.enasolar.ws" rev="latest.release"/>

Building the application

To build the base system, run the archive task on the generic/build.xml Ant script. For example:

$ cd solarnetwork-build/solarnode-deploy/generic
$ ant archive

Buildfile: build.xml

ivy-init:

prepare:
	[mkdir] Created dir: build/assemble
	[mkdir] Created dir: build/jars

jars:
[ivy:resolve] :: Apache Ivy 2.3.0 - 20130110142753 :: http://ant.apache.org/ivy/ ::
	...

archive:
	  [tar] Building tar: build/node-bundles.tgz

BUILD SUCCESSFUL
Total time: 20 seconds

That produces the generic/build/node-bundles.tgz archive, which you can then expand into the directory you want to run the SolarNode application from. For example:

$ cd ~solar
$ tar xzf /tmp/node-bundles.tgz

Other tasks

The clean task will delete the assembled build files from the generic/build directory.

The assemble task assembles the deployable bundles into the generic/build/assemble directory, without the last step of archiving them into a tarball that the archive task does.

Summary

To sum all of this up briefly, once you have the build properties and Ivy configuration files configured, the following steps can be used to perform a clean build:

cd solarnetwork-build
git pull

# create the solarnode-deploy/equinox/build/base-equinox-node.tgz archive
cd solarnode-deploy/equinox
ant clean archive

# create the solarnode-deploy/generic/build/node-bundles.tgz archive
cd ../generic
ant clean archive
Clone this wiki locally