View source | Discuss this page | Page history | Printable version   

ERP 2.50:Developers Guide/Concepts/Development Build Tasks/it

Contents

Introduzione

Questo documento discute i tasks ant usati durante il processo di build di Openbravo ERP. Spiega per cosa sono usati i tasks ant e quali proprietà possono essere usati per controllare il loro comportamento.

Principale Tasks di Build

Build-process2.png

This section explains the main build tasks following the steps as illustrated in the image.

In most of the cases it is only necessary to use 3 tasks (install.source, smartbuild and export.database). There are a number of other tasks that can be used but they are not required for the standard process, they are explained in the Detailed Build Tasks section.

The main task for the standard process is smartbuild which performs all the required processes as explained below. This task accepts two optional properties:

  1. local for local or remote developments which by default is set to yes.
  2. restart indicating if after the build process tomcat should be restarted with no as default value.

The difference between local and remote development is illustrated in the diagram on the right. Local development are changes by the developer him/herself. Remote developments are changes done by other developers. Changes by remote developments are pulled from the source code revision system.

Installazione iniziale

After downloading the Openbravo ERP source files (for example with an hg clone from mercurial). It is necessary to install and deploy it.

The first step is to properly configure all the required properties. All properties are stored in the Openbravo.properties file. This file is not in the base source but it can be easily generated from the Openbravo.properties.template. Another way to set up it in a graphical way is to execute the setup tool for the current platform which is located in config directory (run ant setup first).

After all the properties are configured the following step is to build the application from scratch and to deploy it. All this is done by the install.source task. This task creates the database, inserts sample data on it and compiles and deploys the application accordingly with the chosen deployment mode. To execute it just type in the Openbravo ERP root directory:

ant install.source

Once Openbravo ERP is up and running it is possible to develop on it. Generally, new developments should be done through modules, further explanations about how to develop modules can be found in the Modularity article.

Build

Una volta che gli sviluppi sono pronti da testare è necessario fare il build dell'applicazione. Non è necessario fare un build completo, ma solo builds incrementali, che faccia il build di quello che è stato modificato. Questo è possibile grazie al comando smartbuild :

ant smartbuild

Questo task genera e compila i sorgenti per gli elementi modificati , e, in funzione del modo di fare il deploy , ne fa anche il deploy. E' possibile riavviare tomcat dallo stesso task impostando la proprietà restart a yes:

ant smartbuild -Dlocal=yes -Drestart=yes # note the -Drestart=yes 

Esportare il Database

In most cases developments include modifications on the database. This modifications can be persisted in xml files using the DBSourceManager tool. DBSourceManager exports to xml files only the modules (including core) that are set as In Development. To export the database execute:

ant export.database

After this step the changed model xml files can be pushed/committed to the source code revision system, so that other developers can pick them up and continue working on top of it.

Modificare il database

Database model changes are distributed by committing the database schema as xml to Mercurial. Other developers pull the changes from Mercurial and can apply them to update their own database. After updating the database the process is exactly the same as the local one, that is compile and deploy the elements that have been modified since last build. All the required actions (update database, compile last modifications and deploy them) can be done with only the smartbuild command:

ant smartbuild -Dlocal=no # note the -Dlocal=no 

The only difference with the local development is in the local parameter which makes the process to update the database in case the xml files were changed.

Validare il Database

When a module is exported using the export.database task it is first validated to check for common errors. If the validation fails then the export.database task will also fail and export is not possible.

The following checks are currently done:

You can also run the validate database task directly by executing this ant task:

ant validate.database

This will check the complete database and model. Note that when the validation is done as part of the export.database task then only the tables/columns of modules which are exported are checked.

Validare il Modulo

When a module is packaged with the package.module ant task, then first it is checked for some common errors. If an error is detected then the package.module task will fail.

Specifically the following checks are done:

The module validation can be run separately through this ant task:

ant validate.modules -DmoduleJavaPackage=${javapackageofmodule}

Whereby ${javapackageofmodule} equals the java package of the module.

Testare Tasks Ant

Openbravo has a number of ant tasks for running Junit test cases. The main one is run.tests:

ant run.tests

It will run the tests which are side effect free. The test ant tasks assume that the Small Bazaar and Accounting Test clients have been installed.

Tasks di Build Dettagliate

This section contains a detailed listing of all available build tasks.

Tasks di Build Librerie

Task Description Notes Sub Tasks
core.lib Compiles and generates a .jar file from the src-core project. Which is needed by wad.lib and the rest of build tasks. Required by: wad.lib
wad.lib Compiles and generates a .jar file from the src-wad project. Which is needed by the build tasks. This project contains the WAD, the automatic window generator. Requires: core.lib, database created

Required by: compile.*

eclipse.wad.lib
trl.lib Compiles and generates a .jar file from the src-trl project. Which is needed by the translate task. This project allows to translate to different languages manual windows. Requires: core.lib eclipse.trl.lib

Tasks di Build

Task Description Notes Sub Tasks
smartbuild Makes an incremental build of the application. Including:
  • update.database
  • compile
  • deploy

All these tasks are done only if needed.

Requires:

Database must be created and populated with data. Properties:

  • local: (default to yes) when this property is set to no update.database task is executed, otherwise it is not executed.
  • restart: (default to no) if set to yes, tomcat is restarted after the build process.
  • tr: (default to yes) if set to no, translation process is not executed.
generate.entities Generates the Java files for src-gen directory, and compiles them. They are used by DAL to access to the database information. Requires:

Database must be created and populated with data.

install.source Installs the whole application: creates the database, compiles it and generates a war file to be deployed or copies the classes to Tomcat's directory (depending on the deploy.mode property set in Openbravo.properties). Calls:

create.database, core.lib, wad.lib, trl.lib, compile.complete.deploy, applyModule

