Maven 系列

Maven - 人生若只如初见(三)

2019-12-19  本文已影响0人  sunyelw

今天来讲讲Maven的基本概念 - 新手村

首先看一条常用命令的执行输出

sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn clean package -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hymvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ hymvn ---
[INFO] Deleting C:\idea\workspace\hymvn\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ hymvn ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\idea\workspace\hymvn\src\main\resources
[INFO] skip non existing resourceDirectory C:\idea\workspace\hymvn\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ hymvn ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to C:\idea\workspace\hymvn\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ hymvn ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\idea\workspace\hymvn\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ hymvn ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\idea\workspace\hymvn\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ hymvn ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ hymvn ---
[INFO] Building jar: C:\idea\workspace\hymvn\target\hymvn-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.2.RELEASE:repackage (default) @ hymvn ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.668 s
[INFO] Finished at: 2019-12-19T21:02:17+08:00
[INFO] Final Memory: 31M/237M
[INFO] ------------------------------------------------------------------------
sunyelw@windows:hymvn$

带着这些问题开始我们的探险.


一、基本概念

二、插件与目标

1. 插件<plugin>

Plugins are artifacts that provide goals to Maven. (插件是为 Maven 提供功能的 构件 <artifacts> )

举例

这些插件都是开源的,可以在github上找到源码

2. 目标<goal>

说到这里,可能还是不知道插件与目标是个什么玩意,还好Maven提供了一个很有用的插件来让我们切身感受一下那个世界的样子~

三、help插件详述

maven插件列表中有一个特殊的插件,可以用于帮助获取一些有用的信息,这个插件的名字就叫 help

help 既然是一个插件,那么它也是由目标组成, 看看其有哪些目标

对于初学者来说最重要的一个目标就是 describe, 通过这个目标可以获取其他的插件的用法(激动一会......)

我们用help插件的describe目标来描述它本身

mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail

看看输出

sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hymvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ hymvn ---
[INFO] Mojo: 'help:describe'
help:describe
  Description: Displays a list of the attributes for a Maven Plugin and/or
    goals (aka Mojo - Maven plain Old Java Object).
  Implementation: org.apache.maven.plugins.help.DescribeMojo
  Language: java

  Available parameters:

    artifactId
      User property: artifactId
      The Maven Plugin artifactId to describe.
      Note: Should be used with groupId parameter.

    cmd
      User property: cmd
      A Maven command like a single goal or a single phase following the Maven
      command line:
      mvn [options] [<goal(s)>] [<phase(s)>]

    detail (Default: false)
      User property: detail
      This flag specifies that a detailed (verbose) list of goal (Mojo)
      information should be given.

    goal
      User property: goal
      The goal name of a Mojo to describe within the specified Maven Plugin. If
      this parameter is specified, only the corresponding goal (Mojo) will be
      described, rather than the whole Plugin.

    groupId
      User property: groupId
      The Maven Plugin groupId to describe.
      Note: Should be used with artifactId parameter.

    minimal (Default: false)
      User property: minimal
      This flag specifies that a minimal list of goal (Mojo) information should
      be given.

    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.

    plugin
      User property: plugin
      The Maven Plugin to describe. This must be specified in one of three
      ways:

      1.  plugin-prefix, i.e. 'help'
      2.  groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
      3.  groupId:artifactId:version, i.e.
        'org.apache.maven.plugins:maven-help-plugin:2.0'

    version
      User property: version
      The Maven Plugin version to describe.
      Note: Should be used with groupId/artifactId parameters.


