Ê.ï.í., Èâàíîâà È.Â., ìàãèñòðàíò Ñóþíäóêîâ Ð.À.

Êîñòàíàéñêèé ãîñóäàðñòâåííûé óíèâåðñèòåò èì. À. Áàéòóðñûíîâà

 

 

BUILD ENTERPRISE APPLICATIONS

 

         One of the distinguishing features of the Java platform is its independence from the tools used . You can develop an arbitrarily large Java application using notepad and command line . It is clear that no one does so , and all use some IDE. As a consequence of the independence of tools - IDE for Java lot. All is good, but there is one feature . If your colleagues are doing and the application to build the project using IDE Eclipse then IDE Netbeans, which costs you - build the application will not work.

         In general it is no longer a problem. A good practice is to use the build system does not depend on IDE. For more than three of their Java : Apache-Ant, Maven ( also in general, Apache), Gradle etc. . But there is one caveat . If Delphi or Visual Studio, to create and build the application need to click in the button new walk up the steps of the wizard and click to collect , writing ant script and configuration file pom.xml in maven to build such web applications, especially for the novice developer , the task not trivial .

         The article discusses the assembly and deploy Java applications step by step.

If there are problems , then there must be solutions . I think most developers at least once, but faced with Ant. Very many people use Gradle. There are other less common tools : GAnt, Buildr, etc. Each of them has its set of pros and cons , but today I want to introduce you to maven.

life cycle maven:

·validate — validates metadata about the project

·compile — compiles source

·test — runs the tests classes from the previous step

·package — packages the compiled classes in a format easy to move around (jar or war, for example)

·integration-test — sends classes are packed in integration testing environment and runs the tests

·verify — validates the package and satisfied with the quality requirements

·install — drives the package to your local repository, where he (Pecatu) will be available for use as a dependency in other projects

·deploy — sends the packet to the remote production server, where other developers can get it and use

         Thus all steps consistent. And if, for example , perform $ mvn install, it will actually be implemented steps: validate, compile, test, package, integration-test, verify, install. Thus, use maven is quite simple. Written code that executed mvn compile and can be worked on , making sure that the code does not contain syntax and logic errors.

         Configure pom.xml. Here we add a public plugin to build the project (maven-assembly-plugin). Configure it to build the project into a single file to startup phase package, this plugin was doing his job . The final contents of the file pom.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project 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/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>example</groupId>

    <artifactId>example-rinsoft</artifactId>

    <version>1.0-SNAPSHOT</version>

    <build>

        <plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-assembly-plugin</artifactId>

                <version>2.2.1</version>

                <configuration>

                    <descriptorRefs>

                        <descriptorRef>jar-with-example</descriptorRef>

                    </descriptorRefs>

                </configuration>

                <executions>

                    <execution>

                        <id>make-assembly</id>

                        <phase>package</phase>

                        <goals>

                            <goal>single</goal>

                        </goals>

                    </execution>

                </executions>

            </plugin>

        </plugins>

    </build>

    <dependencies>

        <dependency>

            <groupId>log4j</groupId>

            <artifactId>log4j</artifactId>

            <version>1.2.17</version>

        </dependency>

        <dependency>

            <groupId>org.hibernate</groupId>

            <artifactId>hibernate-core</artifactId>

            <version>4.3.4.Final</version>

        </dependency>

        <dependency>

            <groupId>org.springframework</groupId>

            <artifactId>spring-core</artifactId>

            <version>4.0.3.RELEASE</version>

        </dependency>

    </dependencies>

</project>

pom.xml contains the project object model (Project Object Model). POM contains all the important information about your project. This is a very simple POM, but contains key elements. Let us consider each of them to introduce you to the POM:

         -project-this top-level element in all the files pom.xml Maven.

         -modelVersion-ýthe element indicates which version of the object model that uses the POM. 

         -groupId-this element indicates the unique identifier of the organization or group who created the project. GroupId is one of the key identifiers of the project and, as a rule, based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated GroupId for all Maven plugins.

         -artifactId-this element indicates the unique name of the primary database artifacts generated by this project. The main artifact for the project, as a rule, JAR-file. Typical production Maven artifact will look <artifactId> -. <version> <extension> (example, example-1.0.jar).

         -packaging-this element indicates the type of package that will be used this artifact (eg, JAR, WAR, EAR, etc.). This not only means that if an artifact produced by JAR, WAR, or EAR, but can also indicate a specific lifecycle for use as part of the assembly process. EAR - if it is from what we do not need or project jar file (Rutaceae to a project that contains a description). Depending on what type you choose, such an assembly will be (Build Web application is different from the desktop).

         -version-this element indicates a version of the artifact generated by the project. Maven goes a long way to help you to version control, and you will often see the SNAPSHOT version designation that indicates that the project is in development.

         -description-this element is a general description of your project, which is often used in the generation of documentation Maven.

In the console write-> mvn package, after all the procedures in the project folder appears target file-example-1.0-SNAPSHOT-jar-with-example.jar, which is a necessary file with libraries and all its dependencies.

         Thus, efektivnost use maven is not a small effect it gives when building an application project that saves time and streamlines the process of application development.

Literature

1. Maven: The Definitive Guide. Publisher: O'Reilly Media. Released: 2008.

2. Maven: A Developer's Notebook.  Publisher: O'Reilly Media  Released: 2005.

3. http://ru.wikipedia.org/wiki/Apache_Maven

4. http://maven.apache.org/