MAVEN

凌晨1:28

檢查Maven的版本


X
:\Users\蘇岳承>mvn -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: Y:\apache-maven-3.5.0\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: X:\Program Files\Java\j2re-1.8.0_121
Default locale: zh_TW, platform encoding: MS950
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

查詢Maven的基本的指令:

X:\Users\蘇岳承>mvn -h
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0

usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
 -am,--also-make                        If project list is specified, also
                                        build projects required by the
                                        list
 -amd,--also-make-dependents            If project list is specified, also
                                        build projects that depend on
                                        projects on the list
 -B,--batch-mode                        Run in non-interactive (batch)
                                        mode (disables output color)
 -b,--builder <arg>                     The id of the build strategy to
                                        use
 -C,--strict-checksums                  Fail the build if checksums don't
                                        match
 -c,--lax-checksums                     Warn if checksums don't match
 -cpu,--check-plugin-updates            Ineffective, only kept for
                                        backward compatibility
 -D,--define <arg>                      Define a system property
 -e,--errors                            Produce execution error messages
 -emp,--encrypt-master-password <arg>   Encrypt master security password
 -ep,--encrypt-password <arg>           Encrypt server password
 -f,--file <arg>                        Force the use of an alternate POM
                                        file (or directory with pom.xml)
 -fae,--fail-at-end                     Only fail the build afterwards;
                                        allow all non-impacted builds to
                                        continue
 -ff,--fail-fast                        Stop at first failure in
                                        reactorized builds
 -fn,--fail-never                       NEVER fail the build, regardless
                                        of project result
 -gs,--global-settings <arg>            Alternate path for the global
                                        settings file
 -gt,--global-toolchains <arg>          Alternate path for the global
                                        toolchains file
 -h,--help                              Display help information
 -l,--log-file <arg>                    Log file where all build output
                                        will go (disables output color)
 -llr,--legacy-local-repository         Use Maven 2 Legacy Local
                                        Repository behaviour, ie no use of
                                        _remote.repositories. Can also be
                                        activated by using
                                        -Dmaven.legacyLocalRepo=true
 -N,--non-recursive                     Do not recurse into sub-projects
 -npr,--no-plugin-registry              Ineffective, only kept for
                                        backward compatibility
 -npu,--no-plugin-updates               Ineffective, only kept for
                                        backward compatibility
 -nsu,--no-snapshot-updates             Suppress SNAPSHOT updates
 -o,--offline                           Work offline
 -P,--activate-profiles <arg>           Comma-delimited list of profiles
                                        to activate
 -pl,--projects <arg>                   Comma-delimited list of specified
                                        reactor projects to build instead
                                        of all projects. A project can be
                                        specified by [groupId]:artifactId
                                        or by its relative path
 -q,--quiet                             Quiet output - only show errors
 -rf,--resume-from <arg>                Resume reactor from specified
                                        project
 -s,--settings <arg>                    Alternate path for the user
                                        settings file
 -t,--toolchains <arg>                  Alternate path for the user
                                        toolchains file
 -T,--threads <arg>                     Thread count, for instance 2.0C
                                        where C is core multiplied
 -U,--update-snapshots                  Forces a check for missing
                                        releases and updated snapshots on
                                        remote repositories
 -up,--update-plugins                   Ineffective, only kept for
                                        backward compatibility
 -v,--version                           Display version information
 -V,--show-version                      Display version information
                                        WITHOUT stopping build
 -X,--debug                             Produce execution debug output

X:\Users\User1>

透過Maven檢視Environment的詳細資訊:

X:\Users\User1>mvn help:system
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:system (default-cli) @ standalone-pom ---
[INFO]
===============================================================================
========================= Platform Properties Details =========================
===============================================================================

===============================================================================
System Properties
===============================================================================

java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=X:\Program Files\Java\j2re-1.8.0_121\bin
java.vm.version=25.121-b13
maven.multiModuleProjectDirectory=X:\Users\User1
java.vm.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
guice.disable.misplaced.annotation.check=true
path.separator=;
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg=sun.io
user.country=TW
user.script=
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=
.....

===============================================================================
Environment Variables
===============================================================================

CLASSWORLDS_JAR="Y:\apache-maven-3.5.0\bin\..\boot\plexus-classworlds-2.5.2.jar"
PSMODULEPATH=X:\Program Files\WindowsPowerShell\Modules;X:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PROGRAMW6432=X:\Program Files
COMMONPROGRAMW6432=X:\Program Files\Common Files
PROCESSOR_ARCHITECTURE=AMD64
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
......
MAVEN_HOME=Y:\apache-maven-3.5.0\bin\..

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.575 s
[INFO] Finished at: 2017-10-11T16:44:39+08:00
[INFO] Final Memory: 21M/981M
[INFO] ------------------------------------------------------------------------

