概要文件构建会覆盖pom.xml中的项目构建吗?

时间:2018-11-14 16:42:25

标签: java maven spring-boot maven-2 maven-plugin

我是Maven的新手,我正在从事一个maven项目,该项目的pom.xml是针对springframework生成的。阅读以下两个指南后,我遇到了一些无法找到或无法回答的问题:

https://www.tutorialspoint.com/maven/

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

这是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>com.ingicare.algo</groupId>
  <artifactId>packdiff-core</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>algo</name>
  <description>Algorithm project</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/>
    <!-- lookup parent from repository -->
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <java.version>1.8</java.version>
    <javax.inject.version>1</javax.inject.version>

    <spring-cloud.version>Brixton.SR1</spring-cloud.version>

    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>

    <docker.image.prefix>ingicare</docker.image.prefix>
    <dockerfile-maven-plugin.version>1.3.6</dockerfile-maven-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>${spring-cloud.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- swagger 2 plus ui-->
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.8.0</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>2.8.0</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.openpnp</groupId>
      <artifactId>opencv</artifactId>
      <version>3.2.0-0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.pdfbox</groupId>
      <artifactId>pdfbox</artifactId>
      <version>2.0.12</version>
    </dependency>
    <dependency>
      <groupId>org.apache.pdfbox</groupId>
      <artifactId>pdfbox-tools</artifactId>
      <version>2.0.12</version>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>spring-boot:run</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven-resources-plugin.version}</version>
        <executions>
          <execution>
            <id>default-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>target/classes</outputDirectory>
              <useDefaultDelimiters>false</useDefaultDelimiters>
              <delimiters>
                <delimiter>#</delimiter>
              </delimiters>
              <resources>
                <resource>
                  <directory>src/main/resources/</directory>
                  <filtering>true</filtering>
                  <includes>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                  </includes>
                </resource>
                <resource>
                  <directory>src/main/resources/</directory>
                  <filtering>false</filtering>
                  <excludes>
                    <exclude>**/*.xml</exclude>
                    <exclude>**/*.yml</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>dockerfile-maven-plugin</artifactId>
        <version>${dockerfile-maven-plugin.version}</version>
        <configuration>
          <repository>${docker.image.prefix}/${project.artifactId}</repository>
          <buildArgs>
            <JAR_FILE>target/${project.build.finalName}.war</JAR_FILE>
          </buildArgs>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>local</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
              <warSourceDirectory>src/main/webapp/</warSourceDirectory>
              <packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
              <executable>true</executable>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <properties>
        <!-- log configuration -->
        <logback.loglevel>DEBUG</logback.loglevel>
        <!-- default Spring profiles -->
        <spring.profiles.active>local</spring.profiles.active>
      </properties>
    </profile>
  </profiles>

</project>

编辑:

这是我的问题:

1)如果“本地”配置文件构建也存在于主构建生命周期中,那么它们是否会覆盖插件?我的猜测是,如果选择了

2)主构建是“本地”配置文件构建和主构建生命周期的组合吗?

3)我注意到某些插件未定义阶段或目标。意思是不是 有一个默认的(特定于插件)由Maven选择?我的猜测是

0 个答案:

没有答案