Maven

What element in the pom.xml file allows you to provide values that can be reused in other elements of the pom.xml?

1.

Plugins

2.

Build

3.

Properties

4.

Parent

Q 1 / 53

Maven

If you wish to build and package your artifact using the Maven package goal but don't want to execute the unit tests, which environment variable and value would you use?

1.

`maven.test.ignore=TRUE`

2.

`maven.test.run=FALSE`

3.

`maven.test.skip=TRUE`

4.

`maven.verify.execute=FALSE`

Q 2 / 53

Maven

When building a Maven EAR project and specifying the configuration of which projects to include, what is the element in the plugin configuration that contains Enterprise Java Bean projects?

1.

modules/webModule

2.

modules/ejbModule

3.

modules/enterpriseModules

4.

modules/services

Q 3 / 53

Maven

The goal that is executed to generate and deploy a documentation website is _.

1.

deliver

2.

site

3.

doc

4.

deploy

Q 4 / 53

Maven

What does the `mvn -version` command do?

1.

It builds your Maven project.

2.

It installs Maven on your computer.

3.

It updates Maven to the latest version.

4.

It print out your installed version of Maven.

Q 5 / 53

Maven

There are several properties available for use in a pom.xml file that refer to details of the project, such as groupId and version. What do all of these properties start with?

1.

pom

2.

maven

3.

jar

4.

project

Q 6 / 53

Maven

What directory structure contains the source code of your artifact?

1.

src/code

2.

src/test/java

3.

src/main/java

4.

src/main/resources

Q 7 / 53

Maven

Which command is used to run the clean lifecyle followed by verify, install, and package with Maven?

shell script mvn clean mvn package mvn verify mvn install

1.

`mvn clean istall package`

2.

`mvn package`

3.

`mvn clean install`

4.

Option 4

Q 8 / 53

Maven

Which goal would you use with the Dependency plugin to determine which included dependencies are not used, as well as those you are using that you have not defined?

1.

`dependency:tree`

2.

`dependency:properties`

3.

`dependency:evaluate`

4.

`dependency:analyze`

Q 9 / 53

Maven

In a multimodule project, if you have a plugin bound to a phase in the parent, it will be bound to the same phase in the module. What strategy could you employ to prevent the plugin from executing in the module?

1.

In the excluded element of the build section of the POM, list the plugin you do not want to run.

2.

Set the phase in the module to none.

3.

Set a value in the configuration of the plugin in the module to be excluded like this: TRUE.

4.

Do not specify the plugin in the module.

Q 10 / 53

Maven

When building a web application with a WAR type project, which project directory should contain the style sheet, JavaScript, and other static file?

1.

src/main/static

2.

src/main/web

3.

src/main/resources

4.

src/main/webapp

Q 11 / 53

Maven

When performing a build, which Maven plugin will allow you to set the specific version of the artifact to be built without manual modifying the pom.xml file?

1.

Compiler

2.

Surefire

3.

Versions

4.

Javadoc

Q 12 / 53

Maven

When building a Maven Archetype, what is the filepath and file of the archetype descriptor that specifies how to lay out the prototype files?

1.

`src/main/template/descriptor.xml`

2.

`src/main/resources/META-INF/maven/archetype-descriptor.xml`

3.

`src/main/archetype/descriptor.xml`

4.

`src/main/resources/META-INF/maven/maven-archetype.xml`

Q 13 / 53

Maven

What is a valid packaging type for a Maven project?

1.

WAR

2.

all of these answers

3.

POM

4.

EAR

Q 14 / 53

Maven

When two dependencies of your Maven project introduce the same transitive dependency with different versions, which one(s) will be included in the dependency list for your project?

1.

the dependency with the higher version

2.

the transitive dependency that comes from the dependency listed first in the pom.xml file

3.

the transitive dependency that comes from the dependency listed last in the pom.xml file

4.

the transitive dependency version of the artifact that is closest to your project

Q 15 / 53

Maven

Many organizations set up local mirrors to the Maven central repository. In order to leverage your company's Maven repository as a proxy for the Maven central repository, which element should you put into the settings.xml file?

1.

Replacements

2.

Proxies

3.

Mirrors

4.

LocalRepositories

Q 16 / 53

Maven

Which Maven plugin would you leverage to specify the version of the compiler to target as well as the source level of the language?

1.

Versions

2.

Surefire

3.

Target

4.

Compiler

Q 17 / 53

Maven

If your machine is behind a proxy, where should you specify the proxy server settings in order for Maven to access remote resources?

1.

`.m2/proxy.txt`

2.

`pom.xml`

3.

`proxy.xml`

4.

`settings.xml`

Q 18 / 53

Maven

What environment variable can you alter to increase the memory Maven uses?

1.

MAVEN_OPTS

2.

M2_HOME

3.

MAVEN_MEMORY

