介紹
http://maven.apache.org/ref/3.1.1/
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
Java JDK 請自己手動下載
安裝
rpm -ivh jdk-7u45-linux-x64.rpm
wget http://ftp.tc.edu.tw/pub/Apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
tar zxvf apache-maven-3.1.1-bin.tar.gz -C /usr/local
ln -s /usr/local/apache-maven-3.1.1/bin/mvn /usr/bin/mvn
export M2_HOME=/usr/local/apache-maven-3.1.1
export M2=$M2_HOME/bin
# MAVEN_OPTS 非必須
export MAVEN_OPTS="-Xms256m -Xmx512m"
export PATH=$M2:$PATH
export JAVA_HOME=/usr/java/jdk1.7.0_45
測試
顯示版本
[root@localhost ~]# mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 23:22:22+0800)
Maven home: /usr/local/apache-maven-3.1.1
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.el6.x86_64", arch: "amd64", family: "unix"
[root@localhost ~]#
如果不僅是 Maven,連 Linux 預設的的 Java 都要換成剛安裝版本,請看這篇
[研究] Java 7 安裝差異+選擇切換研究 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/java-7-centos-64-x64.html
下載測試
[root@localhost ~]# mvn archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
...(略)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:04.569s
[INFO] Finished at: Mon Nov 04 20:02:12 CST 2013
[INFO] Final Memory: 11M/28M
[INFO] ------------------------------------------------------------------------
[root@localhost ~]#
編譯測試
[root@localhost ~]# cd my-app
[root@localhost my-app]# mvn compile
...(略)
[INFO] Compiling 1 source file to /root/my-app/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 56.778s
[INFO] Finished at: Mon Nov 04 20:03:32 CST 2013
[INFO] Final Memory: 10M/25M
[INFO] ------------------------------------------------------------------------
[root@localhost my-app]#
[root@localhost my-app]# mvn test
...(略)
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.906s
[INFO] Finished at: Mon Nov 04 20:04:36 CST 2013
[INFO] Final Memory: 11M/27M
[INFO] ------------------------------------------------------------------------
[root@localhost my-app]#
[root@localhost ~]# mvn -help
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
-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
-h,--help Display help information
-l,--log-file <arg> Log file to where all build output will go.
-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,--threads <arg> Thread count, for instance 2.0C where C is core multiplied
-t,--toolchains <arg> Alternate path for the user toolchains file
-U,--update-snapshots Forces a check for updated releases and snapshots on remote repositories
-up,--update-plugins Ineffective, only kept for backward compatibility
-V,--show-version Display version information WITHOUT stopping build
-v,--version Display version information
-X,--debug Produce execution debug output
[root@localhost ~]#
http://maven.apache.org/guides/getting-started/index.html
http://maven.apache.org/guides/index.html
(完)
[研究] Apache Maven 3.0.3 (yum) 安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/apache-maven-303-yum-centos-64-x64.html
(不建議,在某些情況下使用有問題,且用 tar.gz 方式安裝 Maven 不困難)
沒有留言:
張貼留言