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 various important source directories underneath: "appn"/"appnEE", "engine"/"adminengine" 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 CheckoutAction.java.

The "appnEE" directory tree holds the Business or Enterprise-only java source for the actions, the forms, the module super-classes and other customisable classes such as LDAPMgr.java.

The "appEngEE" directory tree holds all of the java classes required to create the KKAppEng "Application Engine" - only available in the Business or Enterprise Editions.

The "engine" directory tree holds all of the java classes required to create a "custom engine" for KKEngIf.

The "adminengine" directory tree holds all of the java classes required to create a "custom engine" for KKAdminIf.

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

The "batch" directory tree holds a selection of example batch jobs that you can modify to suit your own needs.

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 "lib" directory contains jars for ant builds.

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/kkant 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:\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_custom_admin_service_classes       Clears away the generated custom admin service 
                                          artifacts
 clean_custom_admin_service_classes_json  Clears away the generated custom admin service  
                                          artifacts
                                          - JSON
 clean_custom_store_service_classes       Clears away the generated custom store service  
                                          artifacts
 clean_custom_store_service_classes_json  Clears away the generated custom store service  
                                          artifacts
                                          - JSON
 clean_liferay_sso_jar                    Clean the KonaKart Liferay SSO classes and jar
 clean_manifest_file                      Clean the MANIFEST file for all jars
 clean_portlet_war                        Clears away the portlet war
 clean_torque_classes                     Clears away the generated torque artifacts
 clean_wars                               Clears away all the WARs and EARs
 compile                                  Compile the customisable application code
 compile_admin_portlet_liferay            Compile the Admin portlet utilities for Liferay
 compile_adminappn                        Compile the customisable admin appn code
 compile_adminappnEE                      Compile the customisable admin appnEE code
 compile_appEngEE                         Compile the customisable appEngEE code
 compile_appn                             Compile the customisable appn code
 compile_appnEE                           Compile the customisable appnEE code
 compile_customAdminService               Compile the Custom Admin Service code
 compile_customAdminService_json          Compile the Custom Admin Service code including JSON
 compile_customStoreService               Compile the Custom Store Service code
 compile_customStoreService_json          Compile the Custom Store Service code - including JSON
 compile_custom_adminengine               Compile the customisable admin engine code
 compile_custom_engine                    Compile the customisable engine code
 compile_konakartadmin_app                Compile the konakartadmin_app code
 compile_modules                          Compile the customisable module code
 compile_utils                            Compile the customisable utils code
 copy_jars                                Copy selected custom konakart jars to the lib  
                                          directories
 create_konakartadmin2                    Create the konakartadmin2 webapp
 create_torque_classes                    Process the Custom Schema to produce torque classes
 debugenv                                 Debug the environment
 deploy_customAdminService                Deploys the Custom Admin Service
 deploy_customDB                          Deploys the Custom Database Jar
 deploy_customStoreService                Deploys the Custom Store Service
 enable_ERPIntegration                    Enable ERP Integration - EE Only
 
 .. continued below
 


 enable_JAXWS                             Enable JAX Web Services in konakart web.xml - BE or
                                          EE Only
 enable_JSON                              Enable JSON in konakart web.xml - BE or EE Only
 enable_JSON_CAS                          Enable JSON Custom Admin Service in konakartadmin 
                                          web.xml - BE or EE Only
 enable_JSON_CSS                          Enable JSON Custom Store Service in konakart web.xml 
                                          - BE or EE Only
 enable_KKAdmin_JAXWS                     Enable JAX Web Services in konakartadmin web.xml - 
                                          BE or EE Only
 enable_KKAdmin_JSON                      Enable KKAdmin JSON in konakartadmin web.xml - BE or 
                                          EE Only
 enable_KKAdmin_RMI                       Enable KKAdmin RMI in konakartadmin web.xml - EE Only
 enable_KonaKart_Messenger                Enable KonaKart Messenger in konakart web.xml - EE Only
 enable_MQ                                Enable MQ in konakart web.xml
 enable_RMI                               Enable RMI in konakart web.xml - EE Only
 execute_sql_file                         Execute the specified SQL file
 generate_customAdminService              Builds the Custom Admin Service code
 generate_customAdminService_json         Builds the Custom Admin Service code - JSON
 generate_customStoreService              Builds the Custom Store Service code
 generate_customStoreService_json         Builds the Custom Store Service code - JSON
 generate_torque_java                     Process the Custom Schema to produce torque java files
 load_custom_mago_sql                     Load the Custom Mago SQL commands
 load_mago_sql                            Load the Mago SQL commands
 mago_debugenv                            Debug the Mago Set-up environment
 mago_setup                               Sets up the Integration with Mago
 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 Struts-2
                                          Storefront
 make_eclipse_wizard_project              Create an Eclipse Project for Developing the Product 
                                          Creation Wizard
 make_jar_appEngEE                        Create the konakart_app jar
 make_jar_custom                          Create konakart_custom jar
 make_jar_customAdminService              Create the konakartadmin_custom_admin_service jar
 make_jar_customDB                        Create the konakart_custom_db jar
 make_jar_customEE                        Create the konakart_customEE jar
 make_jar_customStoreService              Create the konakart_custom_store_service jar
 make_jar_custom_admin                    Create the konakartadmin_custom jar
 make_jar_custom_adminEE                  Create the konakartadmin_customEE jar
 make_jar_custom_adminengine              Create the konakartadmin_custom_engine jar
 make_jar_custom_engine                   Create the konakart_custom_engine jar
 make_jar_custom_utils                    Create the konakart_custom_utils jar
 make_jar_konakartadmin_app               Create the konakartadmin_app jar
 make_jars                                Create the konakart custom jars
 make_liferay_portlet_war                 Create the KonaKart portlet war for Liferay
 make_liferay_portlet_wars                Create the KonaKart and KonaKartAdmin portlet wars for 
                                          Liferay
 make_liferay_sso_jar                     Create the KonaKart Liferay SSO jar
 make_manifest_file                       Create the MANIFEST file for all jars
 make_ordertotal_module_jar               Create the ordertotal module jar
 make_other_module_jar                    Create the other module jar
 make_payment_module_jar                  Create the payment module jar
 make_shipping_module_jar                 Create the shipping module jar
 make_wars                                Create the konakart wars
 print_classpaths                         Print the classpaths for diagnostic purposes
 print_custom_classpath                   prints the specified classpath
 reset_database                           Removes the default KonaKart database set-up
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-286 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 (Community version with default Struts-2 storefront):


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

