Git Product home page Git Product logo

maven's Introduction

Maven step by step

From http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

mvn --version
    Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100)
    Maven home: D:\apache-maven-3.0.5\bin\..
    Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
    Java home: C:\Program Files\Java\jdk1.6.0_25\jre
    Default locale: nl_NL, platform encoding: Cp1252
    OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

1-simple-jar

mvn archetype:generate -DgroupId=io.github.egenerat -DartifactId=simple-jar -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

to generate a jar

mvn package
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ simple-jar ---
[INFO] Nothing to compile - all classes are up to date

First build and mvn clean install
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ simple-jar ---
[INFO] Changes detected - recompiling the module!

Run the jar

Hello world!

2-simple-dependency

Create with 2 different group-id Check the difference between 2 namespaces and 2 groupId

When running your Jar with java -jar, you're no longer running with the maven resolving of dependencies. You have to make sure that all the jars you depend on are available at the relative loacation specificied in the MANIFEST.mf file in your Jar. Usually, you would use the assembly plugin to create a distributable archive that creates this structure. Or you could use a uberjar/onejar plugin to included everything inside your Jar.

5-provided-dependency-webserver

mvn archetype:generate -DgroupId=io.github.egenerat -DartifactId=webapp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

.
 |-- src
 |   `-- main
 |       `-- java
 |           |-- resources
 |           |-- webapp
 |           |   `-- WEB-INF
 |           |       `-- web.xml
 |           `-- index.jsp
  `-- pom.xml

8-reactor-modules

The following command line switches are available:

--resume-from - resumes a reactor the specified project (e.g. when it fails in the middle)
--also-make - build the specified projects, and any of their dependencies in the reactor
--also-make-dependents - build the specified projects, and any that depend on them
--fail-fast - the default behavior - whenever a module build fails, stop the overall build immediately
--fail-at-end - if a particular module build fails, continue the rest of the reactor and report all failed modules at the end instead
--non-recursive - do not use a reactor build, even if the current project declares modules and just build the project in the current directory

Miscellaneous

Documentation: https://maven.apache.org

A plugin is not run if there is no <execution> tag:

  • phase specifies during which Maven phase the plugin should be run
  • goal specifies which goal of the plugin needs to be executed

Proxy configuration

-Dhttp.proxyHost=<PROXY_IP> -Dhttp.proxyPort=<PROXY_PORT> -Dhttp.nonProxyHosts="localhost"

Interesting ticket about incremental build in maven-compiler-plugin, since version 3.1 https://issues.apache.org/jira/browse/MCOMPILER-209

maven's People

Contributors

egenerat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.