AD

J2EE project with Maven2 to build (b)

Developers to use the internal storage, only modify the local project pom.xml, add the repository configuration:

<repository>
      <id>companyName</id>
      <url>** ${ip}/maven</url>
</repository>


3. Daily build in order to ensure project quality, early discovery projects in the bug, we need to build the system daily, and this is one of our original intention to use maven, maven a few commands you can help us accomplish this task Of course, we can continue to build tools and automatically build maven with implementation time. Construction method:

mvn test
mvn package
mvn install


maven will automatically compile, test, run all the testcase, it also requires that we developers have to write unit test code in accordance with the rules, otherwise, the meaning of the daily build is not much. appfuse framework provides a good unit test code, including for the database layer, business logic, web presentation layer, and so, if we can write the unit tests good, then the follow-up of defects in the system management and control is much helpful.

When construction is completed or the need to build the latest version of the project to Deploy, Easy Ciri arrangements for testers to test, maven provide a variety of deployment, the deployment project in the pom.xml configuration of different deployment of the agreement different configurations are also different:
Be deployed to the file

<project>
        [...]
        <distributionManagement>
            <repository>
                <id>proficio-repository</id>
                <name>Proficio Repository</name>
                <url>file://${basedir}/target/deploy</url>
            </repository>
        </distributionManagement>
        [...]
    </project>


Be deployed to SSH2

<project>
        [...]
        <distributionManagement>
            <repository>
                <id>proficio-repository</id>
                <name>Proficio Repository</name>
                <url>scp://sshserver.yourcompany**/deploy</url>
            </repository>
            </distributionManagement>
        [...]
    </project>


Be deployed to SFTP

<project>
    [...]
    <distributionManagement>
        <repository>
            <id>proficio-repository</id>
            <name>Proficio Repository</name>
            <url>sftp://ftpserver.yourcompany**/deploy</url>
        </repository>
    </distributionManagement>
    [...]
    </project>


Way to extend the deployment of SSH

So far these 3 ways Maven has been included, so long as distributionManagement on it, but extend the use of SSH command to deploy, then you not only need to configure distributionManagement also need a build extension, the following

<project>
        [...]
        <distributionManagement>
            <repository>
                <id>proficio-repository</id>
                <name>Proficio Repository</name>
                <url>scpexe://sshserver.yourcompany**/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>
        [...]
    </project>


The build extension specifies the use of the Wagon external SSH provider, which does the work of moving your files to the remote server. Wagon is the general purpose transport mechanism used throughout Maven.
The build extension specifies the use of the Wagon external SSH provider, which does the work of moving your files to the remote server. Wagon is the general purpose transport mechanism used throughout Maven.

Be deployed by FTP

<project>
        [...]
        <distributionManagement>
        <repository>
            <id>proficio-repository</id>
            <name>Proficio Repository</name>
            <url>ftp://ftpserver.yourcompany**/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>
        [...]
    </project>


Once you have configured the corresponding POM you can run the following command to start the deployment:
mvn deploy

Also generated by the following command in the report of this project site for use by project participants.
mvn site

III. Conclusions

maven powerful Clearly, there are many other features this article does not mention, such as various types of plug-in support, and modules for the project management division and inheritance, these are the characteristics of maven, maven is on a detailed interpretation of the project life cycle , deeply interested in my TX can download the tutorials provided in the annex "Better Builds With Maven2". Meanwhile, I also created a set of my appfuse project under the framework can be used in the myeclipse environment, we can discuss improved.

Annex 1: artifactory for the Maven2 build internal development team to develop a genuine warehouse Detailed After using Maven is customized for the team, so we should not use the official website of the development libraries, should set up an internal development in the local library on the team's jar package management, so we first set up an internal database environment, in addition to the structures described in the article above, Apache server method, we can also use the artifactory (Download: ****jfrog**/sites/artifactory / latest /), A good internal maven repository applications, download the implementation bin directory artifactory.bat command. Starts within the library can access the console ** ip: 8081/artifactory / authentication service is started successfully. The default user name is admin, password is password. artifactory most important thing is to configure third-party jar package, and deploy artifacts to add to the development of their groupId and artifactId (do not forget to change the local of the pom.xml file package to introduce a new increase of the jar.)
In the development side we need to change the global configuration file setting.xml files, project setting.xml into the local maven2-> conf directory, configure the address of the internal storage, only the mirrors in the setting.xml element by adding the following configuration:

