官术网_书友最值得收藏!

Configuring a build tool

Building a java software project typically includes some activities as follows:

  • Compiling all the source code
  • Packaging the compiled code into a JAR or WAR archive file
  • Deploying the packaged archives files on a server

Manually performing all these tasks is time-consuming and is prone to errors. Therefore, we take the help of a build tool. A build tool is a tool that automates everything related to building a software project, from compiling to deploying.

Time for action - installing the Maven build tool

There are other build tools that are available for building Java projects such as Gradle and Ant. We are going to use Maven as our build tool. Let's take a look at how we can install Maven:

  1. Go to Maven's download page at http://maven.apache.org/download.cgi.
  2. Click on the apache-maven-3.3.9-bin.zip download link and start the download.

    Tip

    At the time of writing this book, the latest Maven version is 3.3.9; you can literally use any version of Maven after 3.0 to complete this book.

  3. Once the download is finished, go to the downloaded directory and extract the .zip file into a convenient directory of your choice.
  4. Now we need to create one more environment variable called M2_HOME in a way that is similar to the way in which we created JAVA_HOME. Enter the extracted Maven zip directory's path as the value for the M2_HOME environment variable.
  5. Finally, append the M2_HOME variable to the PATH environment variable as well. Double-click on the path variable and click on the New button to enter %M2_HOME%\bin as the value.

    Setting the M2 environment variable

  6. Now we have installed the Maven build tool in our computer. To verify whether our installation has been carried out correctly, we need to follow steps that are similar to the Java installation verification. Open a new command window, type mvn -version and press Enter; you will see the following details of the Maven version:
    C:\Users\Amuthan>mvn -version
    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
    Maven home: C:\Program Files\apache-maven-3.3.9
    Java version: 1.8.0_91, vendor: Oracle Corporation
    Java home: C:\Program Files\Java\jdk1.8.0_91\jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
    
主站蜘蛛池模板: 惠来县| 延寿县| 乌鲁木齐县| 呼伦贝尔市| 灵台县| 黎平县| 海丰县| 永春县| 碌曲县| 濮阳县| 克什克腾旗| 松溪县| 抚远县| 南京市| 平遥县| 诏安县| 荆门市| 浏阳市| 淮滨县| 喜德县| 曲阜市| 莎车县| 旌德县| 万载县| 塔河县| 皮山县| 威信县| 湛江市| 霍邱县| 都兰县| 娄烦县| 禄丰县| 柳江县| 林周县| 云浮市| 大悟县| 二连浩特市| 苍梧县| 朝阳县| 台北市| 鹰潭市|