4.

PATH

Q 19 / 53

Maven

How can you use Maven to run unit tests in parallel?

1.

It is not possible to do this.

2.

Implement the JUnit dependency and add a configuration that sets the parallel element to true.

3.

Specify the Maven Surefire Plugin and add a configuration that sets the parallel element to true.

4.

Move each test suite into a separate submodule.

Q 20 / 53

Maven

What will the mvn dependency:tree command do?

1.

Verify the dependencies defined in the POM file.

2.

Print out a report of your project's dependencies in a tree format.

3.

Download all the transitive dependencies.

4.

Prune unused dependencies from your dependency tree.

Q 21 / 53

Maven

How do you run a single unit test in Maven?

1.

Maven runs only a single unit test by default.

2.

Use the -Dtest= flag and pass in the name of the test.

3.

Use a plugin that can specify the test you want to run.

4.

It is not possible to do this.

Q 22 / 53

Maven

How can Maven profiles be triggered?

1.

by explicitly calling the profiles using the -P flag

2.

based on environment variables

3.

all of these answers

4.

through Maven settings

Q 23 / 53

Maven

Why will an mvn install command not deploy any artifacts to a remote repository?

1.

The name of the artifact must also be specified in the command.

2.

The name of the remote repository must also be specified in the command.

3.

Deploying artifacts to a remote repository must be done manually.

4.

The deploy phase of the default Maven lifecycle comes after the install phase.

Q 24 / 53

Maven

Suppose you want to include a properties file in the JAR generated by your Maven build. What directory should you put it in?

1.

`${basedir}/src/main/resources`

2.

`${basedir}/src/main/java/resources`

3.

`${basedir}/resources`

4.

`${basedir}/src/main/properties`

Q 25 / 53

Maven

Which structure in a settings.xml file allows for flexing properties based on some value for the runtime of Maven?

1.

Environment

2.

Properties

3.

Switch

4.

Profiles

Q 26 / 53

Maven

What does it mean if the scope of a dependency is runtime?

1.

The dependency is not required to compile the project, but is needed at runtime.

2.

The dependency is needed at compile time and at runtime, and must be packaged for distribution.

3.

The dependency is needed at compile time and at runtime, but does NOT need to be packaged for distribution.

4.

The dependency is required for compilation.

Q 27 / 53

Maven

If you want to utilitze a locally developed JAR file in another project and that JAR file has not been deployed to either the Maven central repository or your own locally sourced mirror repository, what Maven goal do you need to execute on the locally developed JAR project?

1.

package

2.

install

3.

compile

4.

test

Q 28 / 53

Maven

What is the default packaging type for a Maven project build artifact?

1.

WAR

2.

JAR

3.

EAR

4.

POM

Q 29 / 53

Maven

What does the following command do?

> mvn archetype:generate -DgroupID=sample-maven-project -DartifactID=com.palmer.bethan.sample -Dversion=1.0.0 -DinteractiveMode=false

1.

It does nothing since no archetype has been specified

2.

It generates a new Maven archetype

3.

It generates a new Maven projet using the default Maven archetype

4.

It cleans and installs the sample-maven-project project

Q 30 / 53

Maven

When defining a dependency that is included with the runtime container, what scope do you use in the pom.xml?

1.

provided

2.

compile

3.

execution

4.

runtime

Q 31 / 53

Maven

What argument do you pass to Maven in order to update SNAPSHOT from the remote repository?

1.

-U

2.

-J

3.

-X

4.

-S

Q 32 / 53

Maven

When performing a release using the Maven release plugin, which environment variable for batch mode is used to define the stamp placed in SCM to indicate the state of the artifact for the actual release?

1.

tag

2.

scmMark

3.

developmentVersion

4.

releaseVersion

Q 33 / 53

Maven

These are two general uses of plugins. The first is build and the second is _

1.

reporting

2.

servers

3.

dependencies

4.

distribution management

Q 34 / 53

Maven

What does the mvn clean command do?

1.

It removes the target directory

2.

It updates the version of the plugins defined in the POM file.

3.

It removes unused dependencies in your project

4.

It builds your project

Q 35 / 53

Maven

If you want to utilize a locally develop JAR file in another project and that JAR file has not been deployed to either the Maven central repository or your own locally sourced mirror repository, what Maven goal do you need to execute on the locally developed JAR project?

1.

install

2.

test

3.

compile

4.

package

Q 36 / 53

Maven

Bellow is a definition of the Maven JAR Plugin, where the main class is set to com.palmer.bethan.App. What is the effect of this?

<configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.palmer.bethan.App</mainClass> </manifest> </archive> </configuration>

1.

Maven will generate javadocs for the App class.

2.

Maven will generate an executable JAR, which can be used to run the App class.

3.

Maven will include only the App class when it compiles the source code.

4.

