Getting started with maven

I have experience in Ant how to get started with maven. Any advantage with maven over ant?

+3
source share
3 answers

There is quite a big difference where ant forces you to create your own goals, you will get a set of default goals for maven, for example, clean, install, packageetc. without their scripting.

Maven encourages you to use a common directory structure for Java classes, resources, etc. If you do this, maven is only in the file xmlwhere you specify some project metadata, such as name, packageand, most importantly, dependencies, It provides a similar search for dependencies on what ivy is for ant.

maven, . IDE, Netbeans, open project, install .

maven maven. - , . Maven , , , ant, . ( , ), maven - , , Nexus Archiva.

, archetype maven, , , . maven pom.xml, .

. log4j, nececcities ( jar).

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>projectname</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0-SNAPSHOT</version>
    <name>${project.artifactId}</name>
    <url>http://maven.apache.org</url>

    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
    <!-- add more dependencies here ... -->
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
+4

. , Maven Ant.

, (), pom.xml, , build.xml Ant.

. Maven . , , .

eclipse, maven (mvn eclipse:eclipse), .classpath . eclipse.

- maven -

+1

Ant , Maven , - .

, Maven .

, Maven .

http://maven.apache.org/what-is-maven.html

maven, ...

mvn archetype:generate

, . , .

0

Source: https://habr.com/ru/post/1794894/


All Articles