Pesquisar

Este conteúdo não está disponível no idioma selecionado.

Appendix B. Introduction to Apache Maven

download PDF

Apache Maven is a distributed build automation tool used in Java application development to create, manage, and build software projects. You use it to run the AMQ Broker example programs that are included with the AMQ Broker installation.

Running the AMQ Broker example programs requires you to interact with several Maven components:

Project object model (POM) files
Store information about how the project should be built.
Repositories
Hold build artifacts and dependencies.
The Maven settings file
Stores user-specific configuration information.

B.1. Maven POM files

Maven uses standard configuration files called Project Object Model (POM) files to define projects and manage the build process. They ensure that the project is built correctly and uniformly. POM files are XML files (pom.xml).

Maven favors "convention over configuration". Therefore, POM files require minimal configuration and default all other values. A POM file can define the following information for a Maven project:

  • Location of the source, test, and target directories
  • Project dependencies
  • Plug-in repositories
  • Goals that the project can execute
  • Additional details about the project, such as the version, description, developers, mailing list, license, and so on.

Example B.1. Sample pom.xml file

This basic pom.xml file demonstrates the minimum requirements for a POM file:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.jboss.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1</version>
</project>

Additional Resources

B.2. Maven repositories

A Maven repository stores Java libraries, plugins, and other build artifacts. Repositories can be either local or remote.

The default public repository is the Maven 2 Central Repository, but repositories can be private and internal within a company so that common artifacts can be shared among development teams.

Repositories are also available from third-parties. AMQ includes a Maven repository that contains tested and supported versions of the AMQ 7.9 Java packages and dependencies.

Additional resources

B.3. The Maven settings file

The Maven settings.xml file contains user-specific configuration information for Maven. It contains information that must not be distributed with the pom.xml file, such as developer identity, proxy information, local repository location, and other settings specific to a user.

The settings.xml file is found in two locations:

  • In the Maven installation:

    The settings.xml file is located in the <maven-install-dir>/conf/ directory. These settings are referred to as global settings. The default Maven settings file is a template that you can copy and use as a starting point for the user settings file.

  • In the user’s installation:

    The settings.xml file is located in the ${user.home}/.m2/ directory. If both the Maven and user settings.xml files exist, the contents are merged. Where there are overlaps, the user’s settings.xml file takes precedence.

Example B.2. The Maven settings file

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <!-- Configure the JBoss AMQ Maven repository -->
    <profile>
      <id>jboss-amq-maven-repository</id>
      <repositories>
        <repository>
          <id>jboss-amq</id>
          <url>file:///path/to/repo/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>jboss-amq-maven-plugin-repository</id>
          <url>file://path/to/repo</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!-- Optionally, make the repository active by default -->
    <activeProfile>jboss-amq-maven-repository</activeProfile>
  </activeProfiles>
</settings>

Additional resources

Revised on 2022-03-22 15:27:27 UTC

Red Hat logoGithubRedditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja oBlog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

© 2024 Red Hat, Inc.