User defined configuration parameters with OpenPetra.build.config

From OpenPetra Wiki
Revision as of 13:02, 26 October 2011 by Joejoe2010 (talk | contribs)
Jump to navigation Jump to search

You can define your own local (installation-specific) configuration settings such as

  • database and credentials you use
  • local paths for tools, etc.

All the configuration options are set in NAnt build files, which are just simple xml files. Just create a file OpenPetra.build.config in your OpenPetra root directory (the same directory you find the file OpenPetra.build in). As the contents will be different for each developer, it has aleady been marked in bazaar that it shall be ignored by version-control.

The shortest PostgreSQL-example for OpenPetra.build.config for windows (If you use standard parameters ...):

<?xml version="1.0"?>
<project name="OpenPetra-userconfig">
    <property name="DBMS.Type" value="postgresql"/>
    <property name="PostgreSQL.exe" value="C:\Program Files/PostgreSQL/9.0/bin/psql.exe"/>
    <property name="pgdump.exe" value="C:\Program Files/PostgreSQL/9.0/bin/pg_dump.exe" overwrite="false"/>
    <property name="projectfiles.templates-list" value="sharpdevelop3"/>
</project>

For Linux it would be: <?xml version="1.0"?> <project name="OpenPetra-userconfig">

   <property name="DBMS.Type" value="postgresql"/>
   <property name="projectfiles.templates-list" value="sharpdevelop3"/>

</project>

A more complex example:

<?xml version="1.0"?>
<project name="OpenPetra-userconfig">
    <property name="DBMS.Type" value="postgresql"/>
    <property name="PostgreSQL.exe" value="C:\Program Files/PostgreSQL/9.0/bin/psql.exe"/>
    <property name="pgdump.exe" value="C:\Program Files/PostgreSQL/9.0/bin/pg_dump.exe" overwrite="false"/>
    <property name="DBMS.DBName" value="myopenpetradb"/>
    <property name="DBMS.UserName" value="myusername"/>
    <property name="DBMS.Password" value="secret"/>
    <property name="projectfiles.templates-list" value="sharpdevelop3"/>
</project>

An example for SQLite (note: empty password required on Windows):

<?xml version="1.0"?>
<project name="OpenPetra-userconfig">
    <property name="DBMS.Type" value="sqlite"/>
    <property name="DBMS.Password" value=""/>
    <property name="projectfiles.templates-list" value="sharpdevelop3"/>
</project>

Important: after you changed any settings in the config-file, you have to run "nant initConfigFiles".

Explanation of the above example:

  • Database-System: this developer wants to work with PostgreSQL instead of the default SQLite. Therefore you must set the DBMS.Type property.
  • File-Locations: Usually, the psql.exe and pg_dump.exe are located by default in the Program Files directory, but in the case of 64bit Windows, the default Program Files directory for nant is "Program Files (x86)", where Postgresql is not installed in my case.
  • Database: You have the option to define a different database, it's user and password
  • projectfiles.templates-list: if you are only using SharpDevelop anyway, there is no need to create project files and solution file(s) for Visual Studio. By default, project files are generated for both IDEs.

Finding changeable properties

Check this configuration file where the default settings are set:

  • inc\nant\OpenPetra.common.xml

Just browse this file and find the properties you need to fit your configuration. Just copy the property into OpenPetra.build.config and alter it's value appropriately.