index.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. .. _maven_guide:
  2. Maven Guide
  3. ===========
  4. A reference for building GeoServer with Maven.
  5. Installing Maven
  6. ----------------
  7. See :ref:`tools`.
  8. Running Maven
  9. -------------
  10. Maven provides a wide range of commands used to do everything from compiling a
  11. module to generating test coverage reports. Most maven commands can be run from
  12. the root the source tree, or from a particular module.
  13. .. note::
  14. When attempting to run a maven command from the root of the source tree
  15. remember to change directory from the root the checkout into the ``src``
  16. directory.
  17. When running a command from the root of the source tree, or from a directory
  18. that contains other modules the command will be run for all modules. When
  19. running the command from a single module, it is run only for that module.
  20. Building
  21. --------
  22. The most commonly maven command used with GeoServer is the install command::
  23. mvn clean install
  24. While the ``clean`` command is not necessary, it is recommended. Running this
  25. command does the following:
  26. * compiles source code
  27. * runs unit tests
  28. * installs artifacts into the local maven repository
  29. Skipping tests
  30. --------------
  31. Often it is useful to skip unit tests when performing a build. Adding the flag
  32. ``-DskipTests`` to the build command will only compile unit tests, but not run
  33. them::
  34. mvn -DskipTests clean install
  35. Building offline
  36. ----------------
  37. Maven automatically downloads dependencies declared by
  38. modules being built. In the case of SNAPSHOT dependencies,
  39. Maven downloads updates each time it performs the first build of the day.
  40. GeoServer depends on SNAPSHOT versions of the GeoTools library.
  41. The automatic download can result in lengthy build time
  42. while Maven downloads updated GeoTools modules.
  43. If GeoTools was built locally, these downloads are not necessary.
  44. Also, if GeoTools is being modified locally, then the local versions
  45. rather than SNAPSHOT versions of modules should be used.
  46. This can be remedied by running maven in "offline mode"::
  47. mvn -o clean install
  48. In offline mode Maven will not download external dependencies,
  49. and will not update SNAPSHOT dependencies.
  50. Building extensions
  51. -------------------
  52. By default, extensions are not included in the build. They are added to the
  53. build explicitly via :ref:`profiles <profiles>`. For example the following
  54. command adds the ``restconfig`` extension to the build::
  55. mvn clean install -P restconfig
  56. Multiple extensions can be enabled simultaneously::
  57. mvn clean install -P restconfig,oracle
  58. A special profile named ``allExtensions`` enables all extensions::
  59. mvn clean install -P allExtensions
  60. .. _profiles:
  61. Recover Build
  62. -------------
  63. * After fixing a test failure; you can "resume" from a specific point in the build::
  64. mvn install -rf extension/wps
  65. * Recover from a 301 Redirect
  66. A long standing bug in Maven from 2.0.10 handling of 301 errors when an artifact has been moved.
  67. The work around is to run Maven with the option::
  68. mvn install -Dmaven.wagon.provider.http=httpclient
  69. This is not a common issue.
  70. Profiles
  71. --------
  72. Additional profiles are defined in the pom.xml files providing optional build steps. Profiles are directly enabled with the \-P flag, others are automatically activated based on platform used or a \-D property being defined.
  73. To build the release module as part of your build::
  74. -Drelease
  75. To include remote tests::
  76. -PremoteOwsTests
  77. Profiles are also used manage optional extensions community plugins::
  78. -Pproxy
  79. -Poracle
  80. -Pupload
  81. -Pwps
  82. Additional profiles are defined in the pom.xml files providing optional build steps. Profiles are directly enabled with the \-P flag, others are automatically activated based on platform used or a \-D property being defined.
  83. To build javadocs with UML graph::
  84. -Duml
  85. To build the release module as part of your build::
  86. -Drelease
  87. To include the legacy modules::
  88. -Plegacy
  89. To include remote tests::
  90. -PremoteOwsTests
  91. Profiles are also used manage several of the optional community plugins::
  92. -Pupload
  93. -Pwps
  94. -Pproxy
  95. Generating test coverage reports
  96. --------------------------------
  97. Test coverage reports can be generated by running tests with the `jacoco` profile enabled::
  98. mvn test -Pjacoco
  99. Coverage reports are generated in the `target/site/jacoco` directory of each module.
  100. Running the web module with Jetty
  101. ---------------------------------
  102. The maven jetty plugin can be used to run modules which are web based in an
  103. embedded Jetty container::
  104. cd geoserver_2.0.x/src/web/app
  105. mvn jetty:run
  106. .. note::
  107. This command must be run from the web/app module, it will fail if run from
  108. elsewhere.
  109. The above command will run GeoServer with the built in data directory. To
  110. specify a different data directory the ``GEOSERVER_DATA_DIR`` flag is used::
  111. mvn -DGEOSERVER_DATA_DIR=/path/to/datadir jetty:run
  112. Building the web module
  113. -----------------------
  114. When the ``web`` module is installed, it does so with a particular configuration
  115. built in. By default this is the ``minimal`` configuration. However this can be
  116. customized to build in any configuration via the ``configId`` and
  117. ``configDirectory`` flags. For example::
  118. mvn clean install -DconfigId=release -DconfigDirectory=../../../data/release
  119. The above command builds the web module against the release configuration that
  120. is shipped with GeoServer. The ``configId`` is the name of the configuration
  121. directory to include, and the ``configDirectory`` is the parent directory of the
  122. configuration directory to include.
  123. This can also be used when running the local jetty application server:
  124. mvn jetty:run -DconfigId=release -DconfigDirectory=../../../data/release
  125. You may also use an absolute path, if you have a custom data directory you would like to use.