X:\Users\User1>

在POM檔內,我們可以開始加入我們要用的plugin(例如:我們要用jetty),在用該plugin之前,我們可以用maven的command查看這個plugin有甚麼功能:

X:\Users\User1>mvn help:describe -DgroupId=org.mortbay.jetty -DartifactId=jetty-maven-plugin
[INFO] Scanning for projects...
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugins/maven-metadata.xml
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/codehaus/mojo/maven-metadata.xml
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 KB at 13.0 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 17.2 KB/sec)
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-help-plugin/maven-metadata.xml
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugins/maven-help-plugin/maven-metadata.xml
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-help-plugin/maven-metadata.xml (493 B at 0.9 KB/sec)
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-help-plugin/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugins/maven-help-plugin/2.2/maven-help-plugin-2.2.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-help-plugin/2.2/maven-help-plugin-2.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-help-plugin/2.2/maven-help-plugin-2.2.pom (9 KB at 17.3 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugins/maven-help-plugin/2.2/maven-help-plugin-2.2.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-help-plugin/2.2/maven-help-plugin-2.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-help-plugin/2.2/maven-help-plugin-2.2.jar (67 KB at 44.8 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from http://maven-repository.ebaotech.com/artifactory/repo was cached in the local repository, resolution will not be reattempted until the update interval of ebao has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from http://maven-repository.ebaotech.com/artifactory/repo was cached in the local repository, resolution will not be reattempted until the update interval of ebao has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
[WARNING] Failure to transfer org.apache.maven.plugins:maven-help-plugin/maven-metadata.xml from http://maven-repository.ebaotech.com/artifactory/repo was cached in the local repository, resolution will not be reattempted until the update interval of ebao has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins:maven-help-plugin/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ standalone-pom ---
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.pom (5 KB at 8.2 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugin-tools/maven-plugin-tools/2.4.3/maven-plugin-tools-2.4.3.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools/2.4.3/maven-plugin-tools-2.4.3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools/2.4.3/maven-plugin-tools-2.4.3.pom (10 KB at 25.3 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.pom
Downloading: http://repo.maven.apache.org/maven2/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.pom
Downloaded: http://repo.maven.apache.org/maven2/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.pom (2 KB at 2.7 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/codehaus/plexus/plexus-container-default/1.0-alpha-7/plexus-container-default-1.0-alpha-7.pom
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-container-default/1.0-alpha-7/plexus-container-default-1.0-alpha-7.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-container-default/1.0-alpha-7/plexus-container-default-1.0-alpha-7.pom (2 KB at 2.8 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/plexus/plexus-containers/1.0.2/plexus-containers-1.0.2.pom
Downloading: http://repo.maven.apache.org/maven2/plexus/plexus-containers/1.0.2/plexus-containers-1.0.2.pom
Downloaded: http://repo.maven.apache.org/maven2/plexus/plexus-containers/1.0.2/plexus-containers-1.0.2.pom (471 B at 1.2 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/plexus/plexus-root/1.0.3/plexus-root-1.0.3.pom
Downloading: http://repo.maven.apache.org/maven2/plexus/plexus-root/1.0.3/plexus-root-1.0.3.pom
Downloaded: http://repo.maven.apache.org/maven2/plexus/plexus-root/1.0.3/plexus-root-1.0.3.pom (6 KB at 12.9 KB/sec)
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.jar
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/codehaus/plexus/plexus-utils/1.5.7/plexus-utils-1.5.7.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.jar
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.7/plexus-utils-1.5.7.jar
Downloading: http://repo.maven.apache.org/maven2/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.jar (51 KB at 52.1 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar (135 KB at 87.3 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.7/plexus-utils-1.5.7.jar (260 KB at 166.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/mortbay/jetty/jetty-maven-plugin/maven-metadata.xml
Downloading: http://maven-repository.ebaotech.com/artifactory/repo/org/mortbay/jetty/jetty-maven-plugin/maven-metadata.xml
Downloaded: http://repo.maven.apache.org/maven2/org/mortbay/jetty/jetty-maven-plugin/maven-metadata.xml (4 KB at 7.7 KB/sec)
[WARNING] Could not transfer metadata org.mortbay.jetty:jetty-maven-plugin/maven-metadata.xml from/to ebao (http://maven-repository.ebaotech.com/artifactory/repo): maven-repository.ebaotech.com
[INFO] org.mortbay.jetty:jetty-maven-plugin:8.1.16.v20140903

Name: Jetty :: Jetty Maven Plugin
Description: Jetty integrations and distributions
Group Id: org.mortbay.jetty
Artifact Id: jetty-maven-plugin
Version: 8.1.16.v20140903
Goal Prefix: jetty

This plugin has 8 goals:

jetty:deploy-war
  Description: This goal is used to run Jetty with a pre-assembled war.

    It accepts exactly the same options as the run-war goal. However, it
    doesn't assume that the current artifact is a webapp and doesn't try to
    assemble it into a war before its execution. So using it makes sense only
    when used in conjunction with the webApp configuration parameter pointing
    to a pre-built WAR.

    This goal is useful e.g. for launching a web app in Jetty as a target for
    unit-tested HTTP client components.

jetty:help
  Description: Display help information on jetty-maven-plugin.
    Call
      mvn jetty:help -Ddetail=true -Dgoal=<goal-name>
    to display parameter details.

jetty:run
  Description: This goal is used in-situ on a Maven project without first
    requiring that the project is assembled into a war, saving time during the
    development cycle. The plugin forks a parallel lifecycle to ensure that the
    'compile' phase has been completed before invoking Jetty. This means that
    you do not need to explicity execute a 'mvn compile' first. It also means
    that a 'mvn clean jetty:run' will ensure that a full fresh compile is done
    before invoking Jetty.

    Once invoked, the plugin can be configured to run continuously, scanning
    for changes in the project and automatically performing a hot redeploy when
    necessary. This allows the developer to concentrate on coding changes to
    the project using their IDE of choice and have those changes immediately
    and transparently reflected in the running web container, eliminating
    development time that is wasted on rebuilding, reassembling and
    redeploying.

    You may also specify the location of a jetty.xml file whose contents will
    be applied before any plugin configuration. This can be used, for example,
    to deploy a static webapp that is not part of your maven build.

    There is a reference guide to the configuration parameters for this plugin,
    and more detailed information with examples in the Configuration Guide.

jetty:run-exploded
  Description: This goal is used to assemble your webapp into an exploded war
    and automatically deploy it to Jetty.

    Once invoked, the plugin can be configured to run continuously, scanning
    for changes in the pom.xml and to WEB-INF/web.xml, WEB-INF/classes or
    WEB-INF/lib and hot redeploy when a change is detected.

    You may also specify the location of a jetty.xml file whose contents will
    be applied before any plugin configuration. This can be used, for example,
    to deploy a static webapp that is not part of your maven build.

    There is a reference guide to the configuration parameters for this plugin,
    and more detailed information with examples in the Configuration Guide.

jetty:run-forked
  Description: This goal is used to assemble your webapp into a war and
    automatically deploy it to Jetty in a forked JVM.

    You need to define a jetty.xml file to configure connectors etc and a
    context xml file that sets up anything special about your webapp. This
    plugin will fill in the:

    - context path
    - classes
    - web.xml
    - root of the webapp
    Based on a combination of information that you supply and the location of
    files in your unassembled webapp.


    There is a reference guide to the configuration parameters for this plugin,
    and more detailed information with examples in the Configuration Guide.

jetty:run-war
  Description: This goal is used to assemble your webapp into a war and
    automatically deploy it to Jetty.

    Once invoked, the plugin can be configured to run continuously, scanning
    for changes in the project and to the war file and automatically performing
    a hot redeploy when necessary.

    You may also specify the location of a jetty.xml file whose contents will
    be applied before any plugin configuration. This can be used, for example,
    to deploy a static webapp that is not part of your maven build.

    There is a reference guide to the configuration parameters for this plugin,
    and more detailed information with examples in the Configuration Guide.

jetty:start
  Description: This goal is similar to the jetty:run goal, EXCEPT that it is
    designed to be bound to an execution inside your pom, rather than being run
    from the command line.

    When using it, be careful to ensure that you bind it to a phase in which
    all necessary generated files and classes for the webapp will have been
    created. If you run it from the command line, then also ensure that all
    necessary generated files and classes for the webapp already exist.

jetty:stop
  Description: JettyStopMojo - stops a running instance of jetty. The ff are
    required: -DstopKey=someKey -DstopPort=somePort

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.164s
[INFO] Finished at: Sat Oct 14 19:26:36 CST 2017
[INFO] Final Memory: 10M/981M
[INFO] ------------------------------------------------------------------------
X:\Users\User1>

(要注意 ! 若環境中,有用其他不同版本的maven,且因著某專案而設定了\apache-maven-XXX\confsettings.xml,指定了localRepository、another profile,可能會造成maven執行上的錯誤。例如 :情境1)

  • Share:

You Might Also Like

0 意見