Maven will add an empty main method to the App class.

Q 37 / 53

Maven

Suppose you are packaging a Maven project and see the following error "[WARNING] Using platform encoding (CP1252 actually) to copy filtered resources, i.e. build platform dependent!" What do you add to your POM file to set platform encoding to ensure your build is not platform dependet ?

1.

<project.build.resources>

2.

<maven.compiler.source>

3.

<project.build.sourceEncoding>

4.

<project.compiler.encoding>

Q 38 / 53

Maven

Why might you not want to include groupId and version elements in child POM files?

1.

If you include these elements, an error will be thrown when you try to build the project.

2.

These elements are inherited from the parent POM file, and do not need to be repeated.

3.

Child POM files should include definitions of only dependencies and plugins.

4.

The values in the parent POM will be overridden by what is defined in the child POM.

Q 39 / 53

Maven

The settings.xml file that provides the user-specific settings for Maven is contained in which directory by default?

1.

`${maven.home}/${user.name}/settings.xml`

2.

`${user.home}/.m2/settings.xml`

3.

`${maven.home}/conf/settings.xml`

4.

`${user.home}/maven/settings.xml`

Q 40 / 53

Maven

Suppose you are using Maven in a corporate environment and, to save bandwidth, you want to prevent the need for large numbers of developers to download the same dependency from the internet. What do you do to limit this?

1.

Create an internal corporate repository to store copies of the necessary artifacts.

2.

It is not possible to do this.

3.

When defining the dependency, set the scope to provided.

4.

Each developer should define the dependency in the POM file in the local copy of the project.

Q 41 / 53

Maven

In multimodule projects, what do child POMs inherit from the parent POM?

1.

all of these answers

2.

dependencies

3.

groupId

4.

version

Q 42 / 53

Maven

Below is a report generated for a multimodule project with the Checkstyle Plugin. Why might the highlighted links to the two child projects _not_ work?

![q43](q43.png)

1.

The Checkstyle Plugin does not work on child modules.

2.

Each Checkstyle report is in the target/site folder of the respective module.

3.

All links in Checkstyle reports must be specified in the plugin definition.

4.

Checkstyle reports for child modules have to be behind a firewall.

Q 43 / 53

Maven

Which build plugin allows you to create a "fat" JAR file that contains all of the dependencies in the final JAR file?

1.

Fatjar

2.

Shade

3.

Dependency

4.

Package

Q 44 / 53

Maven

What is the default scope for Maven dependencies?

1.

Test

2.

Compile

3.

Runtime

4.

Build

Q 45 / 53

Maven

How many times is compiler:compile called when executing mvn clean compile test package?

1.

one

2.

two

3.

none

4.

three

Q 46 / 53

Maven

What is one of the advantages of using properties in Maven?

1.

Properties provide a template for you to build Maven projects with a certain structure.

2.

Properties allow you to inherit values from the parent POM in the child POM.

3.

You can avoid hard-coding values in multiple places.

4.

Properties speed up your Maven build.

Q 47 / 53

Maven

What are the phases of the clean lifecycle?

1.

pre-clean,clean and post-clean

2.

Compile, clean and install

3.

clean and install

4.

validate, clean and deploy

Q 48 / 53

Maven

A compile-time dependency of a dependency for your project is often called **a_** dependency.

1.

Transitive

2.

runtime

3.

provided

4.

test

Q 49 / 53

Maven

For what purpose can plugins use the validate phase in the default lifecycle?

1. [stackoverflow](https://stackoverflow.com/a/40601037) 2. [maven docs](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#a-build-lifecycle-is-made-up-of-phases)

1.

to check the parent POM file defines all of the child POM files

2.

to carry out checks before building the project

3.

to ensure plugins defined in the POM file are in the correct order

4.

to check the project structure is correct after building a project

Q 50 / 53

Maven

How do you check for unused dependencies in your project?

1. [baeldung](https://www.baeldung.com/maven-unused-dependencies) 2. [stackoverflow](https://stackoverflow.com/a/1518661)

1.

Run mvn clean and look at which plugins are not mentioned in the output.

2.

You will need to do this manually.

3.

Include the Maven dependency plugin in your POM file and run the unpack goal.

4.

Run the analyze goal of the dependency plugin.

Q 51 / 53

Maven

Why is it best practice to avoid overriding the default directory structure?

1.

Keeping the default structure reduces onboarding time, because developers recognize it.

2.

Overriding the default structure is very complex.

3.

Overriding the default structure will cause Maven to take longer to compile your code.

4.

all of these answers

Q 52 / 53

Maven

What is the main purpose of the install phase?

1.

to compile the source code of the project

2.

to install all of the remote dependencies

3.

to deploy the final project artifacts into a remote Maven repository

4.

to copy the final project artifacts into the local Maven repository

Q 53 / 53