debugenv:
     [echo] custom.home              = C:\KonaKart\custom
     [echo] java.source              = 1.8
     [echo] java.target              = 1.8
     [echo] debug_javac              = on
     [echo] torque.build.present     = ${torque.build.present}
     [echo] adminappn.code.present   = true
     [echo] adminappnEE.code.present = ${adminappnEE.code.present}
     [echo] adminengine.code.present = true
     [echo] appn.code.present        = true
     [echo] appnEE.code.present      = ${appnEE.code.present}
     [echo] engine.code.present      = true
     [echo] utils.code.present       = true
     [echo] excludeAXIS              = ${excludeAXIS}
     [echo] noClean                  = ${noClean}

clean_torque_classes:

clean_portlet_war:
     [echo] Cleanup portlet WARs...
     [echo] Cleanup portlet classes...
     [echo] Cleanup portlet WAR staging area...

clean_admin_portlet_war:
     [echo] Cleanup admin portlet WARs...
     [echo] Cleanup admin portlet WAR staging area...

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

clean:
     [echo] Cleanup...

generate_torque_java:

create_torque_classes:

make_manifest_file:
     [echo] Create the MANIFEST.MF file for all jars

compile:
     [echo] Compile the customisable application code

compile_appn:
     [echo] Copy the properties over to C:\KonaKart\custom/appn/classes
     [copy] Copying 3 files to C:\KonaKart\custom\appn\classes
     [echo] Compile the customisable application code
    [javac] Compiling 133 source files to C:\KonaKart\custom\appn\classes

compile_appnEE:

compile_appEngEE:

compile_adminappn:
    [mkdir] Created dir: C:\KonaKart\custom\adminappn\classes
    [javac] Compiling 10 source files to C:\KonaKart\custom\adminappn\classes

compile_adminappnEE:

compile_utils:
     [echo] Compile the customisable utils code
    [mkdir] Created dir: C:\KonaKart\custom\utils\classes
    [javac] Compiling 3 source files to C:\KonaKart\custom\utils\classes




continued...


continued from above...

compile_modules:
     [echo] Compile the customisable module code
    [mkdir] Created dir: C:\KonaKart\custom\modules\classes
    [javac] Compiling 149 source files to C:\KonaKart\custom\modules\classes

make_payment_module_jar:
     [echo] Create the payment module jar
    [mkdir] Created dir: C:\KonaKart\custom\jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakart_payment_authorizenet.jar

make_payment_module_jar:
     [echo] Create the payment module jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakart_payment_elink.jar


	-- other payment, order total and shipping module builds removed


compile_custom_engine:
     [echo] Compile the customisable engine code
    [mkdir] Created dir: C:\KonaKart\custom\engine\classes
    [javac] Compiling 241 source files to C:\KonaKart\custom\engine\classes

