Customizable Source Code

Not all of KonaKart source code is provided in the download kits, only the parts designed to be customized. These include:

Source Code Location

Once you have installed KonaKart you will be able to study the customizable source code in the following locations:

KonaKart Customizable Source Code

You will find all the java sources and associated properties files under the "custom" directory in every download kit from KonaKart version 2.2.1.0 and above. (These source files were available in previous releases but structured slightly differently). In the future, more directories will be added under the custom directory as more customizable source is made available - so don't be surprised if the directory structure that you see is different to the one on the left.

The "custom" directory is located directly under the installation directory that was selected for KonaKart.

The "custom" directory has two main source directories underneath: "appn" and "modules".

The "appn" directory tree holds the java source for the actions, the forms, the module super-classes and other customisable classes such as AdminOrderIntegrationMgr.java.

The "modules" directory tree holds all of the java classes required to implement each of the modules.

An ant build file (build.xml) can be found at the root of the custom directory.

The "bin" directory under custom contains a cut-down ant that is sufficient to build all of the custom code - all you need is to set JAVA_HOME to your JDK.

The "custom/lib" directory contains jars for ant.

Once you have executed an ant build you will see a few more directories under "custom" which are the products of the build process. For example, you will see classes directories, a new jar directory etc. To remove the files and directories produced by the build you can execute the "clean" target of the ant build, eg:

$ bin/ant clean

Building the Customizable Source

An ant file is provided that should make it easy to build the customizable java classes. Use "kkant -p" to see the ant command targets:


C:\Program Files\KonaKart\custom>bin\kkant -p
Buildfile: build.xml

Main targets:

 build                           Compiles all the custom code and creates all the jars
 clean                           Clears away everything that's created during a build
 clean_admin_portlet_war         Clears away the admin portlet war
 clean_manifest_file             Clean the MANIFEST file for all jars
 clean_portlet_war               Clears away the portlet war
 clean_torque_classes            Clears away everything that's created during a build of 
                                 the torque classes
 clean_wars                      Clears away all the WARs and EARs
 compile                         Compile the customisable application code
 compile_custom_adminengine      Compile the customisable admin engine code
 compile_custom_engine           Compile the customisable engine code
 compile_modules                 Compile the customisable module code
 compile_utils                   Compile the customisable utils code
 copy_jars                       Copy the konakart custom jars to the lib directories
 create_torque_classes           Process the Custom Schema to produce torque classes
 enableWebServices               Enable Web Services in deployed server
 generate_torque_java            Process the Custom Schema to produce torque java files
 make_admin_liferay_portlet_war  Create the konakartadmin portlet war for Liferay
 make_ear                        Create the konakart EAR
 make_eclipse_project            Create an Eclipse Project for Developing the Storefront
 make_jars                       Create the konakart custom jars
 make_liferay_portlet_war        Create the konakart portlet war for Liferay
 make_manifest_file              Create the MANIFEST file for all jars
 make_ordertotal_module_jar      Create the ordertotal module jar
 make_payment_module_jar         Create the payment module jar
 make_shipping_module_jar        Create the shipping module jar
 make_torque_jar                 Create the konakart custom torque jar
 make_wars                       Create the konakart wars
Default target: build
 

Notice that the default build target compiles all the source files and creates the jars. It doesn't move the jars or create any wars.

If after building the jars you wish to move these to your webapp lib directories you should use the "copy_jars" target.

The "make_wars" target is just a convenient means of creating wars out of the KonaKart webapps. It is not required to be run to build and deploy the custom code so it's not closely-related to the topics discussed on this page.

The "make_*_portlet_war" targets are for creating JSR-168 compliant WARs out of your current KonaKart application. See the section of this documentation regarding portlets for more details.

Here is an example of running the default ant target:


$ ~/konakart/custom$ ./bin/ant
Buildfile: build.xml

clean_wars:
     [echo] Cleanup WARs...
     [echo] Cleanup EARs...
     
clean:
     [echo] Cleanup...

compile:
     [echo] Compile the customisable application code
    [mkdir] Created dir: /home/pete/konakart/custom/appn/classes
    [javac] Compiling 104 source files to /home/pete/konakart/custom/appn/classes

compile_modules:
     [echo] Compile the customisable module code
    [mkdir] Created dir: /home/pete/konakart/custom/modules/classes
    [javac] Compiling 50 source files to /home/pete/konakart/custom/modules/classes

make_payment_module_jar:
     [echo] Create the module jar
    [mkdir] Created dir: /home/pete/konakart/custom/jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_payment_authorizenet.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_payment_chronopay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_payment_cod.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_payment_payjunction.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_payment_paypal.jar


-- some of the modules have been excluded from this output --


make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_shipping_free.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_shipping_item.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_shipping_table.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_shipping_zones.jar

make_jars:
     [echo] Create the konakart_custom.jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakart_custom.jar
     [echo] Create the konakartadmin_custom.jar
      [jar] Building jar: /home/pete/konakart/custom/jar/konakartadmin_custom.jar

build:

BUILD SUCCESSFUL
Total time: 8 seconds

Developing the Storefront in Eclipse

The custom ant file contains a target ("make_eclipse_project") that will create an Eclipse project that will allow you to develop the storefront application conveniently in the rich development environment provided by Eclipse.

Some notes are provided after the Eclipse project is created as follows:


C:\Program Files\KonaKart\custom>bin\kkant make_eclipse_project
Buildfile: build.xml

make_eclipse_project:
     [echo] Create an Eclipse Project
     [echo] -----------------------------------------------------------------------------------
     [echo] Eclipse Project Created on disk - called kkeclipse
     [echo] Start Eclipse
     [echo] Create a tomcat server (see 'Servers' in Eclipse)
     [echo] Import the custom/kkeclipse project using 'Import existing projects into Workspace'
     [echo] Assign a server for kkeclipse to use
     [echo] Edit, Debug and Run the KonaKart Storefront in Eclipse!
     [echo] -----------------------------------------------------------------------------------

BUILD SUCCESSFUL
Total time: 16 seconds

You can copy the kkeclipse directory to another location before importing into Eclipse if that is more convenient.

You have to create the "Server" that you wish to run the kkeclipse project in. In theory you can choose any server that is supported by Eclipse.

You may have to make one or two modifications to your Eclipse project settings depending on your own environment.