Apache Maven - RIP Tutorial · PDF file from: apache-maven It is an unofficial and free Apache...

Click here to load reader

  • date post

    29-May-2020
  • Category

    Documents

  • view

    6
  • download

    0

Embed Size (px)

Transcript of Apache Maven - RIP Tutorial · PDF file from: apache-maven It is an unofficial and free Apache...

  • Apache Maven

    #maven

  • 1

    1: Apache Maven 2

    2

    2

    Examples 2

    2

    Ubuntu 2

    3

    BrewMac OSX 3

    2: Eclipse 4

    Examples 4

    EclipseMaven 4

    EclipseM2Eclipse Maven 4

    EclipseMaven 4

    3: Maven Assembly 5

    Examples 5

    .jar 5

    4: Maven EAR 6

    6

    Examples 6

    EAR 6

    5: Maven Surefire 7

    7

    Examples 7

    JUnitMaven SurefireJava 7

    6: Maven Tomcat 10

    Examples 10

    maventomcat 10

    7: Maven 12

    12

    12

  • Examples 12

    12

    8: Maven 13

    13

    Examples 13

    Maven 13

    9: POM - 16

    Examples 16

    POM 16

    POM 16

    POM 17

    10: taglist-maven-pluginFIXME / TODO 18

    18

    Examples 18

    pom.xmlFIXME 18

    11: Maven 20

    20

    20

    Examples 20

    MavenMaven 20

    20

    21

    21

    22

    22

    12: Maven 23

    23

    Examples 23

    jar 23

    maven 24

    maven-modelpom.xml 24

    13: 26

  • 26

    26

    Examples 26

    POM.xmlNexus 26

    28

  • You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: apache-maven

    It is an unofficial and free Apache Maven ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official Apache Maven.

    The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.

    Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected]

    https://riptutorial.com/zh-CN/home 1

    http://riptutorial.com/ebook/apache-maven https://archive.org/details/documentation-dump.7z mailto:[email protected]

  • 1: Apache Maven Maven。

    Maven

    • • • • • • •

    SDLC。

    Mavenmaven 。

    Maven。

    Maven Maven。• • •

    1.0-β-2 2002330

    1.0 2004-07-13

    2.0 2.0 2005-10-20

    3.0 3.0 2010-10-08

    Examples

    MavenMaven。

    ziptar.gz。

    JAVA_HOMEJDKJRE。WindowsC:\Program Files\Java\jdk1.8.0_51 。• 。• binapache-maven-3.3.9 for Maven 3.3.9PATH。 Windows 。• mvn -version。•

    M2_HOMEMAVEN_HOME。

    Ubuntu

    https://riptutorial.com/zh-CN/home 2

    https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/guides/getting-started/ https://maven.apache.org/background/philosophy-of-maven.html https://maven.apache.org/background/philosophy-of-maven.html https://maven.apache.org/background/philosophy-of-maven.html https://maven.apache.org/background/philosophy-of-maven.html http://jakarta.apache.org/site/news/news-2002.html#0330.1 http://jakarta.apache.org/site/news/news-2002.html#0330.1 http://jakarta.apache.org/site/news/elsewhere-2004-2ndHalf.html#20040713.1 http://jakarta.apache.org/site/news/elsewhere-2004-2ndHalf.html#20040713.1 http://mail-archives.apache.org/mod_mbox/maven-users/200510.mbox/%3C4356C7AF.6080901%40apache.org%3E http://mail-archives.apache.org/mod_mbox/maven-users/200510.mbox/%3C4356C7AF.6080901%40apache.org%3E http://mail-archives.apache.org/mod_mbox/maven-announce/201010.mbox/%3C4CAF1861.4030006%40apache.org%3E http://mail-archives.apache.org/mod_mbox/maven-announce/201010.mbox/%3C4CAF1861.4030006%40apache.org%3E https://maven.apache.org/download.cgi https://maven.apache.org/download.cgi https://maven.apache.org/download.cgi https://maven.apache.org/download.cgi https://maven.apache.org/install.html https://maven.apache.org/install.html https://maven.apache.org/install.html https://maven.apache.org/install.html https://maven.apache.org/install.html http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them

  • sudo apt-get install maven1.

    mvn -v

    Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.8.0-parrot-amd64", arch: "amd64", family: "unix"

    2.

    javac -versionJDK

    InternetMavenjar - 。

    {Maven}→conf→ settings.xmlMaven。。

    Eclipse

    Eclipsesettings.xmlMavenWindow→Preferences→Maven→User Settings→User Settings。 {Maven}→conf→ settings.xml。

    IntelliJ

    Maven - >。 BuildExecutionDeployment - > Build Tools - >IntelliJ。

    “VM”

    -DproxySet=true -DproxyHost= -DproxyPort= -DproxySet=true -DproxyHost=myproxy.com -DproxyPort=8080

    IntelliJ。

    BrewMac OSX

    brew install maven1.

    mavenmvn -v 。2.

    Apache Maven 3.3.9 Maven home: /usr/local/Cellar/maven/3.3.9/libexec Java version: 1.8.0_121, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.12.4", arch: "x86_64", family: "mac"

    javac -versionJDK

    Apache Maven https://riptutorial.com/zh-CN/maven/topic/898/apache-maven

    https://riptutorial.com/zh-CN/home 3

    https://riptutorial.com/zh-CN/maven/topic/898/apache-maven%E5%85%A5%E9%97%A8 https://riptutorial.com/zh-CN/maven/topic/898/apache-maven%E5%85%A5%E9%97%A8 https://riptutorial.com/zh-CN/maven/topic/898/apache-maven%E5%85%A5%E9%97%A8

  • 2: Eclipse

    Examples

    EclipseMaven

    M2EclipseApache MavenEclipse。EclipseMaven

    Eclipse → ...1.

    ...。2.

    OK

    M2Eclipse

    http://download.eclipse.org/technology/m2e/releases http://download.eclipse.org/technology/m2e/releases

    3.

    ... 。4.

    ◉ 。5.

    Eclipse。 。6.

    EclipseM2Eclipse Maven

    → Eclipse →m2e 。

    EclipseMaven

    EclipseMavenMavenIDEMaven。

    → → Maven → •

    Add ../Maven•

    Finish

    ... your Maven home ... ......

    Apache Maven xyz

    ☑EMBEDDED “” 。•

    Eclipse https://riptutorial.com/zh-CN/maven/topic/2315/eclipse

    https://riptutorial.com/zh-CN/home 4

    http://www.eclipse.org/m2e/ https://www.eclipse.org/m2e/ https://www.eclipse.org/m2e/ https://www.eclipse.org/m2e/ https://riptutorial.com/zh-CN/maven/topic/2315/eclipse%E9%9B%86%E6%88%90 https://riptutorial.com/zh-CN/maven/topic/2315/eclipse%E9%9B%86%E6%88%90 https://riptutorial.com/zh-CN/maven/topic/2315/eclipse%E9%9B%86%E6%88%90

  • 3: Maven Assembly

    Examples

    .jar

    JARjar-with-dependencies 。com.examplepackageAssembly Plugin

    maven-assembly-plugin 2.6 make-assembly package single com.example jar-with-dependencies

    mvn clean package

    jar。

    jar Maven Shade 。

    Maven Assembly https://riptutorial.com/zh-CN/maven/topic/2308/maven-assembly

    https://riptutorial.com/zh-CN/home 5

    http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies http://stackoverflow.com/questions/11947037/what-is-an-uber-jar http://stackoverflow.com/questions/11947037/what-is-an-uber-jar http://stackoverflow.com/questions/11947037/what-is-an-uber-jar https://maven.apache.org/plugins/maven-shade-plugin/ https://maven.apache.org/plugins/maven-shade-plugin/ https://maven.apache.org/plugins/maven-shade-plugin/ https://riptutorial.com/zh-CN/maven/topic/2308/maven-assembly%E6%8F%92%E4%BB%B6 https://riptutorial.com/zh-CN/maven/topic/2308/maven-assembly%E6%8F%92%E4%BB%B6 https://riptutorial.com/zh-CN/maven/topic/2308/maven-assembly%E6%8F%92%E4%BB%B6

  • 4: Maven EAR .war.jarmaven ear

    Examples

    EAR

    {ejbModuleGroupId} {ejbModuleArtifactId} {ejbModuleVersion} ejb {webModuleGroupId} {webModuleArtifactId} {webModuleVersion} war org.apache.maven.plugins maven-ear-plugin 2.9.1 1.4 {ejbModuleGroupId}