Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apache Maven Cookbook

You're reading from  Apache Maven Cookbook

Product type Book
Published in Apr 2015
Publisher Packt
ISBN-13 9781785286124
Pages 272 pages
Edition 1st Edition
Languages

Table of Contents (18) Chapters

Apache Maven Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started 2. IDE Integration with Maven 3. Maven Lifecycle 4. Essential Maven Plugins 5. Dependency Management 6. Code Quality Plugins 7. Reporting and Documentation 8. Handling Typical Build Requirements 9. Multi-module Projects 10. Java Development with Maven 11. Advanced Maven Usage Index

Generating a JAR of the test classes


There could be situations when you would want to use the test classes and resources of a project as a test dependency in another project. This is typically the case in multi-module projects, where a module depends on another module. There could be utility code in the test classes of a module that can be reused in another module.

One way to achieve this would be by creating a separate project to hold these classes. However, that is cumbersome and may be confusing as well.

Maven provides another way to achieve this.

How to do it...

  1. Open a project for which you want to create a test JAR (project-with-test-jar).

  2. Add the following plugin configuration to the pom file:

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.5</version>
            <executions>
              <execution>
                <goals...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}