compile_custom_adminengine:
     [echo] Compile the customisable admin engine code
    [mkdir] Created dir: C:\KonaKart\custom\adminengine\classes
    [javac] Compiling 440 source files to C:\KonaKart\custom\adminengine\classes

make_jars:
     [echo] Create the konakart custom jars

make_jar_custom:
     [echo] Create the konakart_custom.jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakart_custom.jar

make_jar_customEE:

make_jar_custom_engine:
     [echo] Create the konakart_custom_engine.jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakart_custom_engine.jar

make_jar_appEngEE:

make_jar_custom_utils:
     [echo] Create the konakart_custom_utils.jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakart_custom_utils.jar

make_jar_custom_admin:
     [echo] Create the konakartadmin_custom.jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakartadmin_custom.jar

make_jar_custom_adminEE:

make_jar_custom_adminengine:
     [echo] Create the konakartadmin_custom_engine.jar
      [jar] Building jar: C:\KonaKart\custom\jar\konakartadmin_custom_engine.jar

make_torque_jar:

build:

BUILD SUCCESSFUL

Note that from KonaKart v6.5.0.0 the default storefront uses Struts-2. Previous versions of the ANT build file required that if you had installed the Struts-1 storefront you needed to add the "-DS1=true" parameter to most of the custom ANT commands. This ANT parameter is no longer supported beyond v6.6.0.0 of KonaKart.

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 Struts-2 storefront application conveniently in the rich development environment provided by Eclipse.

In earlier versions of the ANT build file a similar "make_eclipse_project_s1" command existed for creating an Eclipse project for working on the Struts-1 storefront. This only worked if you had installed the Struts-1 version of the storefront. This ANT target is no longer included beyond v6.6.0.0 of KonaKart.

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


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

make_eclipse_project:
     [echo] Create an Eclipse Project for Developing the Struts-2 Storefront
    [mkdir] Created dir: C:\Bob\KonaKart\custom\appEngEE\src
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\src
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\build\classes
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\licenses
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\resources
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\WebContent
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\src\com\konakart\bl\modules\others
    [mkdir] Created dir: C:\Bob\KonaKart\custom\kkeclipse\src\com\konakartadmin\modules\others
     [copy] Copying 2 files to C:\Bob\KonaKart\custom\kkeclipse
     [copy] Copying 748 files to C:\Bob\KonaKart\custom\kkeclipse\src
     [copy] Copying 18 files to C:\Bob\KonaKart\custom\kkeclipse\resources
     [copy] Copying 1 file to C:\Bob\KonaKart\custom\kkeclipse\licenses
     [copy] Copying 672 files to C:\Bob\KonaKart\custom\kkeclipse\WebContent
     [echo] -----------------------------------------------------------------------------------
     [echo] Eclipse Project Created on disk - called kkeclipse
     [echo] Start Eclipse
     [echo] Create a tomcat server (see 'Servers' in Eclipse)
     [echo] Move the kkeclipse directory to another location for development if you wish
     [echo] Import the kkeclipse project using 'Import existing projects into Workspace'
     [echo] Assign a server for kkeclipse to use (define server under Project Properties)
     [echo] Edit, Debug and Run the KonaKart Storefront in Eclipse!
     [echo] -----------------------------------------------------------------------------------

BUILD SUCCESSFUL

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.

Developing the Product Creation Wizard in Eclipse

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

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


C:\KonaKart\custom>ant make_eclipse_wizard_project
Buildfile: build.xml

make_eclipse_wizard_project:
     [echo] Create an Eclipse Project for Developing the Product Creation Wizard
     [copy] Copying 56 files to C:\Bob\KonaKart\custom\kkeclipseWizard
     [copy] Copying 213 files to C:\Bob\KonaKart\custom\kkeclipseWizard\WebContent
     [echo] -----------------------------------------------------------------------------------
     [echo] Eclipse Product Creation Wizard Project Created on disk - called kkeclipseWizard
     [echo] Start Eclipse
     [echo] Create a tomcat server (see 'Servers' in Eclipse)
     [echo] Move the kkeclipseWizard directory to another location for development if you wish
     [echo] Import the kkeclipseWizard project using 'Import existing projects into Workspace'
     [echo] Assign a server for kkeclipseWizard to use (define server under Project Properties)
     [echo] Edit, Debug and Run the KonaKart Product Creation Wizard in Eclipse!
     [echo] -----------------------------------------------------------------------------------

BUILD SUCCESSFUL

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

As for the kkeclipse storefront project you have to create the "Server" that you wish to run the kkeclipseWizard 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.