eclipse.install.source: It does the same but calling the correspondent eclipse.* tasks, it does not generate the war file.
compile Generates Java classes for WAD windows, generates Java classes from modified xsql files, compiles all modified classes (including the generated ones), makes insertions in translation tables for non-existing entries for the manual UI files and copies everything to WebContent directory. Requires:

wad.lib, trl.lib, database created and populated.

Calls: translate

Properties:

  • tab: specifies the window name(s) to be generated, to specify more than one window add them as a list of comma separated values.
  • tr: if set to "no" it will not call the translation process.
  • module: a list of comma separated javapackages of modules to generate just the windows containing objects for those modules.
  • compile.src: it does the same as compile but without generating WAD windows.
  • compile.development: it also copies the files to the tomcat's context.
  • eclipse.compile: It does the same as compile but making eclipse to build the Java files if called from Eclipse. If it is called from command line a BUILD FAILED will be raised at the end of the process because it is trying to invoke the Eclipse builder.
  • compile.complete: It does the same as compile but before removes all the generated and built files, so the whole application is built. Note do not use tab or module properties because the application will be partially rebuilt.
  • compile.complete.development: The same as compile.complete but after the process copies all the generated classes to the tomcat's context.
  • eclipse.compile.complete: The same as compile.complete but calling Eclipse to do the compilation of generated classes.
  • compile.deploy: The same as compile or compile.development, depending on how the deploy.mode property in the Openbravo.properties file is set.
  • compile.complete.deploy: The same as a compile.complete or compile.complete.development, depending on how the deploy.mode property in the Openbravo.properties file is set.
translate Checks in the manual windows User Interface files the translateable elements that have not been yet registered and registers them, this is necessary to be able to translate those interfaces to different languages. Requires:

trl.lib

Called by: This task is called by the compile.* tasks in case the tr property is not set to "no"

war Generates a war file from the existing built code. In fact it only zips the application in a single war file. Requires:

compile.*: the application must be built before calling this task.

deploy.context Deploy the existing war file in the tomcat context using the tomcat manager. Requires:
  • war file must be created.
  • Tomcat manager must be running
  • These properties must be properly set in the Openbravo.properties file:
    • tomcat.manager.url
    • tomcat.manager.username
    • tomcat.manager.password

Tasks di Database

Task Description Notes Sub Tasks
update.database Synchronizes database with the current database xml files. By default it checks that no changes in application dictionary in database are done, if so the process stops. Properties:
  • module: A list of module javapackages. This properties only affects to the update.database.mod task. If set only the list of modules will be updated.
  • apply.on.create: If set to "true" in case the are modules they will be applied, otherwise they will be set as "In process" status.
  • force: (default as false) Do not check for database modification and update directly. This can cause lose of database data.
  • onlyIfModified: (default false except for smartbuild) checks the xml files and updates only if there are modifications since last db synchronization.
  • update.database.mod: Updates only a list of modules (module property required).
  • update.database.structure: Updates only the database structure but not the data.
  • update.database.script: It is the same as update.database.structure but does not modify the database. It only generates a sql script file with the statements that would be executed by the other tasks.
create.database Creates the database from the xml files, note that the database is first removed.

If the apply.on.create property is set, masterdata and sampledata will be inserted in the database. If not, only sourcedata will be inserted.

Properties:
  • apply.on.create: If is set to "true" and there are modules they will be applied, otherwise they will be set as "In process" status.
  • create.database.structure: Creates only the structure without data.
  • create.database.script: The same as create.database.structure but does not affect the database it only generates the sql script file with all the statements that would be executed by the other tasks.
export.database Synchronizes xml files with the database current contents. By default they are only exported in case there are modifications in the database. In addition performs database validations for the modules which are exported. Properties:
  • module: A list of module javapackages. The modules specified in the list that are set in development will be exported. If a list is not provided, then all modules set in development will be exported.
  • force: (default to false) Forces exportation even if there are no changes in the database.
  • export.database.structure: It only modifies the model files but not the data ones.
  • export.database.data: Exports only data but not the model.

Moduli

Task Description Notes Sub Tasks
apply.modules Applies the installed but not applied modules, that is: it updates the database for them, imports reference data in case they contain it, set them in installed status, compiles the required windows and generates a war file for the application. Properties:

module: A list of module javapackages to apply.

package.module Validates the module and if no errors are found generates the obx file for the module. Properties
  • Module: Java package for the module to extract.
  • obx.export.RD: If set to true the reference data is exported for the modules (if it has), by default is false.
  • obx.export.DB: If set to true the database is exported for the modules, by default is false.
  • obx.export.CS: If set to true the configuration script is exported (in case there is an active template), by default is false.
package.core Creates a new obx file with the current source files. To execute this task it is necessary to be in a mercurial workspace. Properties
  • calculate.core.revision: When this property is true the minor revision is calculated taking into account the local number for the last changeset in the repository (summing 10000 to it). If it is false the version is the one in the xml files. By default it is true.
export.config.script Generates the configuration script for the current active template (if any).

Tasks di Test

Task Description
run.tests The default, it runs the suite: org.openbravo.test.AntTaskTests. These tests are side effect free and can be run multiple times, after the run the database should be in the same state as before.
run.quick.tests This task runs test cases which are fast and which test the most important parts of the system. It runs the test suite: org.openbravo.test.AllQuickAntTaskTests.
run.all.tests Runs the suite org.openbravo.test.AllAntTaskTests. This suite contains all the test cases, also tests which can change the database.


Retrieved from "http://wiki.openbravo.com/wiki/ERP_2.50:Developers_Guide/Concepts/Development_Build_Tasks/it"

This page has been accessed 9,143 times. This page was last modified on 14 June 2011, at 11:03. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.