Koozali.org formerly Contribs.org

Eclipse IDE for SME Server development

Eclipse IDE for SME Server development
« on: June 12, 2015, 06:10:18 PM »
Eclipse IDE for SME Server development

  • Introduction
  • Java SDK
  • Eclipse standard edition
  • Eclipse plug-ins for SME Server
  • Further information

1. Introduction
Eclipse IDE is the leader of the open source IDE. It's used to develop java applications but not only [Read more]
With this bundle, you will be able to :
  • develop in Shell, Perl, Python, etc...
  • connect to your source repositories with your favorite SCM
  • connect to bugzilla
  • manage the team development tasks
  • write documentation in mediawiki style, inside eclipse
  • generate Epub, Docbook, HTML files of documentations
  • import SRPM in RPM project
  • write a spec file with a templated form
  • build the srpm and the rpm, inside eclipse
  • ...

2. Java SDK
Eclipse needs a Java installation with some tweaks to work well. You could install only JRE but JRE is bundled in JDK and you will not have to install it after, if you want to develop a java application. There are no really differences between OpenJDK 7 and Oracle JDK 7, we will install OpenJDK 7 except on the Windows desktop computers.

2.1. Installation (Centos 7)
Open a terminal and type :
Code: [Select]
sudo yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel java-1.7.0-openjdk-javadoc
2.2. JAVA path (Centos 7)
Before installing Eclipse, you have to update your PATH. This can be done by typing the following lines in your shell:
Code: [Select]
cat << 'EOF' > /etc/profile.d/java.sh
# Path for Java in CentOS
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:$JAVA_HOME/bin
EOF

tac << 'EOF' > /etc/profile.d/java.csh
setenv PATH $PATH:$JAVA_HOME/bin/
setenv JAVA_HOME /usr/lib/jvm/java
# Path for Java in CentOS
EOF

2.3. Tests
Now Java SDK is correctly installed. To check the java type the following :
Code: [Select]
java -version && javac -version

3. Eclipse standard edition
You don't NEED to use Eclipse in order to work on the SME Server code. But if you don't know Eclipse, you should give it a try, as it's what a lot of developers are using, and it's powerful and open source software. Prior to installing Eclipse, be sure you have a Java SDK installed.

3.1. Eclipse download
You can download Eclipse at Eclipse website. Choose the latest stable standard version and not a version for java developers
Code: [Select]
[ ! -d /usr/local/src/eclipse ] && mkdir /usr/local/src/eclipse
cd  /usr/local/src/eclipse
wget http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/luna/SR2/eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz \
http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/luna/SR2/eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz.md5 \
http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/luna/SR2/eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz.sha1 \
http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/luna/SR2/eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz.sha512

3.2. Verify the integrity of the downloaded files
A hash value processed on the downloaded files is a way to make sure that the content is not modified and has not been damaged during the download process.
Code: [Select]
sha512sum -c eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz.sha512 && \
sha1sum -c eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz.sha1 && \
md5sum -c eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz.md5
If the values do not match, your downloaded files are broken. Try the download again, and recheck.

3.3. Eclipse installation on Centos 7
Installing Eclipse is quite simple : you only have to extract the downloaded archive in the target folder (/opt). For instance, if the archive is a tar-gz archive, type the following :
Code: [Select]
tar -xzvf eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz -C /opt/

Fix file permissions and ownership :
Code: [Select]
clear ; ls -lna /opt/ ; ls -lna /opt/eclipse/
chown -vR root:root /opt/eclipse
chmod -v 755 /opt/eclipse/eclipse

3.4. Eclipse shortcut and launcher
On Linux desktop, you may want to create a "desktop shortcut" :
Code: [Select]
cat << 'EOF' > /usr/share/applications/eclipse.desktop
[Desktop Entry]
Type=Application
Version=4.4.2
Name=Eclipse
GenericName=Eclipse Luna IDE
Comment=Eclipse Luna IDE
Exec=/opt/eclipse/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Encoding=UTF-8
Categories=GTK;Development;IDE;
MimeType=text/x-perl;text/x-python;application/xml;text/x-sql;text/x-diff;
EOF

and to be able to start Eclipse with a command line :
Code: [Select]
ln -s /opt/eclipse/eclipse /usr/bin/eclipse

