Mave Project Management Practical Exercise

xiaoxiao2021-03-06  14

Mave Project Management Practical Exercise

Author: Li Junjie

The Mave project is an open source company Apache, which is a tool for project management. It is developed for the shortcomings of Ant projects. In addition to the characteristics of Ant's build projects, there are also project senior management tools, project managers can Easily understand the various situations of the project.

The following combined with the understanding and practice of Maven, the summary is as follows:

u Maven download and installation

u Maven configuration and management

u Maven project inheritance

U Maven and VSS integration

u maven custom javadoc

u Commonly used command Goal

u Maven considerations

Maven download and installation

1) Download Maven, download the latest version of Maven in httart/download.html address (click on Windows.exe, my operating system is Windows), you download the address http:// Www.apache.org/dyn/closer.cgi/maven/binaries/maven-1.0.2.exe, I use HTTP Download (click http://apache.justdn.org/maven/binaries/mAVen-1.0.2. Exe) Download to your location. (I saw a lot of users on the Internet to download Maven failed, so described in detail)

2) Install Maven, if you don't have J2SDK installed on your machine, install J2SDK, then set Java-Home (Windows: My Computer (Right-click) -> Properties -> Advanced -> Environment Variable -> User Variable -> New (New) Such as: Java-Home C: /J2SDK1.4.2_01))), then you can run the maven-1.0.2.exe smooth installation.

3) Set Maven-Home, similar to setting Java-Home, setting such as Maven-Home D: /maven1.02 according to Maven installation path ($ {Maven-home})

4) Open $ {maven-home} /lib/maven.jar with decompression tools (such as WinRAR), find and drag org / apache / maven / messages / message_zh_cn.properties, if Message_zh_CN The code of the .properties file is not the US Information Interchange Standard Code (ASCII), using the Nativie2ASCII command in Java to convert Message_ZH_CN.Properties to US Information Interchange Standard Coding (ASCII). And the converted file name is also named message_zh_cn.properties, then dragged into the maven.jar ORG / APACHE / MAVEN / Messages / Maven / Messages to overwrite the original file. Conversion step: Open the DOS interface, enter D: / BEA / JDK141_03 / bin> native2ascii message_zh_cn.properties Test.properties, then rename Test.properties, rename Message_zh_cn.properties.

5) Start -> Run -> cmd-> Enter the DOS interface, then enter the Maven Enter, if the following case, the installation is successful. Microsoft Windows 2000 [Version 5.00.2195]

(C) All rights reserved 1985-2000 Microsoft Corp.

C: / documents and settings / lijj> maven

- __ __

- | // | __ _Apache_____

- | | | // | / _` / v / -_) '/ ~ Intelligent Projects ~

- | _ | | _ / __, _ | / _ // ___ | _ || _ | v. 1.0.2

-

- Build Successful

- Total Time: 1 seconds

- Finished At: THU Mar 03 16:55:06 CST 2005

-

Maven related configuration and management

Maven's main components include project object model (Repository), repository, and goals, and now illustrates each component based on actual examples. The project object model is generally managing projects with Project.xml, while Repositro is primarily providing the JAR files needed by the project, including different versions, Goals mainly includes Maven.xml and related plugins (Plugs).

Also include attribute files such as Project.properties, build.properties .. The priority of the property file is $ {user.home} /build.properties, $ {basedir} /build.properties, $ {basedir} /project.properties, (where $ {user.home} represents the user directory, C: / Documents and settings / lijj, $ {basedir} Represents project project.properties, such as d: / maventest) priority the highest priority, the latter is the lowest. That is, the latter defines a property, the former also defines the attribute of the same name, the previous person is accurate. Since Maven has inherited concepts in project management, it is not suitable for build.properties files. So we generally don't need build.properties in project management, just use the Project.properties file to define the properties required for the project.

Create a project

As we usually create a project, create a working directory (d: / maventest) and put the relevant project files (such as JSP, Java, Properties, IMG, JS, XML, etc.) COPY to this directory

Create the library required by the project (ie .jar file)

Because Maven advocacy is to implement project management through the network, we use CVS to control the version, now more is more using VSS (Source Safe) to control the version. Maven's repository reflects the idea of ​​centralized management resources, and the network unified management based on the JAR resource files you want to use, and we now tend to use the local resource file.

1) First define in the project's properties file Project.properties

## Local resource location

Maven.repo.local = d: / maven 1.0.2 / repository

## Whether to use remote repository

Maven.repo.remote.Enabled = false2) Secondly, create the project in a local repository to use lib, such as d: / maven 1.0.2 / repository / bjcy / jars, then use the JAR file Copy used to use to this Directory (D: / Maven 1.0.2 / repository / bjcy / jars) Under WebLogic.jar, AppModules.jar, OpenData.jar, etc., use decompression tools (such as WinRAR) to open these JAR files, find meta-inflicity The next manifest.mf file, if you do not find a version instructions, modify the file name (such as jarname.jar-> jarname-.jar, add a horizontal line after the file name), if you find the manifest.mf file, open Seeing Manifest-Version: 1.0, the version number of the JAR file is 1.0, modify the file name (such as jarname.jar-> jarname-1.0.jar)

