[GeoNetwork-devel] How to run and modify Geonetwork source code in Eclipse?

Hi guys,

I am pretty interested in looking into the code of GeoNetwork, so first I
imported the project from Github repository by using clone URL, but after
that, there are many errors saying that some particular class can not be
found.

I do not have much experience of working with such a big project, and things
like maven and ant are new to me, although I have them installed already.

Can anyone help me out? Thanks in advance!

Cody

-----
Geospatial discovery and cyberinfrastructure
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-run-and-modify-Geonetwork-source-code-in-Eclipse-tp5215265.html
Sent from the GeoNetwork developer mailing list archive at Nabble.com.

Hi,

···

I am pretty interested in looking into the code of GeoNetwork, so first I
imported the project from Github repository by using clone URL, but after
that, there are many errors saying that some particular class can not be
found.

I do not have much experience of working with such a big project, and things
like maven and ant are new to me, although I have them installed already.

Can anyone help me out? Thanks in advance!

First, you can use maven to generate the classpaths of the different projects around geonetwork using the following command line (at the toplevel of your source tree):
$ mvn eclipse:eclipse

Then you should be able to import the different projects into eclipse. Even better (but can take more time), you can also tell maven to download the source jars of the underlying dependencies using an extra -DdownloadSources=true to the previous command. So that you will be able to debug code that is not “pure geonetwork” (spring for example).

That’s all for the pure “eclipse” setup issue.

To debug and hard modify the code, it’s a bit more complicated. What I generally do is when I want to add a service or so, I proceed using Test Driven Development, creating the new classes then a test class that I can launch/debug into eclipse (alt+shift+d t to launch a specific test method).

Once done and when I’m almost sure of my code, I compile GN with maven (clean install), and I deploy the webapp with jetty (mvn jetty:run in the web/ subdirectory) or in tomcat, using a JDWP port to hook the whole thing directly into eclipse. (calling your jvm with the following arguments should do it: agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n). Then in eclipse, you can create a new debug configuration of type “remote”, and directly debug the code. Hot code replacement works some time but I never found the feature very stable, being desynchronized very often, without taking the time to figure it out why. Some other people around here use a proprietary tool called JRebel, I personnaly don’t.

That’s all for the tricks I use on a day-by-day basis, maybe the other developers would have things to share, hoping that’ll help anyway,

cheers,

– Pierre

On Sat, Jul 11, 2015 at 11:24 AM, Pierre Mauduit
<pierre.mauduit@anonymised.com> wrote:

Hi,

I am pretty interested in looking into the code of GeoNetwork, so first I
imported the project from Github repository by using clone URL, but after
that, there are many errors saying that some particular class can not be
found.

I do not have much experience of working with such a big project, and
things
like maven and ant are new to me, although I have them installed already.

Can anyone help me out? Thanks in advance!

First, you can use maven to generate the classpaths of the different
projects around geonetwork using the following command line (at the toplevel
of your source tree):
$ mvn eclipse:eclipse

Then you should be able to import the different projects into eclipse. Even
better (but can take more time), you can also tell maven to download the
source jars of the underlying dependencies using an extra
-DdownloadSources=true to the previous command. So that you will be able to
debug code that is not "pure geonetwork" (spring for example).

That's all for the pure "eclipse" setup issue.

To debug and hard modify the code, it's a bit more complicated. What I
generally do is when I want to add a service or so, I proceed using Test
Driven Development, creating the new classes then a test class that I can
launch/debug into eclipse (alt+shift+d t to launch a specific test method).

Once done and when I'm almost sure of my code, I compile GN with maven
(clean install), and I deploy the webapp with jetty (mvn jetty:run in the
web/ subdirectory) or in tomcat, using a JDWP port to hook the whole thing
directly into eclipse. (calling your jvm with the following arguments should
do it: agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n).
Then in eclipse, you can create a new debug configuration of type "remote",
and directly debug the code. Hot code replacement works some time but I
never found the feature very stable, being desynchronized very often,
without taking the time to figure it out why. Some other people around here
use a proprietary tool called JRebel, I personnaly don't.

That's all for the tricks I use on a day-by-day basis, maybe the other
developers would have things to share, hoping that'll help anyway,

cheers,

-- Pierre

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at
http://sourceforge.net/projects/geonetwork

Hi,

There is an "easier" way to do it. Latest versions of eclipse already
have the maven plugin, so you can "import as maven project" all the
projects on the repository. Once you have all the projects imported,
there will be a web-app project, which is the one that you have to add
to the Tomcat server inside eclipse.

But there is a trick. Eclipse doesn't like the "classes" folder inside
the "web/src/main/webapp/WEB-INF" folder. So you have to temporarily
remove (or move) the classes folder and then right click on "web-app"
project and select "Maven -> update".

After the update finishes and you restore the classes folder, you will
be able to select the web-app project for the Tomcat server. Then, you
can either Run or Debug the server to run or debug GeoNetwork.

Fixed!

Eclipse will show a lot of errors, mostly XSLT errors. Don't worry about them.

Eclipse will also show some errors about the automatically classes
generated on the domain project not found. This classes have a name
similar to GroupId_. Note the "_" at the end of the name. This won't
prevent eclipse to run Tomcat, but you can search on the target folder
of the domain project where are this classes generated and add the
folder as source folder (right click over the folder).

Hope this helps,
María.