maven

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

plugin goals

? can be attached to a lifecycle phase

phase

A Goal Binds to a ?

version

A specific release of a project. Projects that have been released have a fixed version identifier that refers to a specific version of the project. Projects undergoing active development can use a special identifier that marks a version as a SNAPSHOT.

Duplicated dependency declarations make it difficult to ensure consistent versions across a large project

Duplicated dependency declarations make it ?

/<groupId>/<artifactId>/<version>/<artifactId>-<version>.<packaging>

The standard for a Maven repository is to store an artifact in this format

goupId, artifactId, version, and packaging

These four elements become the key to locating and using one particular project in the vast space of other "Mavenized" projects

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <testFailureIgnore>true</testFailureIgnore> </configuration> </plugin> mvn test -Dmaven.test.failure.ignore=true

You will often find yourself developing on a system that has failing unit tests. If you are practicing Test-Driven Development (TDD), you might use test failure as a measure of how close your project is to completeness. If you have failing unit tests, and you would still like to produce build output, you are going to have to tell Maven to ignore build failures. When Maven encounters a build failure, its default behavior is to stop the current build. To continue building a project even when the Surefire plugin encounters failed test cases, you'll need to set the ? configuration property of the Surefire plugin to true.

mvn dependency:analyze

what is the command in mvn to uncover the direct reference to dependencies

goals

A Maven Plugin is a collection of one or more ?

differences between build tool and project management tool

A build tool such as Ant is focused solely on preprocessing, compilation, packaging, testing, and distribution. A project management tool such as Maven provides a superset of features found in a build tool. In addition to providing build capabilities, Maven can also run reports, generate a web site, and facilitate communication among members of a working team.

unit of work

A goal is a ? in Maven

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin>

Another way to configure Maven to skip unit tests is to add this configuration to your project's pom.xml. To do this, you would add a plugin element to your build configuration.

Dependency Management

Because a project is defined by a unique set of coordinates consisting of a group identifier, an artifact identifier, and a version, projects can now use these coordinates to declare dependencies.

A Common Interface

Before Maven provided a common interface for building software, every single project had someone dedicated to managing a fully customized build system. Developers had to take time away from developing software to learn about the idiosyncrasies of each new project they wanted to contribute to. In 2001, you'd have a completely different approach to building a project like Turbine than you would to building a project like Tomcat. If a new source code analysis tool came out that would perform static analysis on source code, or if someone developed a new unit testing framework, everybody would have to drop what they were doing and figure out how to fit it into each project's custom build environment. How do you run unit tests? There were a thousand different answers. This environment was characterized by a thousand endless arguments about tools and build procedures. The age before Maven was an age of inefficiency, the age of the "Build Engineer".

Convention Over Configuration

