Koozali.org: home of the SME Server
Contribs.org Forums => Development => Topic started by: Xavier.A 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] (https://en.wikipedia.org/wiki/Eclipse_%28software%29)
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 (https://en.wikipedia.org/wiki/Java_%28programming_language%29) installation with some tweaks to work well. You could install only JRE but JRE is bundled in JDK (https://java.com/en/download/faq/techinfo.xml) and you will not have to install it after, if you want to develop a java application. There are no really differences (https://blogs.oracle.com/henrik/entry/java_7_questions_answers) between OpenJDK 7 (http://openjdk.java.net/) and Oracle JDK 7 (https://docs.oracle.com/javase/7/docs/webnotes/install/), we will install OpenJDK 7 except on the Windows desktop computers.
2.1. Installation (Centos 7)
Open a terminal and type :
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:
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 :
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 (https://www.eclipse.org/downloads/). Choose the latest stable standard version (https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/SR2/eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz) and not a version for java developers
[ ! -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.
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 :
tar -xzvf eclipse-standard-luna-SR2-linux-gtk-x86_64.tar.gz -C /opt/
Fix file permissions and ownership :
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" :
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 :
ln -s /opt/eclipse/eclipse /usr/bin/eclipse
3.5. Eclipse configuration
Before starting eclipse you can tweak his startup (https://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse) configuration file eclipse.ini (https://wiki.eclipse.org/Eclipse.ini). First, move the "/opt/eclipse/eclipse.ini" file in the "/etc/eclipse" folder :
[ ! -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 (https://blogs.oracle.com/poonam/entry/about_g1_garbage_collector_permanent) Collection
echo "-XX:+UseParallelGC" >> /etc/eclipse/eclipse.ini
echo "-XX:+CMSClassUnloadingEnabled" >> /etc/eclipse/eclipse.ini
Heap optimization (https://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse). The following values are for a computer desktop with 8 Go of RAM ( test and adapt the value):
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 (https://marketplace.eclipse.org/).
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 (https://marketplace.eclipse.org/content/shelled)
Help > Eclipse Marketplace > Find : "ShellEd" > Install
4.1.2. Perl scripts : Epic (http://www.epic-ide.org/) v.0.6.57 (last stable)
You must install perl-PadWalker :
sudo yum install perl-PadWalker
Help > Install New Software > Add > Add Repository > Name + Location
Name : EPIC
Location : http://e-p-i-c.sourceforge.net/updates (http://e-p-i-c.sourceforge.net/updates)
> Ok
4.1.3. Web development : Aptana 3 (https://marketplace.eclipse.org/content/aptana-3)
Aptana Studio 3 (http://www.aptana.com/) should be installed as a standalone software.
4.2. Tasks Management
4.2.1. Bugzilla connector (https://wiki.eclipse.org/Mylyn/Bugzilla_Connector) : Mylyn (https://marketplace.eclipse.org/content/mylyn)
Help > Eclipse Marketplace > Find : "Mylyn" > Install
4.2.2. Mediawiki editor (https://wiki.eclipse.org/Mylyn/WikiText) : Mylyn WikiText (https://marketplace.eclipse.org/content/mylyn-wikitext)
Help > Eclipse Marketplace > Find : "Mylyn WikiText" > Install
4.3. Sources management
4.3.1. CVS (http://help.eclipse.org/luna/topic/org.eclipse.platform.doc.user/gettingStarted/qs-61d_repolocb.htm?cp=65_1_1_2_0)(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 (https://wiki.eclipse.org/EGit/FAQ) : EGit - Git Team Provider (https://marketplace.eclipse.org/content/egit-git-team-provider)
Help > Eclipse Marketplace > Find : "EGit" > Install
4.4. Database and LDAP
4.4.1. Apache Directory Project (https://directory.apache.org/) : Apache Directory Studio (https://marketplace.eclipse.org/content/apache-directory-studio)
Apache Directory Studio (https://directory.apache.org/studio/) should be installed as a standalone software.
4.4.2. Data Tools Platform Project (https://wiki.eclipse.org/Data_Tools_Platform_Project) : Eclipse DTP (https://marketplace.eclipse.org/content/eclipse-dtp-data-tools-platform)
Help > Eclipse Marketplace > Find : "Data Tools Platform" > Install
JDBC Drivers :
- Apache Derby (https://db.apache.org/derby/derby_downloads.html)
- Sqlite (https://bitbucket.org/xerial/sqlite-jdbc/downloads)
- Postgresql (https://jdbc.postgresql.org/download.html)
- MySQL (https://dev.mysql.com/downloads/connector/j/)
4.4.3. Database manager : DBeaver (https://marketplace.eclipse.org/content/dbeaver)
DBeaver (http://dbeaver.jkiss.org/download/) should be installed as a standalone software.
4.5. Packaging
Spec file editor (https://wiki.eclipse.org/Linux_Tools_Project/SpecfileEditor/User_Guide) from Linux Tools Project (https://wiki.eclipse.org/Linux_Tools_Project)
You must install the rpmlint and rpm-build packages :
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 (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:
- Eclipsepedia - the Eclipse.org Wiki (https://wiki.eclipse.org/Main_Page)
- Eclipse documentation - Current Release (http://help.eclipse.org/luna/index.jsp)
- Eclipse Community Forums (https://www.eclipse.org/forums)
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...
-
+1
-
+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 ?
-
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
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 :
yum install xorg-x11-xauth libXmu
2.2.3. Change the "Login Shell" for the Eclipse_User
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
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
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 :
yum install gtk2-engines gnome-icon-theme dejavu-sans-fonts
and you must create the ".gtkrc-2.0" file in the Eclipse_User home
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 :
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 :
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+
-
[UPDATE]
Eclipse Mars was released in june 2015, you can read more information about new features here (https://www.eclipse.org/).
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 (http://www.eclipse.org/downloads/):
[ ! -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.
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 :
[ -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 :
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" :
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 :
[ -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 !