Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Directory Wiki" for 
change notification.

The following page has been changed by EmmanuelLecharny:
http://wiki.apache.org/directory/IdeHome

The comment on the change is:
Added a Eclipse howto.

New page:
= Using an IDE to compile/work with ApacheDS =

== preamble ==
First, you have to know that I'm french. Beside the fact that I'm arrogant, 
that I don't take a shower every day, that I eat rotten cheese and a lot of 
garlic and snails - I'm french, remember that -, my english is not as good as 
my french. If you feel the need to correct any part of this text, you are 
welcome !

== Introduction ==

This page has been created as an help for those who want to use an IDE like 
Eclipse, Idea or whatever IDE you like to build ApacheDS.

As you can see, there are not specific files that allow a user to directly 
import ApacheDS in your favorite IDE. There are two reasons for this :
- there are many IDE on the market, and it's better not to constraint the 
project's members to use one,
- we want to be sure that the project can be built every night using GUMP 
(hum), to allow the community to fix a broken project as soon as possible.

However, ApacheDS community members are not using '''ed''' or '''vi''' or, even 
better '''emacs'''. Those are good tools, and from time to time, it's good to 
handle those good old command lines. But the power of a good IDE help us 
concentrate on programming.

== Basic setting ==

First, you have to be sure that your environment is correctly set. You have to 
be able to compile ApacheDS without any error, and this is quite challenging, 
as you can see reading the mail archive !

So here are the prerequisite :

=== OS ===
- a good operating system is needed. Call it Linux, Windows, OS-X, but at least 
choose a system on which you can install a 1.4 JDK. OS/2 is not the winner in 
this category...

- You'll have to choose the OS on which you'll be able to install Eclipse or 
IDEA (or Netbeans, or Jbuilder, who knows?). Be aware that if you want to 
profile your favorite program, there will be some constraints.

- If you want to use Linux (welcome !), no problem. I'm personnaly enjoying 
'''Fedora core 3''' and '''Ubuntu 5.04'''. '''Ubuntu''' is really cool !

=== JDK ===