3.5. Eclipse configuration
Before starting eclipse you can tweak his startup configuration file eclipse.ini. First, move the "/opt/eclipse/eclipse.ini" file in the "/etc/eclipse" folder :
Code: [Select]
[ ! -d /etc/eclipse ] && mkdir /etc/eclipse
cp /opt/eclipse/eclipse.ini /etc/eclipse/ && chmod 644 /etc/eclipse/eclipse.ini
mv /opt/eclipse/eclipse.ini /opt/eclipse/eclipse.ini.bak
ln -s /etc/eclipse/eclipse.ini /opt/eclipse/eclipse.ini
clear ; more /opt/eclipse/eclipse.ini

Tuning Garbage Collection
Code: [Select]
echo "-XX:+UseParallelGC" >> /etc/eclipse/eclipse.ini
echo "-XX:+CMSClassUnloadingEnabled" >> /etc/eclipse/eclipse.ini

Heap optimization. The following values are for a computer desktop with 8 Go of RAM ( test and adapt the value):
Code: [Select]
echo "-XX:PermSize=256M" >> /etc/eclipse/eclipse.ini
sed -i "s/XX:MaxPermSize=256m/XX:MaxPermSize=512m/" /etc/eclipse/eclipse.ini
sed -i "s/Xms40m/Xms512m/" /etc/eclipse/eclipse.ini
sed -i "s/Xmx512m/Xmx2g/" /etc/eclipse/eclipse.ini

4. Eclipse plug-ins for SME Server
There are hundreds of plug-ins available for the Eclipse IDE. Many are collected at and downloadable from the Eclipse Marketplace.
Plug-ins can be installed according to 4 different ways :
  • Help > Eclipse Marketplace > Find > Install
  • Help > Install New Software > Add > Add Repository > Name + Location (Remote repository)
  • Help > Install New Software > Add > Add Repository > Locale (Locale repository aka on your disk)
  • Help > Install New Software > Add > Add Repository > Archive (zip or tar file)
4.1. Programming languages
4.1.1. Shell scripts : ShellEd
Help > Eclipse Marketplace > Find : "ShellEd" > Install

4.1.2. Perl scripts : Epic v.0.6.57 (last stable)
You must install  perl-PadWalker :
Code: [Select]
sudo yum install perl-PadWalkerHelp > Install New Software > Add > Add Repository > Name + Location
Name : EPIC
Location : http://e-p-i-c.sourceforge.net/updates
> Ok

4.1.3. Web development : Aptana 3
Aptana Studio 3 should be installed as a standalone software.

4.2. Tasks Management
4.2.1. Bugzilla connector : Mylyn
Help > Eclipse Marketplace > Find : "Mylyn" > Install

4.2.2. Mediawiki editor : Mylyn WikiText
Help > Eclipse Marketplace > Find : "Mylyn WikiText" > Install

4.3. Sources management
4.3.1. CVS (bundled in Eclipse)
You can check out the sources using CVS. Eclipse supplies a CVS team programming environment that enables you to share your work with others.

4.3.2. GIT : EGit - Git Team Provider
Help > Eclipse Marketplace > Find : "EGit" > Install

4.4. Database and LDAP
4.4.1. Apache Directory Project : Apache Directory Studio
Apache Directory Studio should be installed as a standalone software.

4.4.2. Data Tools Platform Project : Eclipse DTP
Help > Eclipse Marketplace > Find : "Data Tools Platform" > Install

JDBC Drivers :
4.4.3. Database manager : DBeaver
DBeaver should be installed as a standalone software.

4.5. Packaging
Spec file editor from Linux Tools Project
You must install the rpmlint and rpm-build packages :
Code: [Select]
yum install rpmlint rpm-build

Help > Install New Software > Add > Add Repository > Name + Location
Name : Linux Tools Project
Location : http://download.eclipse.org/linuxtools/update
>Ok

Work with : --All Availables sites--
Type filter text : rpm
Select : Linux Tools > RPM Tools

5. Further information
You can find useful further information in the following websites:

This post is a short extract (and a bad translation) from my notes. I tried to make it the smallest as possible, don't hesitate to add your suggestions...

« Last Edit: June 13, 2015, 10:37:50 AM by Xavier.A »
“When the wise man points to the moon, the fool looks at the finger.”

Offline stephdl

  • *
  • 1,505
    • Linux et Geekeries
Re: Eclipse IDE for SME Server development
« Reply #1 on: June 12, 2015, 08:28:53 PM »
+1
See http://wiki.contribs.org/Koozali_Foundation
irc : Freenode #sme_server #sme-fr

!!! Please write your knowledge to the Wiki !!!

Offline ReetP

  • *
  • 2,367
Re: Eclipse IDE for SME Server development
« Reply #2 on: June 13, 2015, 02:12:20 AM »
+1 Nice work Xavier.