[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.392 s
[INFO] Finished at: 2019-12-19T21:20:39+08:00
[INFO] Final Memory: 17M/155M
[INFO] ------------------------------------------------------------------------
sunyelw@windows:hymvn$

有了这个插件,其他插件的用法就都可以获知了,激动一会~

看下插件dependencytree目标

sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn help:describe -Dplugin=dependency -Dgoal=tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hymvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ hymvn ---
[INFO] Mojo: 'dependency:tree'
dependency:tree
  Description: Displays the dependency tree for this project.

For more information, run 'mvn help:describe [...] -Ddetail'

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.228 s
[INFO] Finished at: 2019-12-19T21:24:37+08:00
[INFO] Final Memory: 22M/220M
[INFO] ------------------------------------------------------------------------
sunyelw@windows:hymvn$

展示项目的依赖树,执行一下看看效果

sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hymvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ hymvn ---
[INFO] com.hy.demo:hymvn:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.2.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.2.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  |  +- org.springframework:spring-core:jar:5.0.6.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-jcl:jar:5.0.6.RELEASE:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.5:compile
[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.5:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.5:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.31:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.31:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  +- org.springframework:spring-web:jar:5.0.6.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.0.6.RELEASE:compile
[INFO] |     +- org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO] |     +- org.springframework:spring-context:jar:5.0.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework:spring-context-indexer:jar:5.0.6.RELEASE:compile (optional)
[INFO] \- org.springframework.boot:spring-boot-loader:jar:2.0.2.RELEASE:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.499 s
[INFO] Finished at: 2019-12-19T21:26:42+08:00
[INFO] Final Memory: 21M/228M
[INFO] ------------------------------------------------------------------------
sunyelw@windows:hymvn$

很好,完全符合预期效果~

然后我们会用插件了,但插件又是定义在哪的呢?

4. 插件来源

执行一个不存在的插件命令试试

sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn 1:2
[INFO] Scanning for projects...
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/sun/yelw/maven-metadata.xml
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml (9.7 kB at 4.5 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml (21 kB at 9.5 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.839 s
[INFO] Finished at: 2019-12-19T21:28:18+08:00
[INFO] Final Memory: 22M/192M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix '1' in the current project and in the plugin groups [com.sun.yelw, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (F:\repository), alimaven (http://maven.aliyun.com/nexus/content/groups/public/)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
sunyelw@windows:hymvn$

可以看到一个下载过程,说明如果本地插件库中没找到就会去配置好的远程仓库去下载,这里配的alimaven的镜像,故输出如下:

Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/sun/yelw/maven-metadata.xml
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-metadata.xml (9.7 kB at 4.5 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/mojo/maven-metadata.xml (21 kB at 9.5 kB/s)

中间的那个是用户级别的插件仓库,忽略
真正下载的就俩文件

在本地仓库中找到这俩文件,打开来看下:

<plugin>
  <prefix>dependency</prefix>
  <artifactId>maven-dependency-plugin</artifactId>
  <name>Apache Maven Dependency Plugin</name>
</plugin>
<plugin>
  <prefix>deploy</prefix>
  <artifactId>maven-deploy-plugin</artifactId>
  <name>Apache Maven Deploy Plugin</name>
</plugin>

这里面配置的全是插件,我们上面执行的插件都能在里面找到。

还有一个东西挺好玩, 他的文件名会加上仓库的name, 比如 alimaven 的就是 maven-metadata-alimaven.xml

上面报错还有一个地方需要注意

[ERROR] No plugin found for prefix '1' in the current project 
and in the plugin groups 
[com.sun.yelw, org.apache.maven.plugins, org.codehaus.mojo] 
available from the repositories 
[local (F:\repository), 
alimaven (http://maven.aliyun.com/nexus/content/groups/public/)] 
-> [Help 1]

5. 生命周期<lifecycle>

Maven一共有三个生命周期

这三套生命周期是独立的,是线性的,是互不影响的,详细参见完整生命周期的阶段组成

本地汇总了一张图


生命周期与阶段

6. 一些错综复杂的关系

注意不是之前的所有阶段都会运行,后文再细说

注意两点

[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ hymvn ---
[INFO] Tests are skipped.
[INFO]
sunyelw@windows:hymvn$                                                               
sunyelw@windows:hymvn$ mvn validate                                                  
[INFO] Scanning for projects...                                                      
[INFO]                                                                               
[INFO] ------------------------------------------------------------------------      
[INFO] Building hymvn 1.0-SNAPSHOT                                                   
[INFO] ------------------------------------------------------------------------      
[INFO] ------------------------------------------------------------------------      
[INFO] BUILD SUCCESS                                                                 
[INFO] ------------------------------------------------------------------------      
[INFO] Total time: 0.899 s                                                           
[INFO] Finished at: 2019-12-19T21:48:48+08:00                                        
[INFO] Final Memory: 10M/155M                                                        
[INFO] ------------------------------------------------------------------------      
sunyelw@windows:hymvn$                                                               

是生命周期(lifecycle)的阶段(phase)和插件(plugin)的目标(goal)相互绑定,以完成某个具体的构建任务

那么default 生命周期的其他阶段都没有绑定目标, 这些生命周期是否执行了呢?

官方文档中有一句话

Moreover, if a goal is bound to one or more build phases, that goal will be called in all those phases.
Furthermore, a build phase can also have zero or more goals bound to it.
If a build phase has no goals bound to it, that build phase will not execute.
But if it has one or more goals bound to it, it will execute all those goals.

A goal not bound to any build phase could be executed
outside of the build lifecycle by direct invocation.

7. packaging属性的重要性

生命周期的阶段与目标的绑定关系 取决于 packaging 属性, 比如在 jar 模式下

<phases>
  <process-resources>
    org.apache.maven.plugins:maven-resources-plugin:2.6:resources
  </process-resources>
  <compile>
    org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
  </compile>
  <process-test-resources>
    org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
  </process-test-resources>
  <test-compile>
    org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
  </test-compile>
  <test>
    org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
  </test>
  <package>
    org.apache.maven.plugins:maven-jar-plugin:2.4:jar
  </package>
  <install>
    org.apache.maven.plugins:maven-install-plugin:2.4:install
  </install>
  <deploy>
    org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
  </deploy>
</phases>
阶段 插件:目标
process-resources resources:resources
compile compiler:compile
process-test-resources resources:testResources
test-compile compiler:testCompile
test surefire:test
package ejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war
install install:install
deploy deploy:deploy

可以看到如果执行 package 会执行以下目标

installdeploy 就是后面再加两个,详情请参见默认绑定配置

8. mvn 创建项目

mvn archetype:generate -DgroupId=com.hy.demo -DartifactId=hymvn -DarchetypeArtifactId=maven-archetype-quickstart -Dpackage=com.hy.demo -DinteractiveMode=false

9. mvn命令报错定位

这里列几种我个人常用的方法,比较实用,当然要看问题具体类型。

sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn help:effective-settings
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hymvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:effective-settings (default-cli) @ hymvn ---
[INFO]
Effective user-specific configuration settings:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Generated by Maven Help Plugin on 2019-12-19T10:19:16                  -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/                -->
<!--                                                                        -->
<!-- ====================================================================== -->

<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Effective Settings for 'yello' on 'DESKTOP-S0L3088'                    -->
<!--                                                                        -->
<!-- ====================================================================== -->

<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository xmlns="http://maven.apache.org/SETTINGS/1.1.0">F:\repository</localRepository>
  <mirrors xmlns="http://maven.apache.org/SETTINGS/1.1.0">
    <mirror>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <id>alimaven</id>
    </mirror>
  </mirrors>
  <pluginGroups xmlns="http://maven.apache.org/SETTINGS/1.1.0">
    <pluginGroup>com.sun.yelw</pluginGroup>
    <pluginGroup>org.apache.maven.plugins</pluginGroup>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
  </pluginGroups>
</settings>

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.007 s
[INFO] Finished at: 2019-12-19T22:19:16+08:00
[INFO] Final Memory: 16M/155M
[INFO] ------------------------------------------------------------------------
sunyelw@windows:hymvn$
sunyelw@windows:hymvn$
sunyelw@windows:hymvn$ mvn help:effective-pom | grep 'central' -7
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>C:\idea\workspace\hymvn\src\main\java</sourceDirectory>
    <scriptSourceDirectory>C:\idea\workspace\hymvn\src\main\scripts</scriptSourceDirectory>
sunyelw@windows:hymvn$

发现一个依赖仓库,一个构件仓库,地址都是https://repo.maven.apache.org/maven2

mvn clean package -DskipTests -X > mvn_package_x.log

下面列出部分内容
开头是Maven的版本信息

Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15:58:13+08:00)
Maven home: E:\apache-maven-3.5.2
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: E:\Java\jdk1.8.0_151\jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

然后是一些导包

[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG]   Imported: javax.annotation.* < plexus.core
...
[DEBUG]   Imported: org.slf4j.helpers.* < plexus.core
[DEBUG]   Imported: org.slf4j.spi.* < plexus.core

下面有两行非常重要的信息

[DEBUG] Reading global settings from E:\apache-maven-3.5.2\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\yello\.m2\settings.xml

最终生效的settings.xml文件原来是由两个文件构成的,一个是用户目录${USER_HOME}\.m2\settings.xml, 还有一个安装目录${M2_HOME}\conf\settings.xml,所以如果你用户的设置文件没问题而又多了些配置时不妨考虑下安装目录下的配置。

还有很多信息

本地仓库地址

[DEBUG] Using local repository at F:\repository

镜像使用情况

[DEBUG] Using mirror alimaven (http://maven.aliyun.com/nexus/content/groups/public/) for central (https://repo.maven.apache.org/maven2).

执行计划

[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: com.hy.demo:hymvn:jar:1.0-SNAPSHOT
[DEBUG] Tasks:   [clean, package]
[DEBUG] Style:   Regular
[DEBUG] =======================================================================

还有详细的执行过程与配置信息, 比如clean

[DEBUG] Goal:          org.apache.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <directory default-value="${project.build.directory}"/>
  <excludeDefaultDirectories default-value="false">${maven.clean.excludeDefaultDirectories}</excludeDefaultDirectories>
  <failOnError default-value="true">${maven.clean.failOnError}</failOnError>
  <followSymLinks default-value="false">${maven.clean.followSymLinks}</followSymLinks>
  <outputDirectory default-value="${project.build.outputDirectory}"/>
  <reportDirectory default-value="${project.build.outputDirectory}"/>
  <retryOnError default-value="true">${maven.clean.retryOnError}</retryOnError>
  <skip default-value="false">${maven.clean.skip}</skip>
  <testOutputDirectory default-value="${project.build.testOutputDirectory}"/>
  <verbose>${maven.clean.verbose}</verbose>
</configuration>

后面还有很多详细的输出,就不一一列举了。


现在你看到开篇的输出能解答出Maven做了什么吗?

`

上一篇 下一篇

猜你喜欢

热点阅读