English translation of the article by Joaquin del Cerro.
I´m back to explain to you, how download the sources of one of the gvSIG project´s example and how compile it and debug it.
In this article, I will use as IDE Netbeans 8, which is the IDE that normally I use for developing with gvSIG long time ago. In the future, I will install an Eclipse and in another post I will tell you how to work with it. Anyway, if you are a developer used to Eclipse, it would not be difficult to take the explained ideas.
Keep in mind that this post doesn´t want to be a NetBeans tutorial, just to explain the steps to follow for being able to download and compile gvSIG plugin with it.
Once you have already followed the steps described in the post “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“ and we have all the basic tools installed and set up, we can carry on.
To follow this post, we need internet access. In general, for compiling gvSIG we need internet access. And also:
- An Installable of gvSIG, in my case “gvSIG-desktop-2.1.0-2262-testing-win-x86-standard-withjre.exe”
- An Installable of NetBeans
First of all, we install IDE, NetBeans.
I´ve downloaded it from the NetBeans official website, in downloads:
We will find a few distributions availables for downloading:
- Java SE
- Java EE
- HTML5 & PHP
With the distribution “Java SE” will be enough for compiling the majority of gvSIG projects (excluding the ones requiring natives, because they are out of this post´s scope)
Simply we will download it and proceed to install it.
Through the initial set up, it will ask us for two things, where are we going to install it and where is the JDK to use. In this case, we will choose the JDK which we have already installed like it was explained in “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“.
Once we have installed NetBeans, we will install gvSIG. It will be a standard setup but we will not install it in “Program Files”;, I advise you to install it inside c:/devel, folder, where we have already downloaded the gvSIG sources. I have installed in :
The reason of installing it out of “Program Files” is because in my Windows installation, the user doesn´t have administrator privileges and if I do it in there, I will have problems later when I try to deploy the plugin binaries over that installation. Writing on c:/devel folder (created by me), I will not have any privilege problems at all.
Once we have these two things installed, we change the pathfile on “.gvsig-devel.properties” for pointing to the installation of gvSIG which we have just done in “c:/devel”.
Well, one more thing to do. The actual distribution for Windows of gvSIG-desktop doesn´t include a launcher in gvSIG.sh of gvSIG. The launcher is only included in Linux distribution( in future distributions we will include it as well for Windows). Well, for the moment is not present, so we have two options, if we have alredy compiled “org.gvsig.desktop”, we can take it from “org.gvsig.desktop/target/product” folder or if we don´t have it on hand, we can download it from:
We will leave it in the folder where we have installed gvSIG, along with the “gvsig-desktop.exe”.
Once we have these three things, we will boot NetBeans, then, downwnload the project “org.gvsig.landregistryviewer” and we will compile it. We will download it from the url:
To do it, we will go to menu:
Then, we will write in the field “Repository url” the value of the url (previously indicated) in where is the example project “org.gvsig.landregistryviewer”. We click on “Next”. It will show us the next page of the assistant, in which we should introduce the folder where we want to download the project. In our case, we will introduce “c:/devel”, and click on “Finish”.
When the project´s download finish, it will tell us about the maven projects presents in the donloaded project and it will ask us if we want to open any of them. The screen dialogue will be something like:
When we try to load the project for the first time, probably some error will appear due to the fact that some dependencies are not downloaded, showing us a message like:
Now, we will compile the downloaded project. To do that, we select it in the “proyectos” view and click on “Build project” of the toolbar.
So far, we have seen how to prepare our work environment, download and compile the plugin. If we want to see our plugin in action, simply we will boot Console2, go to gvSIG installation folder, c:/devel/gvsig/2.1.0-2262, and run gvSIG.sh.
$ cd c:/devel/gvsig/2.1.0-2262
Let´s see how to debug our plugin.
We will open the subproject “org.gvsig.landregistryviewer.app.mainplugin”.
Now, we will load the class LandRegistryViewerExtension and put a breaking point at method´s start CreateViewWindow. To do this, we click twice in the line´s number.
Then, we will back to NetBeans, and connect to gvSIG in debug mode.
If we need to see the code of gvSIG, we click on Ctrl-O and type the class name which we want to locate.For instance, if wew want to put a breaking point in the proect creation, we will type Ctrl-O y “DefaultProject” …
All I have talked about is related to Windows 7. For Linux developers, it´s quite easy to follow and you just need to change the path c:/devel for the one that you use to leave the sources.
For Eclipse developers, the steps to follow are similars, the most complicated issue could be the support setting of maven which has already NetBeans.
It´s a post quite long (a lot of screenshots), but I think that they could be helpful to follow up the article.
I hope it was useful,
Greetings to all and thank you!