<mirror>
      <id>emay local</id>
      <mirrorOf>central</mirrorOf>
      <name>emay local artifactory</name>
      <url>** Internal library ip:8081/artifactory/repo</url>
    </mirror>


It should be noted here that in adding this code I am using appfuse application server that comes with the framework to build tomcat6 can not function properly, tomcat error report, or to remove this application server will be changed in the pom.xml is operating normally after tomcat5.5. It seems there are a lot of bug maven needs to be improved.

Configuration to complete before you can run mvn install to build normal, maven will look for the library from the domestic project depends jar package. Run mvn clean clean maven build files.

Annex 2: maven2 command Daquan

validate, verify the project is correct, all required resources are available.
compile, compile the project's source code.
test-compile, compile the project the test code.
test, using compiled test code, test the compiled source code.
package, the format has been released, such as jar, will have compiled the source code package.
integration-test, the test can be run in the integrated environment management and distribution package.
verify, run any checks, verify the package is valid and meets quality standards.
install, the package is installed in the local repository, other projects can be used as a dependent
deploy, in the integration or release environment, the final version of the package will be copied to the remote repository, so other developers or projects can be shared.
generate-sources, generate any additional required application source code, such as xdoclet.
标签: business logic, presentation layer, unit test, test code, target, implementation time, web presentation, database layer, project quality, testcase, maven, local project, construction method, maven2, system management, deployment project, internal storage, logic web, time construction, discovery projects
分类: Development
时间: 2011-01-11

相关文章

  1. To build a J2EE project with Maven2

    I. Background Maven2 The basic principle is simple, using local storage and remote storage and pom (project ob ...
  2. Construction of the J2EE project with Maven2

    One. Background Maven2 The basic principle is very simple, using a remote repository and local warehouses and ...
  3. Maven2 integration to build a J2EE project

    1. Background Maven2 basic principle is very simple, the use of remote storage and local storage, as well as p ...
  4. Quickly create a project using Maven2

    Quickly create a project using Maven2 source address: http://www.intellij.org.cn/portal/index.php?option=com_c ...
  5. J2EE project coding standards

    J2EE project coding standard "! - Body start -" Package naming standards: Objective: To package nami ...
  6. j2ee project command rules

    Original from: http://www.yuanma.org/data/2009/0922/article_3930.htm Specifications for the purpose of the cod ...
  7. Development of commonly used open source J2EE project

    Read other people's records, feel good, on the collection here, Original Source: http://blog.csdn.net/fenixsha ...
  8. J2EE project data persistence layer design

    J2EE project data persistence layer design Data Persistence Layer design goal is to provide a high level throu ...
  9. J2EE project structure best practices

    J2EE project structure best practices article Category: Java programming project-based worst practice can be s ...
  10. J2EE project real exception handling

    Why talk about exceptions in J2EE project, deal with it? Many java beginners may want to say: "Exception ...
  11. JavaMail can not send messages to resolve the error (in the J2EE project)

    This semester course is a j2ee project, the last time that the teacher checks the registration when our projec ...
  12. _ Turn exception handling J2EE project

    Exception Handling J2EE project Why talk about exceptions in J2EE project, deal with it? Many java beginners m ...
  13. Different J2EE project development process

    A typical J2EE project which is usually the development process should use it? There are many popular developm ...
  14. Briefly on the J2EE project team personnel structure of the view

    Some people do a summary: a J2EE project team usually how people structure, or, how a J2EE project usually req ...
  15. Maven2 build J2EE project, "non-coded map GBK character"

    Down a RichFaces source code, compile the source code with Maven2.x, Java files appear in Chinese, the command ...
  16. Maven2 build J2EE project, "non-coding mapping GBK character"

    Under a RichFaces source code, compile the source code with Maven2.x, Java files appear in Chinese, the comman ...
  17. flex + blazeDS integration j2ee project

    Records about integration blazeDS and flex in the process of j2ee projects: Preparation: eclipse plug-ins inst ...
  18. j2ee project started

    Came to Shenzhen to fast more than two months and has been busy with work, things going on holiday these days, ...
  19. MyEclipse configure Tomcat, the deployment j2ee project

    Configure Tomcat: 1. Point Configure Server 2. Figure Set Deploy j2ee projects: 1. Point on the left of the ic ...