Convention over configuration is a simple concept: Systems, libraries, and frameworks should assume reasonable defaults. Without requiring unnecessary configuration, systems should "just work". Popular frameworks such as Ruby on Rails and EJB3 have started to adhere to these principles in reaction to the configuration complexity of frameworks such as the initial EJB 2.1 specifications. An illustration of convention over configuration is something like EJB3 persistence: all you need to do to make a particular bean persistent is to annotate that class with @Entity. The framework assumes table and column names based on the name of the class and the names of the properties. Hooks are provided for you to override these default, assumed names if the need arises, but, in most cases, you will find that using the framework-supplied defaults results in a faster project execution. (http://books.sonatype.com/mvnex-book/reference/installation-sect-conventionConfiguration.html)

When Maven is executed against a project with submodules, Maven first loads the parent POM and locates all of the submodule POMs. Maven then puts all of these project POMs into something called the Maven Reactor which analyzes the dependencies between modules. The Reactor takes care of ordering components to ensure that interdependent modules are compiled and installed in the proper order.

Describe the way multi-module projects are built

zero or more

Each phase may have how many goals bound to it

mvn archetype:generate --batch-mode \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DgroupId=uk.co.pookey.hibernate \ -DartifactId=hibernate

How do create a simple jar project in mvn in batch mode

mvn archetype:generate --batch-mode \ -DarchetypeArtifactId=maven-archetype-webapp \ -DgroupId=uk.co.pookey.hibernate \ -DartifactId=hibernate

How do create a simple web application project in mvn in batch mode

A multi-module project is defined by a parent POM referencing one or more submodules

How do we define a multi-module project in mvn

artifactId

How do we define a unique identifier under groupId that represents a single project

<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> </plugin>

How do you add a jetty plugin in mvn project

mvn jetty:run

How do you start a jetty web app server as a mvn plugin:goal

Fortunately, via bytecode analysis, the Maven Dependency plugin is able to assist you in uncovering direct references to dependencies. Using the updated POMs we previously optimized, let's look to see if any errors pop up:

How do you uncover direct references to dependencies in mvn

Made possible by the fact that the Maven repository stores more than just bytecode; it stores metadata about artifacts

How does Maven maintain transitive dependencies?

mvn dependency:resolve

If you need to find out what is on the classpath, you can use the Maven Dependency plugin to print out a list of dependecies

mvn dependency:tree

If you would like to know about the entire dependency tree of your project, you can run this goal.

mvn install -X

If you're truly adventurous or want to see the full dependency trail, including artifacts that were rejected due to conflicts and other reasons, run Maven with the debug flag.

address

Just like in any other coordinate system, a set of Maven coordinates is an ? for a specific point in "space"

groupId:artifactId:packaging:version

Maven coordinates are often written using a colon as a delimiter in the following format ?

maven

Maven is a project management tool which encompasses a project object model, a set of standards, a project lifecycle, a dependency management system, and logic for executing plugin goals at defined phases in a lifecycle. When you use Maven, you describe your project using a well-defined project object model, Maven can then apply cross-cutting logic from a set of shared (or custom) plugins.

public, private, or local

Maven repositories are

C:\Users\USERNAME\.m2\repository

Once Maven has downloaded an artifact from the remote Maven repository it never needs to download that artifact again as Maven will always look for the artifact in the local repository before looking elsewhere. On windows, the directory is this

mvn install assembly:assembly

Once assembly plugin is added, how do we invoke mvn

Optimizing a multimodule project's POM is best done in several passes as there are many areas to focus on

Optimizing a multimodule project's POM is best done in ?

If more than one project depends on a specific dependency, you can list the dependency in dependencyManagement. The parent POM can contain a version and a set of exclusions; all the child POM needs to do to reference this dependency is use the groupId +and +artifactId. Child projects can omit the version and exclusions if the dependency is listed in dependencyManagement.

Pull-up common dependencies to dependencyManagement

mvn help:describe -Dplugin=exec -Dfull

The Exec plugin allows you to execute Java classes and other scripts. It is not a core Maven plugin, but it is available from the Mojo project hosted by Codehaus. For a full description of the Exec plugin, run:

packaging

The type of project, defaulting to jar, describing the packaged output produced by a project. A project with packaging jar produces a JAR archive; a project with packaging war produces a web application.

Use ${project.version} and ${project.groupId} when referring to a sibling project. Sibling projects almost always share the same groupId, and they almost always share the same release version. Using ${project.version} will help you avoid the sibling version mismatch problem discussed previously.

Use built-in project version and groupId for sibling projects

On this site, you'll notice that some default reports are available. A unit test report communicates the success and failure of all unit tests in the project. Another report generates Javadoc for the project's API. Maven provides a full range of configurable reports, such as the Clover report that examines unit test coverage, the JXR report that generates cross-referenced HTML source code listings useful for code reviews, the PMD report that analyzes source code for various coding problems, and the JDepend report that analyzes the dependencies between packages in a codebase. You can customize site reports by configuring which reports are included in a build via the pom.xml file

What are the default reports produced by mvn site command

Maven Coordinates

What define a set of identifiers which can be used to uniquely identify a project, a dependency, or a plugin in a Maven POM

The parent project doesn't create a JAR or a WAR; instead, it is simply a POM that refers to other Maven projects and simply provides a Project Object Model (pom)

What does parent parent pom publishes?

The group, company, team, organization, project, or other group

What is groupId in mvn?

generate a new project using the default maven-archetype-quickstart archetype

What is the default behavior of archetype:create

<dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency>

What is to be done to tell Maven that the jar is provided by the container and thus should not be included in the war.

A dependency in Maven isn't just a JAR file; it's a POM file that, in turn, may declare dependencies on other artifacts. These dependencies of dependencies are called transitive dependencies

What is transitive dependencies?

A repository is a collection of project artifacts stored in a directory structure that closely matches a project's Maven coordinates

What makes a Maven repository a Maven repository?

Archetype

What plugin creates a project with a file named pom.xml.

<plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin>

What plugin do we add if we want to install with all the dependencies

pluginId:goalId

When referring to a plugin goal, we frequently use the shorthand notation: ?:?

Not bundled. They are used only for compilation

When you create a JAR for a project, dependencies are bundled or not bundled with the generated artifact

...

When you use Maven to create a WAR or an EAR file, you can configure Maven to bundle dependencies with the generated artifact, and you can also configure it to exclude certain dependencies from the WAR file using the provided scope. The provided scope tells Maven that a dependency is needed for compilation, but should not be bundled with the output of a build. This scope comes in handy when you are developing a web application. You'll need to compile your code against the Servlet specification, but you don't want to include the Servlet API JAR in your web application's WEB-INF/lib directory.

Whenever there is duplication of some piece of information, there is usually a better way to solve. Refactor your dependencies and configurations

Whenever there is duplication of some piece of information, there is usually a ?

mvn install -Dmaven.test.skip=true

You may want to configure Maven to skip unit tests altogether. Maybe you have a very large system where the unit tests take minutes to complete and you don't want to wait for unit tests to complete before producing output. You might be working with a legacy system that has a series of failing unit tests, and instead of fixing the unit tests, you might just want to produce a JAR. Maven provides for the ability to skip unit tests using the skip parameter of the Surefire plugin

Unfortunately, dependencyManagement doesn't apply to plugin dependencies,

does dependencyManagement apply to plugin dependencies,

mvn install

how do install a project

read http://maven.apache.org/plugins/maven-eclipse-plugin/reactor.html

how do we create multi module project from command line and make i ready to be imported in eclipse

project web site in the target/site directory. Load target/site/index.html

output of mvn site?

JAR

phase is going to create a ? file for a project with jar packaging

mvn help:effective-pom

project might have a relatively minimal pom.xml, the contents of your project's POM are interpolated with the contents of all parent POMs, user settings, and any active profiles. To see this "effective" POM, run which mvn command

A good rule of thumb in Maven is to always declare explicit dependencies for classes referenced in your code

regarding dependencies, should you depend on the transitive dependencies in maven?

site

this lifecycle is concerned solely with processing site content under the src/site directories and generating reports

lifecycle phase

to validate the basic integrity of the project and ends with a phase that involves deploying a project to production

This shell contains some reports under "Project Reports" in the lefthand navigation menu, and it also contains information about the project, the dependencies, and developers associated with it under "Project Information." The simple project's web site is mostly empty, since the POM contains very little information about itself beyond its Maven coordinates, a name, a URL, and a single test dependency.

what is the basic shell of a project site

archetype:generate

when referring to the generate goal in the Archetype plugin, we write ?:?


संबंधित स्टडी सेट्स

Biomechanics Final Exam(s) Review

View Set

Kinesiology Chapter 2- Shoulder & Arm

View Set

Chapter 1 Classification of Motor Skills

View Set

Module 14: Communication & Module 5: Decision Making

View Set

Insurance Exam Practice Test Questions

View Set

Intro to c sharp chapter 7-9 multiple choice

View Set

Chp 2. Financial Statements Taxes and Cash flow

View Set

03. EF Pre-Int Practical English 1: Hotel Problems

View Set