3) Finally, the resource to depend on the project is written in the Project.xml file.

BJCY

WebLogic

1.0

BJCY

AppModules

. . . . . . . . .

This document indicates that the version of the WebLogic.jar file is 1.0, and the appmodules.jar file has no version instructions, and all JARs to depend on are under BJCy / Jars.

Project.xml file description

Project.xml is the core file of Maven project management, mainly indicating the necessary content of the project.

3

prjCysPAPP

prjCysPAPP

1.1, 1.2, 2.0-snapshot ->

1.0

Beijing ×××× Software Company

http://www.apache.org/

http://maven.apache.org/images/jakarta-logo-blue.gif

2005

prjCysPAPP

http://maven.apache.org/images/maven.jpg

Beijing ×× District Online Approval System

×× District Online Approval Online Service System is under the unified leadership of Beijing, in accordance with unified planning, unified leadership, improved service, improve the principle of efficiency, to promote the reform of administrative examination and approval system, optimize the development environment, to serve Enterprise, service taxpayer is fundamental, based on Beijing e-government network platform, based on online consultation and approval system online consultation and approval system in the existing ×× District Investment Service Hall, establish a unified, social public The ×× area online approval online service system platform, improves the efficiency of work and the quality of public service.

http://maven.apache.org/reference/plugins/examples/

http://nagoya.apache.org/scarab/serveRVlet/scarab/

jakarta.apache.org

/www/maven.apache.org/reference/plugins/examples /

/www/maven.apache.org/builds /

The Connection Element Has The Form:

SCM: : ->

SCM: CVS: PSERVER: Anoncvs@cvs.apache.org: / home / cvspublic: maven-plugins / examples

http://cvs.apache.org/viewcvs/maven-plugins/examples/

Zhang 3

ANLI

ANLI@sohu.com

Beijing ×× Software Companies

Project Manager

Li 4

lijj

lijj@sina.com

Beijing ×× Software Companies

Developer

Wang 5

maj

mj@sina.com

Beijing ×× Changtian Software Company

Developer

Zhao Six

zhxm

zxm@sina.com

Beijing ×× Software Companies

Developer

Beijing ××× Software Company

http://www.openData.com.cn

Download and Install

BJCY

WebLogic

1.0

bjcy AppModules

BJCY

OpenData

1.0

BJCY

lenovo_usermanager

BJCY

jfreechart

0.9.15

BJCY

jdom

1.0

BJCY

Mail

1.0

BJCY

msg

1.0

BJCY

Base64

1.0

BJCY

Log4j

1.2.8

BJCY

SOAP

1.0

BJCY

Xerces

1.0

BJCY

FormServer 1.0

BJCY

DataAccess_client

1.0

BJCY

classes12

BJCY

Axis

1.0

BJCY

ShareClient

1.0

BJCY

saaj

1.0

BJCY

jaxrpc

1.0

BJCY

JCOMMON

1.0

Apache

Log4j

1.2.8

Turbine-maven-dev@jakarta.apache.org

develop / prjbjcyeap / src

TEST / JAVA

** / * Test.java

** / naughtytest.java

SRC / CONF

*. Properties

Project.properties file description

## Local resource location

Maven.repo.local = d: / maven 1.0.2 / repository

## Whether to use remote repository

Maven.repo.remote.enabled = false

## The XML declaration head that should be included in the document

Maven.docs.omitXmldeclaration =

## 代 代 代 代 代 代 编 号 i -8859-1

Maven.docs.outputencoding = GB2312

Maven.xdoc.date = left

## Maven.xdoc.version = $ {pom.currentversion}

# maventest.dir = d: / maventest

## HTML Format Report Output Directory $ {baseDir} is the directory where the Maven.xml file is located

Maven.docs.dest = $ {basedir} / docs

## xdocs documentation Output Directory after HTML

Maven.gen.docs = $ {basedir} / DOCS / XMLDOCS

Maven.build.dest = $ {basedir} / wevelop / prjbjcyeap / classes

Maven.plugin.dir = $ {maven.home} / plugins

## Test Environment IP

Test.host = 192.168.1.249

## Test Environment Foreign Network Deployment Directory

Test.ww.deploy.dir = e $ / maventest / wevelop / prjbjcyeap / wwdomain / applications / bjcyww

## Test environment intranet deployment directory

Test.nw.deploy.dir = e $ / maventest / wevelop / prjbjcyeap / nwdomain / applications / bjcynw

## 本 外 网 环境 环境 部 部 目

Local.ww.deploy.dir = $ {basedir} / wevelop / prjbjcyeap / wwdomain / applications / bjcyww

## 本 外 网 环境 环境 部 部 目

