maven2 use Xiangjie

http://www.cnblogs.com/flyingzqx/archive/2009/12/03/1616201.html
maven2 start I believe everyone maven1 already very familiar with the specific maven can do, is not explained in detail. Personally feel that the open-source projects using maven or relatively more within the company, it is not clear. I've used the company for some time, but that was not below the.
With the maven1 compared, maven2 can be regarded as virtually rewritten, but from the speed it should be faster.
Several major new features include: (detailed reference http://www.ibm.com/developerworks/cn/opensource/os-maven2/index.html)
1. Faster and easier than the ant can be in terms of speed of
2. Fewer configuration file configuration file is now only in the settings.xml and pom.xml.
3. Plugin language change language began to support java, BeanShell, and ant
4. Provides a pre-defined template, which is most helpful, users can define their own project their own template, just as the same as with the appfuse project structure is generated
5. The introduction of life-cycle in the Maven2 have a clear concept of life cycle, but also offer corresponding command, making the project to build a more clarity.
6. New Dependency Scope
This is also more important, some are used for test range of packages, you can not join the dependence of the
7. Transitive dependencies, simplifying dependency management it is most convenient, and can save a lot of configuration. As a dependent on b, b will be dependent on a dependent on c default c. But will also have hidden dangers, such as the version of the conflict. But maven has also been taken into account, and can be used exclusions to exclude duplication of the corresponding dependence.

Introduced so many, and now cut into the issues that are beginning maven2 Tour:
The first need to download these tools:
maven2: http://maven.apache.org/download.html the most important
maven-proxy: to proxy repository, use the local library instead of the remote repository maven2
http://maven-proxy.codehaus.org/
continuum: a nice continuous integration tool for automated build. Support for ant, maven
http://maven.apache.org/continuum/
svn: version control tools that have been configured.
maven for eclipse plug-ins, the main station in the maven has downloaded, it is true plug-ins. Of course, there are a corresponding plug-in idea
Finally, http, the server is essential. Developed for internal use.
You can use apache, or the jetty http://www.mortbay.org/

maven2 installation:
Install maven2 is very simple to download to the maven package solved on the list. (Currently I have the configuration in win2003, but also does not apply to linux, all of the configuration for all the windows). To increase the corresponding environment variable m2_home = maven2 installation directory, do not forget to set java_home directory. Also in path to increase% m2_home% \ bin; can be used directly in the command line the following mvn.
Other tools installed in the follow-up article will introduce.

Start the first one mvean2 projects:
mvn archetype: create-DgroupId = com.mycompany.app \-DartifactId = my-app
Brief groupId equivalent of your organization, as org.springframework, will be converted to the corresponding, local path artifactId, you have the main jar package name, that is, you have beaten the name of the jar.
To compile application resources
mvn compile
Compiling the corresponding test class jave file is compiled and run test class
mvn test
If you want to compile test class to run test, the implementation of
mvn test-compile
Packaging and installation of your local library Package: mvn package
Installation: mvn install
Create a web site: mvn site
Clear all output: mvn clean
Ide to create the relevant file mvn idea: idea or mvn eclipse: eclipse

By the way, maven2 is a life-cycle concept, meaning that if you are running package, the corresponding previous steps, such as compile, test and so will automatically.
The beginning of the implementation would be more slow and therefore require a remote database from the maven2 to download all the files to the local. If you are local there is no corresponding dependence on packet, then the time will go to a remote maven to download, so to configure an image library is more important.

-------------------------------------------------- ------------------------------

maven configuration chapter of the settings.xml
maven2 configuration file mainly concentrated in the pom.xml and settings.xml.
First it said the settings.xml, settings.xml for maven is the equivalent of overall configuration, used for all projects. The maven2 exist two settings.xml, one in maven2 installation directory conf the following as the overall configuration. For the team setting, the definition of consistency is the key, so maven2/conf following settings.xml as a team on a common configuration file. Ensure that all team members have the same configuration. Of course, for each member, we need a special custom settings, such as user information, so another one settings.xml on as a local configuration. The default location: $ (user.dir) / .m2/settings.xml directory ($ (user.dir) refers to windows in the user directory).
settings.xml basic structure is as follows:
<settings xmlns="http://maven.apache.org/POM/4.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                              http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
      <localRepository/> 
      <interactiveMode/> 
      <usePluginRegistry/> 
      <offline/> 
      <pluginGroups/> 
      <servers/> 
      <mirrors/> 
      <proxies/> 
      <profiles/> 
      <activeProfiles/> 
    </settings> 

A brief look at the configuration of several major factors:
localRepository: said location to save the local library, which is the main maven2 save jar location, the default in the $ (user.dir) / .m2/repository, if you need another set, they replace the other path.
offline: If you do not want to compile every time, have to go find a remote central repository, it is set to true. Of course, the premise is that you have already downloaded the necessary dependency packages.
Servers: The distributionManagement element in the POM defines the development of libraries. However, the specific username and pwd can not be used in the pom.xml, so to save the server through this configuration information
 <servers> 
    <server> 
      <id>server001</id> 
      <username>my_login</username> 
      <password>my_password</password> 
      <privateKey>${usr.home}/.ssh/id_dsa</privateKey> 
      <passphrase>some_passphrase</passphrase> 
      <filePermissions>664</filePermissions> 
      <directoryPermissions>775</directoryPermissions> 
      <configuration></configuration> 
    </server> 
  </servers> 

id: server's id, used to match distributionManagement database id, more important.
username, password: used to login to this server's user name and password
privateKey, passphrase: set the private key, and passphrase
filePermissions, directoryPermissions: When the library file or directory is created, you need permission to visit. The light of unix file permissions, such as the 664 and 775
Mirrors: Mirror said the library, specify the database mirroring, used to increase the other libraries
<mirrors> 
    <mirror> 
      <id>planetmirror.com</id> 
      <name>PlanetMirror Australia</name> 
      <url>http://downloads.planetmirror.com/pub/maven2</url> 
      <mirrorOf>central</mirrorOf> 
    </mirror> 
  </mirrors> 

id, name: the only sign used to distinguish between the mirror
url: mirror url
mirrorOf: This image points to the service id
Proxies: mainly used in the library can not be direct access to the central user profile.
<proxies> 
    <proxy> 
      <id>myproxy</id> 
      <active>true</active> 
      <protocol>http</protocol> 
      <host>proxy.somewhere.com</host> 
      <port>8080</port> 
      <username>proxyuser</username> 
      <password>somepassword</password> 
      <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts> 
    </proxy> 
  </proxies> 

id: Agent logo
active: whether the activation agent
protocol, host, port: protocol: / / host: port proxy
username, password: user name and password
nonProxyHosts: no proxy host
Profiles: The profile is similar to pom.xml elements include activation, repositories, pluginRepositories and properties elements in the beginning of contact, it may be more confusing, this is actually maven2 of the more powerful functions. Literally speaking, is the personality configuration. After a separate profile definition, and will not enter into force, by meeting the conditions to activate.
repositories, and pluginRepositories
The definition of other development libraries and library plug-in development. For the team, it certainly has its own development library. This configuration can be defined.
The following configuration, defines a local development bank, for release release.
<repositories> 
       <repository> 
          <id>repo-local</id> 
          <name>Internal  Development library  </name> 
          <url>http://192.168.0.2:8082/repo-local</url> 
          <releases> 
            <enabled>true</enabled> 
            <updatePolicy>never</updatePolicy> 
            <checksumPolicy>warn</checksumPolicy> 
          </releases> 
          <snapshots> 
            <enabled>false</enabled> 
          </snapshots> 
          <layout>default</layout> 
       </repository> 
    </repositories> 
    <pluginRepositories> 
      <pluginRepository> 
        <id>repo-local</id> 
        <name>Internal  Development library  </name> 
        <url>http://192.168.0.2:8082/repo-local</url> 
        <releases> 
            <enabled>true</enabled> 
            <updatePolicy>never</updatePolicy> 
            <checksumPolicy>warn</checksumPolicy> 
        </releases> 
        <snapshots> 
          <enabled>false</enabled> 
        </snapshots> 
        <layout>default</layout> 
      </pluginRepository> 
    </pluginRepositories> 

releases, snapshots: for each product version of the Release or snapshot (Note: release and the snapshot of the difference between, release version is generally more stable, while the snapshot is basically unstable, only as a snapshot)

properties: maven of the properties as a placeholder value, such as the ant's properties.
Includes the following 5 types of values:
1. Env.X, returns the current environment variables
2. Project.x: Back pom defined in the element values, such as project.version
3. Settings.x: Back to the elements defined in settings.xml
4. Java system property: All After java.lang.System.getProperties () Returns the value of the
5. X: set the value of the user's own
Activation: used to activate this profile
 <activation> 
        <activeByDefault>false</activeByDefault> 
        <jdk>1.5</jdk> 
        <os> 
          <name>Windows XP</name> 
          <family>Windows</family> 
          <arch>x86</arch> 
          <version>5.1.2600</version> 
        </os> 
        <property> 
          <name>mavenVersion</name> 
          <value>2.0.3</value> 
        </property> 
        <file> 
          <exists>${basedir}/file2.properties</exists> 
          <missing>${basedir}/file1.properties</missing> 
        </file> 
  </activation> 

jdk: If you match the specified jdk version, will be activated
os: operating system
property: If maven can detect the corresponding attribute
file: the file is used to determine the existence or non-existent

In addition to using activation to activate the profile, can also be activated by activeProfiles
ActiveProfiles
That activated profile, through the profile id to specify.
<activeProfiles> 
    <activeProfile>env-test</activeProfile>  Specifies the id of the profile  
  </activeProfiles>


-------------------------------------------------- ------------------------------

maven configuration chapter of the pom.xml

pom as a project object model. Xml indicated by maven project, use the pom.xml to achieve. Mainly describes the project: including the configuration file; developers need to follow the rules, the defect management system, organization and licenses, the project url, project dependencies, as well as all the other project-related factors.
Quick View:
<project> 
  <modelVersion>4.0.0</modelVersion>

  <!-- The Basics --> 
  <groupId>...</groupId> 
  <artifactId>...</artifactId> 
  <version>...</version> 
  <packaging>...</packaging> 
  <dependencies>...</dependencies> 
  <parent>...</parent> 
  <dependencyManagement>...</dependencyManagement> 
  <modules>...</modules> 
  <properties>...</properties>

  <!-- Build Settings --> 
  <build>...</build> 
  <reporting>...</reporting>

  <!-- More Project Information --> 
  <name>...</name> 
  <description>...</description> 
  <url>...</url> 
  <inceptionYear>...</inceptionYear> 
  <licenses>...</licenses> 
  <organization>...</organization> 
  <developers>...</developers> 
  <contributors>...</contributors>

  <!-- Environment Settings --> 
  <issueManagement>...</issueManagement> 
  <ciManagement>...</ciManagement> 
  <mailingLists>...</mailingLists> 
  <scm>...</scm> 
  <prerequisites>...</prerequisites> 
  <repositories>...</repositories> 
  <pluginRepositories>...</pluginRepositories> 
  <distributionManagement>...</distributionManagement> 
  <profiles>...</profiles> 
</project>


Basic elements:
POM includes all the project information.
maven-related: pom defines the smallest maven2 elements, allowing groupId, artifactId, version. All the required elements of
groupId: project or organization's unique identifier, and the configuration, the resulting path could result from the generation, such as the relative path org.codehaus.mojo build: / org / codehaus / mojo
artifactId: the common name of the project
version: the version of the project
packaging: packaging of mechanisms, such as pom, jar, maven-plugin, ejb, war, ear, rar, par
classifier: classification
POM relationship:
Is mainly dependent on, inheritance, synthesis dependency relations:
 <dependencies> 
    <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.0</version> 
      <type>jar</type> 
      <scope>test</scope> 
      <optional>true</optional> 
    </dependency> 
    ... 
  </dependencies> 

groupId, artifactId, version: description of the project rely on the only sign may be installed in the following ways:
Use the following command to install:
· Mvn install : install-file-Dfile = non-maven-proj.jar-DgroupId = some.group-DartifactId = non-maven-proj-Dversion = 1
Create your own libraries, and configuration, use the deploy: deploy-file
* Set this depends range system, define a system path. Is not recommended.
type: the corresponding forms of reliance on product packages, such as jar, war
scope: to limit the scope of the corresponding dependence, including the following several variables:
· Compile : the default scope, used by the compiler provided: similar to compile, but the support you expect jdk or containers provided, similar to the classpath
· Runtime : in the implementation, the need to use the test: used to test the use of the task system: need to get outside to provide the corresponding element. To get through the systemPath
systemPath: only for the range of system. Provide the appropriate path
optional: marked optional, when the project is also dependent on their own time. For the continuous use of exclusive reliance on external maven tell you only the specified items, not including related dependency. This version of the main factors used to resolve conflicts
 <dependencies> 
    <dependency> 
      <groupId>org.apache.maven</groupId> 
      <artifactId>maven-embedder</artifactId> 
      <version>2.0</version> 
      <exclusions> 
        <exclusion> 
          <groupId>org.apache.maven</groupId> 
          <artifactId>maven-core</artifactId> 
        </exclusion> 
      </exclusions> 
    </dependency> 

Said the project maven-embedder needs of the project maven-core, but we do not want to quote maven-core

Inheritance another powerful change, maven brings the project inheritance. The main settings:
The definition of the parent project
<project> 
  <modelVersion>4.0.0</modelVersion> 
  <groupId>org.codehaus.mojo</groupId> 
  <artifactId>my-parent</artifactId> 
  <version>2.0</version> 
  <packaging>pom</packaging> 
</project> 

packaging type of pom for the parent and the need for synthesis of multiple projects. We need to increase the value of corresponding to the parent pom, for subprojects inherit. The main elements are as follows:
Dependent developers and collaborators list of plug-in implementation of plug-ins list of statements using the appropriate matching ids
Plug-in configuration sub-project configuration
<project> 
  <modelVersion>4.0.0</modelVersion> 
  <parent> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>my-parent</artifactId> 
    <version>2.0</version> 
    <relativePath>../my-parent</relativePath> 
  </parent> 
  <artifactId>my-project</artifactId> 
</project> 

relativePath can do without, but it used to indicate a parent directory, for fast queries.

dependencyManagement:
For the parent co-project configuration dependence, the main configuration dependent on package the same factors, such as version, scope.

Synthesis of (or multiple modules)
A project has multiple modules, also known as multiple modules, or the synthesis of the project.
The following definition:
<project> 
  <modelVersion>4.0.0</modelVersion> 
  <groupId>org.codehaus.mojo</groupId> 
  <artifactId>my-parent</artifactId> 
  <version>2.0</version> 
  <modules> 
    <module>my-project1<module> 
    <module>my-project2<module> 
  </modules> 
</project>


build setting is mainly used to compile settings, including the two main elements, build, and report
build
Is divided into two parts, the basic elements and extend elements of a collection of note: including project build and profile build
<project> 
  <!-- "Project Build" contains more elements than just the BaseBuild set --> 
  <build>...</build> 
  <profiles> 
    <profile> 
      <!-- "Profile Build" contains a subset of "Project Build"s elements --> 
      <build>...</build> 
    </profile> 
  </profiles> 
</project>


Basic elements
<build> 
  <defaultGoal>install</defaultGoal> 
  <directory>${basedir}/target</directory> 
  <finalName>${artifactId}-${version}</finalName> 
  <filters> 
    <filter>filters/filter1.properties</filter> 
  </filters> 
  ... 
</build> 

defaultGoal: define a default target, or stage. Such as the install
directory: the directory to compile the output
finalName: the style of the final document is generated
filter: Definition filter, used to replace the corresponding properties file, use the maven-defined properties. Set the value of all placehold

Resources (resources)
You need to specify the project resources. Such as the spring configuration file, log4j.properties
<project> 
  <build> 
    ... 
    <resources> 
      <resource> 
        <targetPath>META-INF/plexus</targetPath> 
        <filtering>false</filtering> 
        <directory>${basedir}/src/main/plexus</directory> 
        <includes> 
          <include>configuration.xml</include> 
        </includes> 
        <excludes> 
          <exclude>**/*.properties</exclude> 
        </excludes> 
      </resource> 
    </resources> 
    <testResources> 
      ... 
    </testResources> 
    ... 
  </build> 
</project> 

resources: resource list, including all the resources used for
targetPath: specify the target path, for the placement resources for build
filtering: whether to replace the properties of resources placehold
directory: the location of resources
includes: styles, including those resources
excludes: exclude resources
testResources: test resource list of plug-in build, the implementation of the plug-in, more useful parts, such as using jdk 5.0 compiler, etc.
<project> 
  <build> 
    ... 
    <plugins> 
      <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-jar-plugin</artifactId> 
        <version>2.0</version> 
        <extensions>false</extensions> 
        <inherited>true</inherited> 
        <configuration> 
          <classifier>test</classifier> 
        </configuration> 
        <dependencies>...</dependencies> 
        <executions>...</executions> 
      </plugin> 
    </plugins> 
  </build> 
</project> 

extensions: true or false, whether the load plug-in extensions. Default false
inherited: true or false, whether this plug-in configuration will be used in poms, who inherited this project
configuration: specify the plug-in configuration
dependencies: plug-ins need to rely on the package
executions: used to configure the execution objectives, a plug-in can have multiple targets.
Are as follows:
<plugin> 
        <artifactId>maven-antrun-plugin</artifactId>

        <executions> 
          <execution> 
            <id>echodir</id> 
            <goals> 
              <goal>run</goal> 
            </goals> 
            <phase>verify</phase> 
            <inherited>false</inherited> 
            <configuration> 
              <tasks> 
                <echo>Build Dir: ${project.build.directory}</echo> 
              </tasks> 
            </configuration> 
          </execution> 
        </executions> 
      </plugin> 

Description:
id: a unique identifier that provides execution
goals: the target
phase: that stage, the objective would be at what stage in the implementation of
inherited: and the above elements, as set false maven will be refused to implement the succession to the sub plug-ins
configuration: indicates that this implementation of the configuration properties

Plugin Manager
pluginManagement: plug-in manager in the same way, including plug-in element, is used in a specific project configuration. All subprojects inherit this project can use. The main elements of the definition of a common plug-ins

Expansion of the main elements of the collection include the following elements:
Directories
Used to set up a variety of directory structure, as follows:
<build> 
    <sourceDirectory>${basedir}/src/main/java</sourceDirectory> 
    <scriptSourceDirectory>${basedir}/src/main/scripts</scriptSourceDirectory> 
    <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory> 
    <outputDirectory>${basedir}/target/classes</outputDirectory> 
    <testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory> 
    ... 
  </build>


Extensions

Expressed the need for expansion of plug-ins to be included in the corresponding build path.

<project> 
  <build> 
    ... 
    <extensions> 
      <extension> 
        <groupId>org.apache.maven.wagon</groupId> 
        <artifactId>wagon-ftp</artifactId> 
        <version>1.0-alpha-3</version> 
      </extension> 
    </extensions> 
    ... 
  </build> 
</project>


Reporting
Site phase of the output is used to report. Specific output of the corresponding maven plug-in can be customized and configured reports.
<reporting> 
    <plugins> 
      <plugin> 
        <outputDirectory>${basedir}/target/site</outputDirectory> 
        <artifactId>maven-project-info-reports-plugin</artifactId> 
        <reportSets> 
          <reportSet></reportSet> 
        </reportSets> 
      </plugin> 
    </plugins> 
  </reporting>


Report Sets
Used to configure the different objectives, used in different reports
<reporting> 
    <plugins> 
      <plugin> 
        ... 
        <reportSets> 
          <reportSet> 
            <id>sunlink</id> 
            <reports> 
              <report>javadoc</report> 
            </reports> 
            <inherited>true</inherited> 
            <configuration> 
              <links> 
                <link>http://java.sun.com/j2se/1.5.0/docs/api/</link> 
              </links> 
            </configuration> 
          </reportSet> 
        </reportSets> 
      </plugin> 
    </plugins> 
</reporting>


More project information
name: Project In addition artifactId addition, you can define multiple names
description: Project Description
url: item url
inceptionYear: Founding Year

Licenses
<licenses> 
  <license> 
    <name>Apache 2</name> 
    <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> 
    <distribution>repo</distribution> 
    <comments>A business-friendly OSS license</comments> 
  </license> 
</licenses>


Organization
Configuration Organization Information
  <organization> 
    <name>Codehaus Mojo</name> 
    <url>http://mojo.codehaus.org</url> 
  </organization>


Developers
Configuration Developer Information
<developers> 
    <developer> 
      <id>eric</id> 
      <name>Eric</name> 
      <email>eredmond@codehaus.org</email> 
      <url>http://eric.propellors.net</url> 
      <organization>Codehaus</organization> 
      <organizationUrl>http://mojo.codehaus.org</organizationUrl> 
      <roles> 
        <role>architect</role> 
        <role>developer</role> 
      </roles> 
      <timezone>-6</timezone> 
      <properties> 
        <picUrl>http://tinyurl.com/prv4t</picUrl> 
      </properties> 
    </developer> 
  </developers>


Contributors
 <contributors> 
    <contributor> 
      <name>Noelle</name> 
      <email>some.name@gmail.com</email> 
      <url>http://noellemarie.com</url> 
      <organization>Noelle Marie</organization> 
      <organizationUrl>http://noellemarie.com</organizationUrl> 
      <roles> 
        <role>tester</role> 
      </roles> 
      <timezone>-5</timezone> 
      <properties> 
        <gtalk>some.name@gmail.com</gtalk> 
      </properties> 
    </contributor> 
  </contributors>


Environment Settings

Issue Management
Related to the definition bug tracking systems such as bugzilla, testtrack, clearQuest, etc.
<issueManagement> 
    <system>Bugzilla</system> 
    <url>http://127.0.0.1/bugzilla</url> 
  </issueManagement> 

Continuous Integration Management
Continuous integration management, based on triggers or timings
 <ciManagement> 
    <system>continuum</system> 
    <url>http://127.0.0.1:8080/continuum</url> 
    <notifiers> 
      <notifier> 
        <type>mail</type> 
        <sendOnError>true</sendOnError> 
        <sendOnFailure>true</sendOnFailure> 
        <sendOnSuccess>false</sendOnSuccess> 
        <sendOnWarning>false</sendOnWarning> 
        <configuration><address>continuum@127.0.0.1</address></configuration> 
      </notifier> 
    </notifiers> 
  </ciManagement>


Mailing Lists
<mailingLists> 
    <mailingList> 
      <name>User List</name> 
      <subscribe>user-subscribe@127.0.0.1</subscribe> 
      <unsubscribe>user-unsubscribe@127.0.0.1</unsubscribe> 
      <post>user@127.0.0.1</post> 
      <archive>http://127.0.0.1/user/</archive> 
      <otherArchives> 
        <otherArchive>http://base.google.com/base/1/127.0.0.1</otherArchive> 
      </otherArchives> 
    </mailingList> 
  </mailingLists>


SCM
Software configuration management, such as cvs and svn
 <scm> 
    <connection>scm:svn:http://127.0.0.1/svn/my-project</connection> 
    <developerConnection>scm:svn:https://127.0.0.1/svn/my-project</developerConnection> 
    <tag>HEAD</tag> 
    <url>http://127.0.0.1/websvn/my-project</url> 
  </scm>


Repositories

Configuration with the development of libraries in setting.xml

Plugin Repositories
Configuration with the repositories

Distribution Management
The distribution for configuration management, configuration corresponding product release information, and is mainly used for publishing, said after the implementation of the mvn deploy the location you want to publish
One configuration to the file system
<distributionManagement> 
<repository> 
<id>proficio-repository</id> 
<name>Proficio Repository</name> 
<url>file://${basedir}/target/deploy</url> 
</repository> 
</distributionManagement>

2 using the ssh2 Configure
<distributionManagement> 
<repository> 
<id>proficio-repository</id> 
<name>Proficio Repository</name> 
<url>scp://sshserver.yourcompany.com/deploy</url> 
</repository> 
</distributionManagement> 

3 configured to use sftp
<distributionManagement> 
<repository> 
<id>proficio-repository</id> 
<name>Proficio Repository</name> 
<url>sftp://ftpserver.yourcompany.com/deploy</url> 
</repository> 
</distributionManagement> 

4 the use of external ssh configuration compiler extension to specify the use of wagon external ssh to provide for the provision of your file to the appropriate remote server.
<distributionManagement> 
<repository> 
<id>proficio-repository</id> 
<name>Proficio Repository</name> 
<url>scpexe://sshserver.yourcompany.com/deploy</url> 
</repository> 
</distributionManagement> 
<build> 
<extensions> 
<extension> 
<groupId>org.apache.maven.wagon</groupId> 
<artifactId>wagon-ssh-external</artifactId> 
<version>1.0-alpha-6</version> 
</extension> 
</extensions> 
</build>


5 using the ftp configuration
<distributionManagement> 
<repository> 
<id>proficio-repository</id> 
<name>Proficio Repository</name> 
<url>ftp://ftpserver.yourcompany.com/deploy</url> 
</repository> 
</distributionManagement> 
<build> 
<extensions> 
<extension> 
<groupId>org.apache.maven.wagon</groupId> 
<artifactId>wagon-ftp</artifactId> 
<version>1.0-alpha-6</version> 
</extension> 
</extensions> 
</build>


repository corresponding to the development of libraries in your user information through the settings.xml in the server to obtain

Profiles
Similar to the settings.xml in the profiles, an increase of several elements, the following style:
 <profiles> 
    <profile> 
      <id>test</id> 
      <activation>...</activation> 
      <build>...</build> 
      <modules>...</modules> 
      <repositories>...</repositories> 
      <pluginRepositories>...</pluginRepositories> 
      <dependencies>...</dependencies> 
      <reporting>...</reporting> 
      <dependencyManagement>...</dependencyManagement> 
      <distributionManagement>...</distributionManagement> 
    </profile> 
  </profiles>


-------------------------------------------------- ------------------------------

Use maven2 for the team to configure it for the team, the establishment of a unified development environment is necessary, but maven could very well help to establish a unified environment. Here's how to more effectively carry out a unified configuration.
Preparation:
Download the necessary software:
maven2: http://maven.apache.org/download.html the most important
maven-proxy: to proxy repository, using a proxy to access multiple remote repository
http://maven-proxy.codehaus.org/
continuum: a nice continuous integration tool for automated build. Support for ant, maven
http://maven.apache.org/continuum/
svn: version control tool

To create a consistent development environment

In a shared development environment, a better proposal is to maintain the maven of the two different configuration files to be administered separately, including the sharing and user-defined settings. Common configurations included in the installation directory, but separate development settings are saved in the user's local directory.

The global configuration file settings.xml

<servers> 
       // The company's internal library, all of the release version  ,serverid Corresponds to the repository ID used to access the deploy, use, mainly to save user name and password  
<server> 
<id>internal</id> 
<username>${website.username}</username> 
<password>${website.pwd}</password> 
<filePermissions>664</filePermissions> 
<directoryPermissions>775</directoryPermissions> 
</server> 
// The present development library, library for snapshot  
<server> 
<id>snapshot</id> 
<username>${website.username}</username> 
<password>${website.pwd}</password> 
<filePermissions>664</filePermissions> 
<directoryPermissions>775</directoryPermissions> 
</server> 
</servers>

<profiles> 
<!-- Defining the core library maven mirrors  , By maven  -proxy Implementation  --> 
<profile> 
<id>central-repo</id> 
<repositories> 
<repository> 
<id>central</id> 
<name>Internal Repository</name> 
<url>http://192.168.0.2:9999/repository</url> 
</repository> 
</repositories> 
<pluginRepositories> 
<pluginRepository> 
<id>central</id> 
<name>Internal Repository</name> 
<url>http://192.168.0.2:9999/repository</url> 
</pluginRepository> 
</pluginRepositories> 
</profile>

<!-- Define an internal library, including all of the company's release version  --> 
<profile> 
<id>internal-repo</id> 
<repositories> 
<repository> 
<id>internal</id> 
<name>Internal Repository</name> 
<url>http://192.168.0.2:8080/repo-local</url> 
<releases> 
<enabled>true</enabled> 
<updatePolicy>never</updatePolicy> 
<checksumPolicy>warn</checksumPolicy> 
</releases> 
</repository> 
</repositories> 
<pluginRepositories> 
<pluginRepository> 
<id>internal</id> 
<name>Internal Plugin Repository</name> 
<url>http://192.168.0.2:8080/repo-local</url> 
<releases> 
<enabled>true</enabled> 
<updatePolicy>never</updatePolicy> 
<checksumPolicy>warn</checksumPolicy> 
</releases> 
</pluginRepository> 
</pluginRepositories> 
</profile> 
<!-- Define an internal development library, or you can merge snapshot and release  --> 
<profile> 
<id>snapshot-repo</id> 
<repositories> 
<repository> 
<id>snapshot</id> 
<name>Internal Repository</name> 
<url>http://192.168.0.2:8080/repo-snapshot</url> 
<snapshots> 
<enabled>true</enabled> 
<updatePolicy>interval:60</updatePolicy> 
<checksumPolicy>warn</checksumPolicy> 
</snapshots> 
</repository> 
</repositories> 
<pluginRepositories> 
<pluginRepository> 
<id>snapshot</id> 
<name>Internal Plugin Repository</name> 
<url>http://192.168.0.2:8080/repo-snapshot</url> 
<snapshots> 
<enabled>true</enabled> 
<updatePolicy>interval:60</updatePolicy> 
<checksumPolicy>warn</checksumPolicy> 
</snapshots> 
</pluginRepository> 
</pluginRepositories> 
</profile> 
</profiles> 
<!--  Activate the corresponding get configuration  --> 
<activeProfiles> 
<activeProfile>central-repo</activeProfile> 
<activeProfile>internal-repo</activeProfile> 
<activeProfile>snapshot-repo</activeProfile> 
</activeProfiles> 
<!--  Plug-ins default groupId  --> 
<pluginGroups> 
<pluginGroup>com.mycompany.plugins</pluginGroup> 
</pluginGroups>


Includes the following shared factors:
A typical server settings are common, only the user name needs to set the user environment. The use of consistent definitions to configure the settings common
profile defines the common elements, the internal development of libraries, including the designation of the organization or department released products. These libraries are independent of the core development libraries.
Activation profiles list, used to activate the corresponding profile
plugin group only if your organization has its own plug-ins defined for the command line to run is defined in the pom.
For individual users, set up as follows:

<settings> 
<profiles> 
<profile> 
<id>property-overrides</id> 
<properties> 
<website.username>myuser</website.username> 
<website.pwd>test</website.username> 
</properties> 
</profile> 
</profiles> 
</settings>


Most organizations create a shared development libraries will create their own internal development libraries for the configuration, the center development library for connecting to maven
Set up the internal development library is simple, using http protocol, you can use existing http server. Or create new services, the use of apache, or the jetty
Suppose the server address of 192.168.0.2, port 8080
http://192.168.0.2:8080/repo-local
Set another developer library, used to set the project snapshot repository http://192.168.0.2:8080/repo-snapshot
Center image library, use the maven-proxy creation, of course, you can create your own image. Used to download the artifact is not a local library

maven-proxy settings from the Internet directly to download maven-proxy-standalone-0.2-app.jar and proxy.properties
In the command line, direct run java-jar maven-proxy-standalone-0.2-app.jar proxy.properties
The main configurations:
Set repo.list added to the appropriate library on the can, the following definition:
repo.list = repo1.maven.org, ...
# maven's central repository
repo.repo1.maven.org.url = http://repo1.maven.org/maven2
repo.repo1.maven.org.description = maven.org
repo.repo1.maven.org.proxy = one
repo.repo1.maven.org.hardfail = false
repo.repo1.maven.org.cache.period = 360000
repo.repo1.maven.org.cache.failures = true
After all of the remote database, to increase through this way. By the way, do not forget to note the original example, it is no way to visit.

Other configurations, such as the port number port = 9999
Save the location repo.local.store = target / repo
serverName = http://localhost:9999

Organization to create a standard pom
The definition of common elements, including the company's structure, such as the organizational, departmental and team.
Look at what maven itself can serve as a good reference.
Such as the scm

<project> 
<modelVersion>4.0.0</modelVersion> 
<parent> 
<groupId>org.apache.maven</groupId> 
<artifactId>maven-parent</artifactId> 
<version>1</version> 
</parent> 
<groupId>org.apache.maven.scm</groupId> 
<artifactId>maven-scm</artifactId> 
<url>http://maven.apache.org/maven-scm/</url> 
... 
<modules> 
<module>maven-scm-api</module> 
<module>maven-scm-providers</module> 
... 
</modules> 
</project>    


In the maven parent project can be seen in the following definition:

<project> 
<modelVersion>4.0.0</modelVersion> 
<parent> 
<groupId>org.apache</groupId> 
<artifactId>apache</artifactId> 
<version>1</version> 
</parent> 
<groupId>org.apache.maven</groupId> 
<artifactId>maven-parent</artifactId> 
<version>5</version> 
<url>http://maven.apache.org/</url> 
... 
<mailingLists> 
<mailingList> 
<name>Maven Announcements List</name> 
<post>announce@maven.apache.org</post> 
... 
</mailingList> 
</mailingLists> 
<developers> 
<developer> 
... 
</developer> 
</developers> 
</project> 


maven parent pom includes shared elements, such as a statement e-mail list, developers. Most of the projects and the succession of apache Organization:

<project> 
<modelVersion>4.0.0</modelVersion> 
<groupId>org.apache</groupId> 
<artifactId>apache</artifactId> 
<version>1</version> 
<organization> 
<name>Apache Software Foundation</name> 
<url>http://www.apache.org/</url> 
</organization> 
<url>http://www.apache.org/</url> 
... 
<repositories> 
<repository> 
<id>apache.snapshots</id> 
<name>Apache Snapshot Repository</name> 
<url>http://svn.apache.org/maven-snapshot-repository</url> 
<releases> 
<enabled>false</enabled> 
</releases> 
</repository> 
</repositories> 
... 
<distributionManagement> 
<repository> 
... 
</repository> 
<snapshotRepository> 
... 
</snapshotRepository> 
</distributionManagement> 
</project>    


For the project itself, the parent pom rarely updated. Therefore, the final way to save the parent pom file in a separate version of the control area, they can check out, change and configuration.

Lasting integration of the use of Continuum

Continued integration of auto-build your project, through a certain time, including all of the conflicts in the early detection, rather than the release time. Also continuing the development of integration is also a good way, so that team members can produce subtle, interactive changes to more effectively support parallel development process.
You can use maven as a lasting integration of the continuum of services.
Installation continuum, relatively simple, use the following command:
C: \ mvnbook \ continuum-1.0.3> bin \ win32 \ run
Can http://localhost:8082/continuum to verify in order to support the continuum Send e-mail reminders, you will need the appropriate smtp service for sending messages. Default to localhost: 25, if you do not set up, edit the file above to change the smtp-host setting.
Next, set the svn directory:
svn co http://www.cnblogs.com/flyingzqx/admin/file:///C:/mvnbook/svn/proficio/trunk proficio
Edit pom.xml to get the correct corresponding e-mail address.

... 
<ciManagement> 
<system>continuum</system> 
<url>http://localhost:8080/continuum 
<notifiers> 
<notifier> 
<type>mail</type> 
<configuration> 
<address>youremail@yourdomain.com</address> 
</configuration> 
</notifier> 
</notifiers> 
</ciManagement> 
... 
<scm> 
<connection> 
scm:svn:file://localhost/c:/mvnbook/svn/proficio/trunk 
</connection> 
<developerConnection> 
scm:svn:file://localhost/c:/mvnbook/svn/proficio/trunk 
</developerConnection> 
</scm> 
... 
<distributionManagement> 
<site> 
<id>website</id> 
<url> 
http://www.cnblogs.com/flyingzqx/admin/file:///c:/mvnbook/repository/sites/proficio 
/reference/${project.version} 
</url> 
</site> 
</distributionManagement> 


Submission of the corresponding pom, and then run mvn install

If you return to http://localhost:8082/continuum, you will see a corresponding list of items.

Once you are logged in, you can choose mavan 2.0 project to increase the corresponding projects. You can add your url or submit your local content.

You can use the local pom url, as follows http://www.cnblogs.com/flyingzqx/admin/file:///c:mvnbook/proficio/pom.xml

After this url submission, continuum will return to the success of the corresponding information.
The following principles to better contribute to the sustainability integration:
As early as submitted, are always present: When a user regularly submitted to the constant integration is most effective. This does not mean that the author is not the correct code.
Regular running build: for the failure to detect the earliest amendments were defeated as soon as possible: When the failure occurred, it should be immediately amended version of the failure of the proposed operation of an effective clean build
Running a complex integrated test
build all of the project's structure continued to run the project copy the branch
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of maven2 use Xiangjie

  • Properties with 6 supplementary hibernate.cfg.xml configuration

    In some special circumstances, we may be saved in the database connection information config.properties document, for example, make a install.jsp to modify config.properties documents, implementation of online information on the database configuration. At

  • hibernate the third study (mapping file configuration)

    If you do not want to use the default hibernate.cfg.xml file as a configuration file, we can also specify the configuration file name: File file = new File ( "C: \ \ myhibernate.xml"); Configuration config = new Configuration (). Configure (file

  • Maven 2.0: Compile. Test. Deployment. Run

    <url> http://maven.apache.org </ url> <dependencies> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 3.8.1 </ version> <scope> test </ scope> <

  • Struts2 Spring Hibernate integration of easy

    1. Add Spring 2.0 in Libraries Choose the following four jar, and configure the / WEB-INF/lib under Spring2.0 AOP Libraries Spring2.0 Core Libraries Spring2.0 Persistence Core Libraries Spring2.0 WEb Libraries At the same time, the applicationContext ...

  • Struts2 Spring Hibernate's easy to integrate

    1. Add Spring 2.0 in Libraries Choose the following four jar, and configure the / WEB-INF/lib under Spring2.0 AOP Libraries Spring2.0 Core Libraries Spring2.0 Persistence Core Libraries Spring2.0 WEb Libraries At the same time, the applicationContext ...

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • java read file

    java read documents in two ways: java.io and java.lang.ClassLoader When using the java.io, when java.lang.ClassLoader use it? (Note: If prior to read xml file java read file clearly aware of these two methods have been like! Can take much less to understa

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries