GettingStarted:Environment_Setup_eclipse_setup_git_clone



From:https://wiki.opendaylight.org/view/GettingStarted:Developer_Main


Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.
settings.xml is not required (and thus not autocreated in ~/.m2 folder) unless you want to change the default settings.
Standalone maven and the maven in eclipse will use the same local repository (~/.m2 folder). This means if some artifacts/dependencies are downloaded by standalone maven, it will not be again downloaded by maven in eclipse.
Based on the version of Eclipse that you use, you may have different maven version in eclipse compared to the standalone. It should not matter in most cases.
The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.
There are two locations where a settings.xml file may live:
  • The Maven install: ${maven.home}/conf/settings.xml
  • A user’s install: ${user.home}/.m2/settings.xml

Environment_Setup

https://wiki.opendaylight.org/view/GettingStarted:Development_Environment_Setup

sudo apt-get install openjdk-8-jdk
sudo apt-get install maven
sudo apt-get install git-core



gin1994@ubuntu:/etc/maven$ sudo chmod 777 settings.xml

[sudo] password for gin1994: 

gin1994@ubuntu:/etc/maven$ wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > settings.xml


sudo apt-get install wireshark

Eclipse-setup


NEW: Fully automated opendaylight-eclipse-setup based on Eclipse Installer (Oomph)
https://github.com/vorburger/opendaylight-eclipse-setup



  1. Download the Eclipse package ("for Java EE Developers", "for Java Developers" and "for RCP and RAP Developers" all seem to work) and extract it into your home directory.
  2. Increase the memory for the Eclipse installation by modifying the eclipse.ini file in the same directory as the eclipse executable.
    • Change the -Xmx setting to be AT least 1G, recommended 2GB. (i.e. -Xmx2048m ). Note: This file may be in a different location depending on your OS. Refer to eclipse documentation if you don't see the file.
    • Also change the PermGen space (-XX:MaxPermSize) to be at least 512MB, i.e., -XX:MaxPermSize=512m. If you are only using 1 GB for max memory, then I would suggest 300 MB to start for PermSize.


       3. Install Eclipse Maven Integration(not required if you use Eclipse Luna)
  1. From Eclipse, go to Help => Install New Software...
  2. Paste "http://download.eclipse.org/technology/m2e/releases" into the "Work with:" field
  3. Select m2e and (optionally) m2e - slf4j both (1.4.0 is current as of the writing of these instructions)
  4. Click Next, OK and Finish else until things install
  5. Restart Eclipse when it asks


       4.Install Eclipse Tycho integration
  1. From Eclipse, go to Help => Install New Software...
  2. Paste http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.7.0/N/0.7.0.201309291400/ into the "Work with:" field.
  3. Select the Tycho Project Configurators. Click Next, OK, Finish etc until it installs (ignore the unsigned content warning by clicking "OK" in the form).
  4. Restart Eclipse when it asks.


       5.Install the build-helper-maven plugin (this allows eclipse to see yang/xtend generated directories            as source folders)
  1. From Eclipse, go to Windows => Preferences, expand the Maven folder and select Discovery.
  2. In the right panel, click 'Open Catalog'.
  3. Type 'build' in he Find box to filter the list.
  4. You should see 'buildhelper' listed. Select it and click Finish.
  5. Click Next in the following 2 panels, accept the license terms and click Finish (ignore the unsigned content warning by clicking "OK" in the form).
  6. Restart Eclipse when it asks.






        6. If you are planning to import the YANG Tools project, also take the following steps:

  1. Install the Eclipse Xtend plugin
    1. From Eclipse, go to Help => Install New Software...
    2. Paste "http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases" into the "Work with:" field
    3. Click Next, OK and Finish else until things install
    4. Restart Eclipse when it asks
      • If you still have issues after install the plugin, you might try:
        1. When installing the xtend plugin, uncheck "Show only the latest versions of available software" and "Group items by category", if necessary.
        2. Select Xtend SDK 2.4.3.XXX and Xtend M2E extensions 2.4.3.XXX
          There are newer versions, however some users have reported having issues with newer versions.

        2.Install Groovy plugin
  1. From Eclipse, go to Help => About, and note what eclipse version you have (4,4, 4.3, 4.2 etc).
  2. From Eclipse, go to Help => Install New Software...
  3. In the "Work with:" field, paste http://dist.springsource.org/release/GRECLIPSE/e4.4 and hit Enter. Note: if you have an earlier eclipse version, change 4.4 to that version, e.g http://dist.springsource.org/release/GRECLIPSE/e4.3 for version 4.3
  4. Select 'Groovy-Eclipse' and 'm2e Confgurator for Groovy-Eclipse' to install.
  5. Click Next, accept the license terms and click Finish.
  6. Restart Eclipse when it asks.


Automatically Avoiding Trailing Whitespace

