Setup of Development environment: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
No edit summary
Line 15: Line 15:
* [[Setup of Development Environment for Mandriva]]
* [[Setup of Development Environment for Mandriva]]
* [[Setup of Development Environment for MacOS]]
* [[Setup of Development Environment for MacOS]]
== hosted workstation ==
There is an Ubuntu workstation, that is available to selected developers. The aim is to reduce the installation effort and provide a defined environment to get quick results.
* [[Hosted development workstation]]


== Use another database system ==
== Use another database system ==

Revision as of 11:03, 8 March 2012

Overview and Introduction

All the development tools we use are open source themselves, so developers do not need to spend money to be able to partly or fully join the openPETRA development!

The openPETRA developers in OM work on Windows, but all the tools (including the DB systems) are available on various operating systems (supported on Windows, on a number of Linux distributions and on MacOS), with the exception of the IDE (Integrated Development Environment). A very powerful open source IDE, SharpDevelop, is available only for Windows and this is the IDE we use at OM. Another open source IDE, MonoDevelop, is cross-platform and possibly not that powerful (yet). The openPETRA developers in OM haven't tried using MonoDevelop, but it should work, at least as the C# code editor. We do have a fully-fledged build system which is based on NAnt (similar to Ant, but for .NET and not Java), which is cross-platform and that is what we mostly use for compiling anyways.


Setup by Operating System

Please follow the Link for the operating system of your choice. You are more than welcome to add your own instructions here if the OS of your choice isn't listed here yet and you have found out how to set the development tools up on this OS!

hosted workstation

There is an Ubuntu workstation, that is available to selected developers. The aim is to reduce the installation effort and provide a defined environment to get quick results.

Use another database system

The development environment is initially set up using SQLite as the default database system. This is the easiest way to get a quick start as no RDBMS needs to be installed for that. For serious development on OpenPetra it makes more sense to use either the PostgreSQL or MySQL RDBMS because they enforce DB Constraints and through that coding errors come to light much quicker. Also, when the PostgreSQL or MySQL RDBMS are used the performance of the RDBMS is more comparable to a deployed OpenPetra installation.

To switch to another database system, please follow these steps:

  • Change resp. in the first use create your [OpenPetra.build.config] file
    • Change the value of DBMS.Type to 'postgresql' or 'MySQL'
    • Enter the username and password of the user you created (for Postgres: see this wiki page) in DBMS.Password and DBMS.Password.
  • If you haven't yet performed the tasks mentioned in initial steps then please skip the next steps and continue with the next section of this wiki page instead.
  • Otherwise you can run nant recreateDatabase and nant resetDatabase which will create the database and load the base and demo data, respectively.
    • Run nant startPetraServer, which will copy the correct .config file and start the OpenPetra Server. The switch to the other database system succeeded if no error is shown when the server starts up.
    • Optional: Run nant startPetraClient to start up the OpenPetra Client to verify that the login to the OpenPetra Server works.

Compiling (NAnt script info)

After completing all the steps that are involved in the setup of your development environment on the operating system of your choice, you are ready for the compiling and starting of openPETRA!

Our NAnt files are split up in several pieces. A small NAnt file is located in most directories. It will include a central NAnt file according to what is needed. The central NAnt files are located in inc/nant. Most targets are available in all directories of our code base.

Local Configuration (required)

see User_defined_configuration_parameters_with_OpenPetra.build.config

get help

To see the available commands, just go to the root directory of the checked out openPetra and run the command line:

nant help

or

nant -projecthelp

Be aware, that nant -projecthelp only shows the help information of targets, which are directly defined in the build file, but not in the imported buildfile!

initial steps

First you should build openPetra and generate the project and solution files. This is done by following command:

nant generateSolution

Here it is recommended to send the nant output into a file, because the program otherwise sends 1MB data to the console and this is a time consuming process and furthermore - if you have only one processor - it is a pc blocking process. In this case you have to use an editor to read the last line of the report (successful or not) and you have to delete the file but and the end of the process you are the winner.

Create-A-Project-0.JPG

And be careful using "nant generateSolution" command. It only works if the c#-code can be compiled without any error. Use nant generateCsprojectNoCompile if it does not or uncomment the dangerous lines.

The solution and project files will be created in the direcory delivery\projects\sharpdevelop4 resp. delivery\projects\vs2010. This directory contains all possible project files (actually 132 files) and the best and easiest way is to open the load box and to start with the characters "op", then the main projects are listed (OpenPetra.Client.sln, OpenPetra.Server.sln, OpenPetra.Testing.sln) Common und Shared are part of those project files now.

Now you need to create a database. If you do not add a nant file called OpenPetra.build.config with the config file with a property names DBMS.Type, the SQLite database system will be used. See User defined configuration parameters with OpenPetra.build.config for more details on how to create and populate this configuration file or if you get a "we do not support sqlite databases with passwords" error (see third example about SQLite on page linked above).

nant recreateDatabase

Then you want to load the database with base data:

nant resetDatabase

Start the OpenPetra.org Server:

nant startPetraServer

Start the OpenPetra.org client:

nant startPetraClient

With the base database, there is the user demo with password demo that you can use to login to your installation of OpenPetra.org. The user sysadmin with password CHANGEME (capital letters!!) will allow you to create more users, backup the database, etc.

See Basic Tutorial for information what is actually working already.

Stop the OpenPetra.org Server:

nant stopPetraServer

further steps

Targets in source directories

clean: Remove generated files and output files

uncrustify or indent: re-formats the source files in the directory according to programming guidelines

depend: find out dependencies in sub-project and generates nant files in the source directories

compile: Compiles the source files in this directory

generateCsproject: Generate the project file for this directory


Creating a new source sub-directory

Just add the directory and put the source files into it. Run

 nant generateSolution 

will regenerate the project files and add it to the solution. (In case this doesn't work, try to run nant quickClean and then nant generateSolution.)

Based on the directory ICT\Petra\Server\lib\MFinance\GL I've created ICT\Petra\Server\lib\MFinance\GL\Test and I've inserted a initializing file Test.GL.Revaluation.cs containing the namespace Test.Ict.Petra.Server.MFinance.GL and some other followed by an empty bracket (or some content) and some using commands. The file has been found and integrated into a project.

If the new directory contains yaml files, you need to add the new directory in the file csharp\ICT\Petra\Client\Ict.Petra.Client.build to the property "directories-with-yaml".

Adding new files to an existing project

Careful: when you add a new cs file directly in SharpDevelop, the file will be stored in delivery\projects\sharpdevelop4, and that is the wrong place. So the best is to create the file manually in the directory in eg csharp\ICT\Common\IO, where it should live, and then on the command line:

cd csharp\ICT\Common\IO
nant generateCsprojectNoCompile

Adding a new Third Party Dll

We have some third party dlls in csharp/ThirdParty. They are published with a license that is compatible to the GPL, so we are allowed to use them with OpenPetra. There is usually a readme file which refers to the sources of that dll, and instructions how to build it or which things we have modified. Sometimes we have added small patches to the directory.

When adding a new third party dll, you also must add a reference to the file inc\nant\OpenPetra.references.xml, in the section 3rdPartyPattern.


Testing

see Working with NUnit tests