'''Sun''' or '''IBM''' JDK are equally good. I have better performance with IBM 
JDK, I don't know why. Be sure to install the latest version, as many security 
issues has been corrected. I'm using '''Sun JDK 1.4.2_08''' and '''IBM JDK 
1.4.2''', both works well. I didn't had chance to test the JRocket JDK, thaat 
would be interesting.

If you are a Linux user, the best solution is to install your JDK under 
/user/java. Linux gurus may have better advices, so listen to them !

{{{
This project need a 1.4 JDK, it won't compile with a JDK 1.3 or 1.5 !!! (for 
1.5 JDK, this is just because there is a little problem with AOP; it will be 
fixed sooner or later)
}}}

=== Subversion ===

In order to check out the code, you will have to install a '''subversion''' 
client. Here is the link : http://subversion.tigris.org/project_packages.html

Subversion is pretty well documented, so I won't add a lot of informations 
about it.

Check that the client is ok :

{{{
$ svn
Type 'svn help' for usage.
$ 
}}}

It seems that '''svn''' is installed !

=== Maven ===

Here we are! You'll have to be under the iron rule of Maven to build the 
project. If you can't compile ApacheDS with Maven, then you are on the dark 
side of the Force.

So, download and install Maven 1.0.2. Install it wherever fits your need (I've 
installed it under /home/java). Add a MAVEN_HOME environment variable :

Here is an extract of my .bashrc file on my Linux boc ('''.bashrc''' is the 
file you'll found on you home directory)
{{{
...
export MAVEN_HOME=/home/java/maven-1.0.2 
export PATH=$JAVA_HOME:$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
...
}}}

'''Windows''' users, please set up your env using the correct sequence of left 
and right clicks...

Insure yourself that Maven is correctly installed by lauching it in a command 
window :

{{{
$ maven
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
Java : /usr/java/j2sdk1.4.2_08/bin/java :
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2

BUILD SUCCESSFUL
Total time: 2 seconds
Finished at: Sun May 01 23:56:22 CEST 2005

$
}}}

(Good ! And the JVM is OK, too !)

=== Donwload the code ===

Very simple ! Create a working directory, and go there :

{{{
$ mkdir ApacheDS
$ cd ApacheDS
$ svn co http://svn.apache.org/repos/asf/directory
$ svn co http://svn.apache.org/repos/asf/directory
A  directory/LicenseBoilerPlate.txt
A  directory/trunks
A  directory/network
A  directory/network/trunk
A  directory/network/trunk/xdocs
A  directory/network/trunk/xdocs/roadmap.xml
A  directory/network/trunk/xdocs/index.xml
A  directory/network/trunk/xdocs/navigation.xml
A  directory/network/trunk/LICENSE.txt
A  directory/network/trunk/project.properties
A  directory/network/trunk/project.xml
A  directory/network/trunk/maven.xml
A  directory/network/trunk/src
A  directory/network/trunk/src/test
...
Checked out external at revision 165553.

Checked out revision 165553.
$
}}}

'''It takes time!!!''' Do NOT interrupt the process with a '''ctrl-c''', it 
does not work. Either wait or kill the process. If you kill it, you will better 
clean the full directory before retrying the command, there are a lot of 
meta-files created.

So have a coffee. Forget about your micro-wave oven, don't use instant cofee. 
You have plenty of time !

=== First compilation ===

So far, so good. You have downloaded around 400 000 lines of code. You can 
check it by launching the command '''codesize.sh''' under the sub-directory 
'''directory''' :

{{{
$ pwd
<home>/ApacheDS
$ cd directory
$ ./codesize.sh (sorry, windowers... please install Cygwin, it's really cool !)
lines of code in ./protocol-providers/ldap/trunk = 2084
lines of code in ./protocol-providers/dns/trunk = 4302
lines of code in ./protocol-providers/ntp/trunk = 1550
lines of code in ./protocol-providers/kerberos/trunk = 1996
lines of code in ./protocol-providers/changepw/trunk = 1514
lines of code in ./protocol-providers/dhcp/trunk = 4853
lines of code in ./clients/ldap/trunk = 10421
lines of code in ./clients/kerberos/trunk = 867
lines of code in ./sandbox/trunk = 53934
lines of code in ./sandbox/trunk/protocol/trunk = 583
lines of code in ./sandbox/trunk/apseda/trunk = 15176
lines of code in ./authx/trunk = 9386
lines of code in ./naming/trunk = 17227
lines of code in ./network/trunk = 19548
lines of code in ./shared/ldap/trunk = 85948
lines of code in ./shared/kerberos/trunk = 11215
lines of code in ./apacheds/trunk = 44946
lines of code in ./trunks/shared/ldap/trunk = 85948
lines of code in ./asn1/trunk = 26675
Total: 398173

$ 
}}}

Let's go for the first compilation ! You will have to be connected on Internet, 
because many files will have to be downloaded by Maven (many Jakarta files).

'''To compile the project you ***MUST*** be in the main directory''', which is 
'''apacheds/trunk'''.

The command to type is '''maven multiproject:install'''. Don't ask my what it 
means, I don't know ;-), at least, it compiles the whole stuff, and launch the 
tests.

{{{
$ pwd
<home>/ApacheDS/directory
$ cd apacheds/trunk/
$ pwd
<home>/ApacheDS/directory/apacheds/trunk
$ maven multiproject:install
 maven multiproject:install
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
Java : /usr/java/j2sdk1.4.2_08/bin/java :
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2

build:start:

multiproject:install:
multiproject:projects-init:
    [echo] Gathering project list
Starting the reactor...
Our processing order:
ApacheDS Shared
ApacheDS Plugin
ApacheDS Core
ApacheDS Main
...
}}}

Tea time. Enjoy the pleasure of a Lapsang Soushong, you have to brew it for 5 
minutes before drinking it ...

{{{
...
BUILD SUCCESSFUL
Total time: 2 minutes 17 seconds
Finished at: Mon May 02 00:25:27 CEST 2005
$
}}}

Jeeze ! My computer is really fast ! ahhh. I know. I have all the downloaded 
files already in my Maven repository. (400 000 lines of Java code compiled in 2 
minutes. Who ever told that Java was slow?)

== Using Eclipse IDE ==

Ok, so you basic environment is up and running. Time to Eclipse the command 
line, it seems.

=== Eclipse version ===

The latest, the best. Install the 3.0.2 version of eclipse (forget about the 
3.1.M6, I don't know if it works.)

Add an '''eclipse-apacheDS.sh''' file in your eclipse root directory, to allow 
eclipse to consume more memory :

{{{
$ more /opt/eclipse-3.0.2/eclipse-apacheDS.sh 
/opt/eclipse-3.0.2/eclipse -data $HOME/workspace-apacheDS -vm java -vmargs 
-Xmx750M
}}}

I like to declare a specific workspace when launching eclipse. I have created a 
workspace-apacheDS directory in my HOME directory, where all the ApacheDS 
project is built when I use Eclipse.

I also added a directive to allow Java to use up to 750 M bytes of memory (I 
had Out of Memory errors with the standard setting). 

Launch eclipse :

{{{
$ /opt/eclipse-3.0.2/eclipse-apacheDS.sh 
...
}}}

=== Eclipse plugins ===

Here are the plugins I personally use :

||Plugin name || role || external site ||version||
||subclipse||Subversion plugin||http://subclipse.tigris.org/update||0.9.30||
||mevenide||Maven 
plugin||http://mevenide.codehaus.org/release/eclipse/update/site.xml||0.8.0||
||multi-projects||Utilities||http://eclipse-tools.sourceforge.net/updates||1.0.6||
||antlr|| Antlr plugin||http://antlreclipse.sourceforge.net/updates||2.7.4||

Install all of them, you will need them.

You'll have to paramtrize those plugins.

==== Subclipse plugin ====

Here are the parameters I use :

{{{
Window --> Preferences --> Team --> SVN :
}}}

attachment:svn-prefs1.png

 * Note that I've checked the SVN command line, even if it's a beta version. 
(the javahl extension does not work on linux yet)

Declare the svn repository by opening the SVN perspective, adding a new 
repository location:

attachment:svn-repo.png

 * This is an http access on the repository, it won't allow you to update your 
changes ! Don't be afraid to make mistakes using svn, you will only harm 
yourself ;)
 * The user may be anonymous/anonymous, I don't remember. If you are a 
commiter, you must type your user/password here, and change the previous http 
by https.

=== Importing projects ===

Now, you will have to '''check out as ...''' the following projects :

|| SVN path || Java project ||
||apacheds/trunk||apacheds||
||asn1/trunk||apacheds-asn1||
||authx/trunk||apacheds-authx||
||clients/kerberos/trunk||apacheds-client-kerberos||
||clients/ldap/trunk||apacheds-client-ldap||
||naming/trunk||apacheds-naming||
||network/trunk||apacheds-network||
||protocol-providers/changepw/trunk||apacheds-protocol-provider-changepw||
||protocol-providers/dhcp/trunk||apacheds-protocol-provider-dhcp||
||protocol-providers/dns/trunk||apacheds-protocol-provider-dns||
||protocol-providers/kerberos/trunk||apacheds-protocol-provider-kerberos||
||protocol-providers/ldap/trunk||apacheds-protocol-provider-ldap||
||protocol-providers/ntp/trunk||apacheds-protocol-provider-ntp||
||shared/trunk||apacheds-shared||

You can forget about sandbow, sitedoces and trunks.

You will have many projetcs, and many compilation errors ! You have to create 
the sources directory and set the dependencies.

=== .classpath ===

Here are the .classpath I use :


||project||.classpath||
||apacheds||attachment:apacheds.classpath||
||apacheds-asn1||attachment:apacheds-asn1.classpath||
||apacheds-authx||attachment:apacheds-authx.classpath||
||apacheds-client-kerberos||attachment:apacheds-client-kerberos.classpath||
||apacheds-client-ldap||attachment:apacheds-client-ldap.classpath||
||apacheds-naming||attachment:apacheds-naming.classpath||
||apacheds-network||attachment:apacheds-network.classpath||
||apacheds-protocol-provider-changepw||attachment:apacheds-protocol-provider-changepw.classpath||
||apacheds-protocol-provider-dhcp||attachment:apacheds-protocol-provider-dhcp.classpath||
||apacheds-protocol-provider-dns||attachment:apacheds-protocol-provider-dns.classpath||
||apacheds-protocol-provider-kerberos||attachment:apacheds-protocol-provider-kerberos.classpath||
||apacheds-protocol-provider-ldap||attachment:apacheds-protocol-provider-ldap.classpath||
||apacheds-protocol-provider-ntp||attachment:apacheds-protocol-provider-ntp.classpath||
||apacheds-shared||attachment:apacheds-shared.classpath||

Copy those .classpath files in the correct sub-directories, refresh the 
perspective, it should be OK.

'''THIS IS A DRAFT !!! Thanks to mail a comment to [email protected] if 
you have any problem!'''






== Using Idea IDE ==

Any IDEA user out there ?

Reply via email to