Local.nw.Deploy.dir = $ {basedir} / wevelop / prjbjcyeap / nwdomain / applications / bjcynw

Deploy.attr = LOCAL

Maven.xml file description

XMLns: maven = "jelly: maven"

XMLns: j = "jelly: core" xmlns: util = "jelly: util">

Remote deployment

->

Local deployment

->

Local deployment begins!

The local deployment ends!

Remote deployment ends!

Combine preparation deployment for compiled projects

->

eeeeee

This machine deploys the intranet

->

This unit deployed external network

->

Todir at the time of remote deployment should first start with "//", do not write to Project.Properties, then reference, it will be wrong. And first log in to the remote machine before remote deployment.

->

Remote deployment

->

Remote deployment intranet

->

Maven project inheritance

Maven project inheritance is similar to the mechanism of object inheritance to perform project management, where the Project.xml file, the maven.xml file, and the Project.properties file can inherit, the command goal, attribute, etc. in the above file in the parent project. You can override in the child, if you do not overwrite, call the relevant command or properties of the parent project.

1) Project.xml in the subproject

D: /MAVENTEST/Project.xml

It is indicated that the project is inherited from the D: / Maventest project, which can be a relative directory, a directory where the sub-project's Project.xml file is located.

2) Maven.xml in subproject

There are two ways to inherit the GOAL in the parent project, one is to cover the Goal in the parent project, and the other is to expand the GOAL of the parent, such as

Pregoal said goal to be executed in front of Goal in the parent project

Postgoal said goal to be executed behind the same name Goal in the parent project

->

pregoal

Postgoal

Maven and VSS integration

The main idea of ​​Maven Project Management is network centralized management, so Maven is mainly controlled by CVS, and we now use VSS (Source Safe) to make version management. In order to be able to control the version in project management, provide an integrated approach, add the following Goal to Maven.xml:

The meaning of the main parameters:

LocalPath: Get down code storage location

Recursive = "true": Get all files in a directory (including files below all subdirectory)

Login: SourceSafe username, password

VSSPATH: Directory to get files on SourceSafe

SSDIR: Running Directory in SourceSafe's installation directory (Right-click SourceSafe start icon -> Properties -> Shortcut -> Target)

ServerPath: SourceSafe

Writable = false: GET files are read-only

AutoResponse = "N": If you have a writable file, you have a rename on the SourceSafe, it is not overwritten.

->

LocalPath = "E: / TEST / SRC"

Recursive = "true" login = "lijunjie, lijj"

vsspath = "/ xx approval / App / src"

SSDIR = "E: / Software / VSS / WIN32 /"

ServerPath = "// 192.168.1.188/sourceesafe/"

Writable = "false"

AutoResponse = "n"

Quiet = "True" />

Recursive = "true" login = "lijunjie, lijj"

vsspath = "/ × × Approval / App / NWDOMAIN"

SSDIR = "E: / Software / VSS / WIN32 /"

ServerPath = "// 192.168.1.188/sourceesafe/"

Writable = "false"

AutoResponse = "n"

Quiet = "True"

/>

Recursive = "true" login = "lijunjie, lijj"

vsspath = "/ × × approval / App / wwdomain"

SSDIR = "E: / Software / VSS / WIN32 /" ServerPath = "// 192.168.1.188/sourcesafe/"

Writable = "false"

AutoResponse = "n"

Quiet = "True" />

Maven Custom Javadoc

Maven itself has Javadoc Goal, but its source files, the directory generated by the Javadoc file must be the default, to flexibly customize Javadoc, especially in maven.xml, Goal:

Produced Javadoc ->

Main parameters description:

PackageNames: To produce Javadoc's package name

SourcePath: The location of the source file is relative to the relative directory of the Project.xml file

Destdir: Generate a directory of the Javadoc file, absolute directory

->

Private = "YES" defaultexcludes = "YES" destdir = "$ {basedir} / javadoc">

Commonly used commands Goal

Java: Compile: Compiles all Java source code.

JAR: Create a JAR file that has been compiled source code

Site: generate: Generate the corresponding site file

MAVEN considerations

This document only describes the Maven project management based on a certain item now, and readers will change the corresponding parameters based on different items.

1) In the deployment goal (Maven Project: Deploy) in the parent project, first get the value of the deploy.attr property from the Project.Properties file, determine the remote deployment or local deployment according to the attribute value. Thereby performing the corresponding Goal

2) When you are remotely deployed, you should first log in to the destination machine to be deployed, otherwise an error has an error username and password error.

3) Pay attention to Project.xml, Maven.xml, Project.properties under the same directory.

4) Maven operation Now uses the command line, enter the directory where the project is located, the directory where the Project.xml file is located, such as: D: / SONMAVENTEST>, then enter Maven, then enter the goal to execute, such as: D: / SONMAVENTEST> Maven Project: Deploy

Contact the author:

Email: lijj_72@hotmail.com

转载请注明原文地址:https://www.9cbs.com/read-50772.html

New Post(0)