OpenDaylight (at least in the controller project) will refuse to compile code which has trailing whitespaces in in. Eclipse can be configured to automatically eliminate them for Java files.
  1. Go to Window => Preferences (or "Eclipse => Preferences" on a Mac), expand Java => Editor and click "Save Actions"
  2. check "Perform the selected actions on save" and "Additional actions", but uncheck the rest
  3. click "Configure..." next to the additional actions (expand the form's window if you don't see the button).
  4. Check "Remove trailing whitespace" and "All lines" on the first tab ("Code Organizing"), uncheck everything else on the other tabs
    • (at the bottom of the form you should see "1 of 27 save actions activated"; the "1" in the message is important, the "27" can differ if not in version 4.4).
    • (while the other save actions in the "1" part are likely harmless, they will result in spurious changes if you save files that other people created without those options)

Automatically Using Spaces instead of Tabs


  1. Go to Preferences
  2. Go to Java => Code Style => Formatter
  3. Click "edit" next to the "Active Profile"
  4. Go to the "Indentation" tab
  5. Change the tab policy to "Spaces only"
  6. Click OK




Gerrit Setup

OpenDaylight Controller:Setting up HTTP in Gerrit

https://wiki.opendaylight.org/view/OpenDaylight_Controller:Setting_up_HTTP_in_Gerrit


git clone https://<your_username>@git.opendaylight.org/gerrit/p/controller.git


Install Dependencies

Ubuntu 13.10/14.04 (assuming maven already installed using this guide)


 sudo apt-get install pkg-config gcc make ant g++ git libboost-dev libcurl4-openssl-dev \
    libjson0-dev libssl-dev openjdk-7-jdk unixodbc-dev xmlstarlet

Attention: openjdk-8-jdk instead if using jdk8.


Pull code via https(or via git CLI,ssh)

FIXME: The project names need to be updated.
for PROJECT in aaa affinity bgpcep controller defense4all dlux docs groupbasedpolicy integration/distribution l2switch \
lispflowmapping odlparent opendove openflowjava openflowplugin opflex ovsdb packetcable releng/autorelease \
releng/builder reservation sdninterfaceapp sfc snbi snmp snmp4sdn tcpmd5 toolkit ttp vtn yangtools; \
do git clone https://git.opendaylight.org/gerrit/${PROJECT}.git ${PROJECT}; \
done

Checkout Stable branch

git checkout stable/<release name>

Checkout Release tag


git checkout tags/release/<release name>




Test the Code


Build and Run Karaf distribution

git clone https://git.opendaylight.org/gerrit/p/integration/distribution.git



Build the integration code skipping test:

cd distribution
mvn clean install -Pq


Run the just created Karaf distribution:

cd distribution-karaf/target/assembly
bin/karaf




Importing the Source Into Eclipse

  1. Pull the code from the command line and build it with these instructions. The short version is:
    1. Pull the code: git clone ssh://<username>@git.opendaylight.org:29418/controller.git
    2. Build the code: cd controller && MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=512m" mvn clean install You can also build from opendaylight/distribution/opendaylight, but it just builds the distribution as opposed to building everything
      The long version is available here GettingStarted:Pulling,_Hacking,_and_Pushing_All_the_Code_from_the_CLI.
    3. Incase you face issues with Non-Resolvable POM Parent Error while compiling, you can check whether you have settings.xml properly configured as mentioned in below link (See Edit ~/ml2/settings.xml section)
  1. Import all of the OpenDaylight projects into eclipse
    1. From Eclipse, go to File => Import => Maven => Existing Maven Projects
    2. Browse to the root directory of the git repository
    3. All of the projects should be selected by default, just click Finish
    4. It may ask you to install Tycho, do so if it asks (This should be a 1 time deal. Make sure you have enough memory allocated otherwise it can cause Eclipse to hang and eventually crash)
    5. It may also complain about jacoco, you should be able to ignore those errors


Here I import controller,l2switch,toolkit projects.


Debugging the Controller

As it is no longer possible to build OpenDayLight cleanly in Eclipse, the only way to debug it is to use remote debugging. If you attempt to run or debug OpenDayLight from Eclipse, you will end up with a build failure reporting over 100000 errors and most likely run out of memory as well.

Attaching the Debugger to a Running ODL

Using Eclipse you can debug a locally running, or a remote running controller. Thankfully, the way you do either debugging is the same. First you start ODL with a debug flag, and then you tell Eclipse to attach to the running application via IP. If it is a local instance, use localhost, otherwise provide the hostname or IP address of the remote server!

To remotely debug the controller you first need to start ODL with the -debug flag, or just debug since Helium release.
  1. Start the controller with the -debug flag passed to the run.sh script.
    ./run.sh -debug   
    This starts the controller, opening up port 8000 for debugging.
    Since Helium, start the controller with the debug flag passed to the karaf.sh script.
    ./karaf.sh debug 
    This starts the controller, opening up port 5005 for debugging.
  2. In Eclipse choose Run->"Debug Configurations"
    • Under "Remote Java Application" choose a standard connection type, and enter the hostname (localhost or remote controller name) and port (8000 by default).
    • Under the "Source" tab click "Add" and then "Java Project". This will give you a list of all java projects in the workspace. Select them all and click OK a few times to close out of the dialogs.
      Note: this should only be required once per debug configuration.
    • Click debug to launch the debugger.













评论

此博客中的热门博文

openflow switch(I)

YANG Tools:YANG to Java Mapping

OpenDaylight架构简介