2021年8月4日 星期三

[研究] Apache Maven 3.5.4 (yum) 安裝 (CentOS 8.4 x64_86)

[研究] Apache Maven 3.5.4 (yum) 安裝 (CentOS 8.4 x64_86)


2021-08-03

介紹
http://maven.apache.org/

Maven是一個專案的開發,管理和綜合工具。

下載
http://maven.apache.org/download.cgi

參考
http://maven.apache.org/download.cgi#Installation

使用教學
http://maven.apache.org/guides/getting-started/index.html
http://maven.apache.org/guides/index.html

CentOS 8.4 的 yum 提供 maven 3.5.4 版了,安裝比 CentOS 6.x 容易很多 (環境變數設定非必須,下面會自動安裝 OpenJDK 1.8) 


[john@localhost ~]$ yum -y install maven
Error: This command has to be run with superuser privileges (under the root user on most systems).
[john@localhost ~]$ sudo yum -y install maven
...
  java-1.8.0-openjdk-1:1.8.0.302.b08-0.el8_4.x86_64                             
  java-1.8.0-openjdk-devel-1:1.8.0.302.b08-0.el8_4.x86_64             
...
  maven-1:3.5.4-5.module_el8.0.0+39+6a9b6e22.noarch      
...
[john@localhost ~]$ 

測試,顯示版本


[john@localhost ~]$ mvn -v
Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 1.8.0_302, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el8_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-305.3.1.el8.x86_64", arch: "amd64", family: "unix"
[john@localhost ~]$ 

下載測試 (過程所有問題按下 Enter 回答)


[john@localhost ~]$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.mycompany.app -DartifactId=my-app
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:3.2.0:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:3.2.0:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- maven-archetype-plugin:3.2.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
...(略)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 1805: 
Choose org.apache.maven.archetypes:maven-archetype-quickstart version: 
1: 1.0-alpha-1
2: 1.0-alpha-2
3: 1.0-alpha-3
4: 1.0-alpha-4
5: 1.0
6: 1.1
7: 1.3
8: 1.4
Choose a number: 8: 
[INFO] Using property: groupId = com.mycompany.app
[INFO] Using property: artifactId = my-app
Define value for property 'version' 1.0-SNAPSHOT: : 
[INFO] Using property: package = com.mycompany.app
Confirm properties configuration:
groupId: com.mycompany.app
artifactId: my-app
version: 1.0-SNAPSHOT
package: com.mycompany.app
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: maven-archetype-quickstart:1.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.mycompany.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mycompany.app
[INFO] Parameter: packageInPathFormat, Value: com/mycompany/app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mycompany.app
[INFO] Parameter: groupId, Value: com.mycompany.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Project created from Archetype in dir: /home/john/my-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.320 s
[INFO] Finished at: 2021-08-03T20:05:30-04:00
[INFO] ------------------------------------------------------------------------
[john@localhost ~]$ 

編譯測試 


[john@localhost ~]$ cd  my-app
[john@localhost my-app]$ mvn compile
...(略)
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/john/my-app/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.292 s
[INFO] Finished at: 2021-08-03T20:08:18-04:00
[INFO] ------------------------------------------------------------------------
[john@localhost my-app]$ mvn compile

 


[john@localhost my-app]$ mvn test
...(略)
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.mycompany.app.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 s - in com.mycompany.app.AppTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.256 s
[INFO] Finished at: 2021-08-03T20:09:53-04:00
[INFO] ------------------------------------------------------------------------
[john@localhost my-app]$ 

mvn 參數

xxx
[root@localhost IRWS]# mvn -h

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
 -ntp,--no-transfer-progress            Do not display transfer progress
                                        when downloading or uploading
 -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
[root@localhost IRWS]# 

mvn  編譯打包指令


mvn package 

(完)


相關

[研究] Apache Maven 3.5.4 (yum) 安裝 (CentOS 8.4 x64_86)

[研究] Apache Maven 3.0.5 (yum) 安裝 (CentOS 7.1 x64_86)
http://shaurong.blogspot.com/2015/05/apache-maven-305-yum-centos-71-x6486.html

[研究] Apache Maven 3.0.5 (yum) 安裝 (CentOS 7.0 x64_86)
http://shaurong.blogspot.com/2014/08/apache-maven-305-yum-centos-70-x6486.html

[研究] Apache Maven 3.1.1 安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.com/2013/11/apache-maven-311-centos-64-x64.html
http://forum.icst.org.tw/phpbb/viewtopic.php?t=80036

[研究] Apache Maven 3.0.3 (yum) 安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/apache-maven-303-yum-centos-64-x64.html

相關

[研究] Apache Maven 3.6.3 安裝 (Windows 2019)

[研究] Apache Maven 3.5.3 安裝 (Windows 2016)
https://shaurong.blogspot.com/2018/06/apache-maven-353-windows-2016.html

[研究] Apache Maven 3.0.5 (yum) 安裝 (CentOS 7.1 x64_86)
http://shaurong.blogspot.com/2015/05/apache-maven-305-yum-centos-71-x6486.html

[研究] Apache Maven 3.5.3 安裝 (Windows 2016)
http://shaurong.blogspot.com/2018/06/apache-maven-353-windows-2016.html

[研究] Apache Maven 3.2.2 (tar.gz)安裝 (CentOS 7.0 x64_86)
http://shaurong.blogspot.com/2014/08/apache-maven-322-targz-centos-70-x6486.html

[研究] Apache Maven 3.0.5 (yum) 安裝 (CentOS 7.0 x64_86)
http://shaurong.blogspot.com/2014/08/apache-maven-305-yum-centos-70-x6486.html

[研究] Apache Maven 3.1.1 (tar.gz)安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.com/2013/11/apache-maven-311-centos-64-x64.html

[研究] Apache Maven 3.1.0 安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.com/2013/07/apache-maven-310-centos-64-x64.html

[研究] Apache Maven 3.0.3 (yum) 安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.com/2013/11/apache-maven-303-yum-centos-64-x64.html

沒有留言:

張貼留言