I use Eclipse a lot because of it's debugging capabilities.

The one thing I wish I could really do is debug remote SME perl code from Eclipse on my desktop.

I have also been kindly given a Open Source licence for Komodoide - (I must give them some credits on the front page). It's nice, way faster than Eclipse but nowhere near as many feature as yet. That can do remote debugging http://docs.activestate.com/komodo/4.4/debugperl.html but I have not tried it yet.

You can also run perl scripts on your server in debug mode with perl -d somescript.pl - a nice little howto on the commands for this might be nice :-)

I did wonder about trying to build a test SME box with just enough kit to run Eclipse or Komodo directly on the box so the debug was 'local' to the app - if you don;t you get loads of library issues etc etc. I guess it needs a very basic X server with ssh -X ?
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Re: Eclipse IDE for SME Server development
« Reply #3 on: June 13, 2015, 08:19:01 PM »
I don't use Komodo but if you can write a post on it, I will give it a try....

About editing files on a remote server, there are 2 ways to do that :
  • Remote System Explorer in your local eclipse
  • Eclipse in your SME Server

1. Remote System Explorer plug-in
1.1. Installation
Help > Install New Software
Work with : --All Availables sites--
Type filter text : Remote System Explorer
Select : General Purposes Tools > Remote System Explorer End-User Runtime + Remote System Explorer User Actions

1.2. Configuration
1.2.1. SSH connection
Window > Preferences > Network Connections > SSH2

1.2.2. Remote system connection
Window > Open Perspective > Other > Remote System Explorer
right clic on 'Local' > New > Connection > SSH Only > Next > ... > Finish
right clic on 'Ssh Terminals' > Subsystem > Port > OK
right clic on 'Connection name' > Connect > ... > OK

Use the contextual menu (Sftp Files / Ssh Shells / Ssh Terminals) and explore your remote server  :P

2. Eclipse in SME Server
2.1 Install Eclipse
Follow the first post, except for the desktop shortcut

2.2 X11 Forwarding using SSH
2.2.1. Create the custom template
Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/ssh/sshd_config
cat > /etc/e-smith/templates-custom/etc/ssh/sshd_config/50X11Forwarding << EOF
X11Forwarding yes
X11UseLocalhost no
EOF
expand-template /etc/ssh/sshd_config
service sshd restart

2.2.2. xauth - X authority file utility
Install in your SME Server :
Code: [Select]
yum install xorg-x11-xauth libXmu
2.2.3. Change the "Login Shell" for the Eclipse_User
Code: [Select]
Eclipse_User=???
env | grep SHELL
cat /etc/passwd | grep $Eclipse_User
usermod -s $SHELL $Eclipse_User
db accounts setprop $Eclipse_User Shell $SHELL
db accounts show $Eclipse_User

2.2.4. Transfer SSH Keys
Code: [Select]
SMESERVER=???
PORT=???
cat .ssh/id_rsa.pub | ssh -p $PORT $USER@$SMESERVER "cat >> ~/.ssh/authorized_keys" && \
cat .ssh/id_dsa.pub | ssh -p $PORT $USER@$SMESERVER "cat >> ~/.ssh/authorized_keys"

2.2.5. Test the connection
Code: [Select]
ssh -X -C -p $PORT $USER@$SMESERVER eclipse

2.2.6. Improve appearance of eclipse
If you find the Eclipse GUI ugly, you can install GTK themes, icons and fonts in SME Server :
Code: [Select]
yum install gtk2-engines gnome-icon-theme dejavu-sans-fonts

and you must create the ".gtkrc-2.0" file in the Eclipse_User home
Code: [Select]
ssh -p $PORT $USER@$SMESERVER
cat > $HOME/.gtkrc-2.0 << EOF
include "/usr/share/themes/Clearlooks/gtk-2.0/gtkrc"
gtk-icon-theme-name = "gnome"
style "smeserver"
{
font_name = "DejaVu Sans 10"
}
widget_class "*" style "smeserver"
gtk-font-name = "DejaVu Sans 10"
EOF

2.2.7. Eclipse local desktop shortcut
create "/usr/bin/eclipse_sme" script, change $SMESERVER and $PORT :
Code: [Select]
sudo su -
cat <<'EOF'> /usr/bin/eclipse_sme
#!/bin/sh
SMESERVER=???
PORT=????
ssh -X -C -p $PORT $USER@$SMESERVER eclipse
EOF

chmod 755 /usr/bin/eclipse_sme

create the desktop shortcut :
Code: [Select]
cat <<'EOF'> /usr/share/applications/eclipse_sme.desktop
[Desktop Entry]
Type=Application
Version=4.4.2
Name=Eclipse (SME Server)
GenericName=Eclipse Luna IDE (SME Server)
Comment=Eclipse Luna IDE (SME Server)
Exec=/usr/bin/eclipse_sme
Icon=/opt/eclipse/icon.xpm
Terminal=false
Encoding=UTF-8
Categories=GTK;Development;IDE;
MimeType=text/x-perl;text/x-python;application/xml;text/x-sql;text/x-diff;
EOF

Now, your Eclipse IDE is on the clouds (in your SME Server), and we don't need a CentOS Desktop  8) 
You can mix the 2 techniques to access files in another server from your SME.


A+
« Last Edit: June 16, 2015, 03:29:31 PM by Xavier.A »
“When the wise man points to the moon, the fool looks at the finger.”

Re: Eclipse IDE for SME Server development
« Reply #4 on: August 21, 2015, 12:22:51 PM »
[UPDATE]

Eclipse Mars was released in june 2015, you can read more information about new features here.

3. Eclipse edition

There are no more standard editions of Eclipse then you will have to download the java developer edition or another one. With the Java developer edition you will have to re-install manually the CVS plugin.

3.1. Eclipse download
you can donwload Eclipse Mars from the french CNRS IBCP mirrors or from here:

Code: [Select]
[ ! -d /usr/local/src/eclipse ] && mkdir /usr/local/src/eclipse
cd  /usr/local/src/eclipse
wget http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/mars/R/eclipse-java-mars-R-linux-gtk-x86_64.tar.gz \
http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/mars/R/eclipse-java-mars-R-linux-gtk-x86_64.tar.gz.md5 \
http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/mars/R/eclipse-java-mars-R-linux-gtk-x86_64.tar.gz.sha1 \
http://mirror.ibcp.fr/pub/eclipse/technology/epp/downloads/release/mars/R/eclipse-java-mars-R-linux-gtk-x86_64.tar.gz.sha512


3.2. Verify the integrity of the downloaded files
A hash value processed on the downloaded files is a way to make sure that the content is not modified and has not been damaged during the download process.

Code: [Select]
sha512sum -c eclipse-java-mars-R-linux-gtk-x86_64.tar.gz.sha512 && \
sha1sum -c eclipse-java-mars-R-linux-gtk-x86_64.tar.gz.sha1 && \
md5sum -c eclipse-java-mars-R-linux-gtk-x86_64.tar.gz.md5

3.3. Eclipse installation on Centos 7 or Debian 8
Updating Eclipse is quite simple : you only have to extract the downloaded archive in the target folder (/opt). For instance, if the archive is a tar-gz archive, type the following :

Code: [Select]
[ -d /opt/eclipse ] && mv /opt/eclipse /opt/eclipse.bak
tar -xzvf eclipse-java-mars-R-linux-gtk-x86_64.tar.gz -C /opt/

Fix file permissions and ownership :
Code: [Select]
clear ; ls -lna /opt/ ; ls -lna /opt/eclipse/
chown -vR root:root /opt/eclipse
chmod -v 755 /opt/eclipse/eclipse

3.4. Eclipse shortcut and launcher
On Linux desktop, you may update the "desktop shortcut" :
Code: [Select]
cat /usr/share/applications/eclipse.desktop
sudo sed -i "s/4.4.2/4.5.0/g" /usr/share/applications/eclipse.desktop
sudo sed -i "s/Luna/Mars/g" /usr/share/applications/eclipse.desktop


3.5. Eclipse configuration

Update the /etc/eclipse/eclipse.ini file :
Code: [Select]
[ -d /etc/eclipse ] && mv  /etc/eclipse/eclipse.ini /etc/eclipse/eclipse.ini.bak
cp /opt/eclipse/eclipse.ini /etc/eclipse/ && chmod 644 /etc/eclipse/eclipse.ini
mv /opt/eclipse/eclipse.ini /opt/eclipse/eclipse.ini.bak
ln -s /etc/eclipse/eclipse.ini /opt/eclipse/eclipse.ini
clear ; more /opt/eclipse/eclipse.ini

Optimize your Eclipse Mars software and happy coding !

PS : /!\ Beware, you will have to update all of your Eclipse workspaces and plugins !
« Last Edit: August 22, 2015, 12:59:52 PM by Xavier.A »
“When the wise man points to the moon, the fool looks at the finger.”