How can I include unit tests in maven assembly?

Reason: Our project is using Ant as commandline interface. After making a new assembly with maven's assembly plugin, I want to make initial tests to see if all has been properly assembled. Therefore I need to include the unit tests in the final assembly. After assembling, the initial tests would then be called sth like

> ant initTest

build.xml:

<target="initTest"> <junit> <test class="MyTest" /> </junit> </target>

Problem is: I want to keep my Unit tests in src/test/java and not move them to src/main/java. Is there a way to tell the assembly plugin to include my unit tests? A simple include in the assembly descriptor does not do it ...

-------------Problems Reply------------

There are two steps:

  1. Package the tests into a jar as well as the main code.
  2. Depend on that "-tests" jar in the module that makes the assembly.

To package up the tests, you need to bin the jar:test-jar goal. e.g.

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>test-jar</id>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Then in the assembly module, you can depend on the resulting artifact.

<dependencies>
<dependency>
<groupid>${project.groupId}</groupId>
<artifactId>some-artifact</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
</dependency>
</dependencies>

The key bit is the "classifier".

Category:maven 2 Views:0 Time:2009-06-19

Related post

  • Maven assembly include problem 2009-09-28

    Context We have this application, using about 60 coding projects. We have several products that are realized using this same code base, so we follow the maven best-practices : we assemble each product using an assembly project, using the assembly plu

  • How to include unit tests in a ruby module? 2009-12-01

    I'm trying to include the unit tests for a module in the same source file as the module itself, following the Perl modulino model. #! /usr/bin/env ruby require 'test/unit' module Modulino def modulino_function return 0 end end class ModulinoTest <

  • Maven Assembly plugin - Include repo jars 2009-12-24

    I have a multi module project and I am using assembly plugin to build a tar file. I have included all of my modules in assembly plugin using moduleSets tag. <moduleSets> <moduleSet> <includes> <include>module1</include>

  • How do I include configuration files with Maven Appassembler? 2010-01-18

    I'm using the Maven Appassembler plugin to package my application. I'd like to package some configuration files with the application. I've found the configurationDirectory and includeConfigurationDirectoryInClasspath parameters, but I haven't found h

  • Maven Assembly: include a dependency with a different classifier 2010-04-22

    I would like to build two different versions of a WAR in Maven (I know that's a no-no, that's just the way it is given the current situation). In the version of a WAR depicted by an assembly, I want to replace a dependency by the same dependency with

  • Maven Assembly Plugin - Include Dependencies from Sub-Modules? 2010-08-08

    I am trying to setup the assembly plugin for a large multi-module project. The goal right now is to just get all of my artifacts into a directory. Here is my descriptor: <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assemb

  • How do I make a WAR archive produced with maven-assembly-plugin available for other projects' unit tests? 2010-10-22

    My problem consists of two maven projects, a server project A and a client project B. A uses maven-assembly-plugin to produce several variants of A, where one variant is a WAR archive. The problem I am facing relates to the test-driven development of

  • building a jar and including it in a zip with maven-assembly-plugin 2011-02-09

    I have a mavenized java project (Maven2) which I want to build into a jar, which is easy enough by supplying the jar-with-dependencies descriptorRef in the pom.xml. However I also need to deploy my project in a zip with some .exe and .bat files, amon

  • XCode 4 - 'Include Unit Tests' 2011-03-14

    I just upgraded to XCode 4 and I was wondering if I need to 'include unit tests' when setting up an application? Also, what does that mean exactly? --------------Solutions------------- You do not need to include unit tests. What does "unit testing" m

  • Maven assembly dependency set with include doesn't pick up transitive dependencies 2011-05-16

    I'm having a spot of bother with the Maven assembly goal. I have a project which has a number of dependencies each of which may have their own transitive dependencies. If I run mvn dependency:tree than I can see all the dependencies including transit

  • Maven assembly: include JDBC 2011-10-19

    I'm trying to build a single .jar file from a Maven project which includes every necessary dependency. Therefore the .jar should run on a computer with missing libraries. The in my pom.xml: <dependencies> <dependency> <groupId>junit

  • Maven assembly Include too many dependencies in a ZIP 2011-10-21

    I have a Maven multi-module project. In one module, we create a ZIP with maven-assembly-plugin plugin. The configuration for this: <baseDirectory>/</baseDirectory> <formats> <format>zip</format> </formats> <incl

  • How to include dependency with 'provided' scope with maven-assembly-plugin 2011-11-17

    I am fighting with maven to include a managed dependency with 'provided' scope into tar file by using the maven-assembly-plugin. I use super parent pom file as a base for all of my projects. most of the projects will be deployed under application ser

  • Include jar files from maven repository to eclipse project? 2012-03-08

    How can I include jars from local maven repository into eclipse project? Actually, I need to include them into WebContent/WEB-INF/lib directory in eclipse web service project, if it makes any differencies. --------------Solutions------------- Open yo

  • Format values to include unit size 2012-11-24

    How to format number (e.g. 10) to include unit size; e.g. gal in a cell so it appears as 10 gal but acts as a number or value --------------Solutions------------- Format> Cells - Custom, select one of the number models there [such as #,##0] then a

  • maven assembly include all sub-module dependencies without "already added, skipping" 2011-02-06

    So I have a parent module with a bunch of sub-modules, and I'm trying to generate a zip file with all of the module jars and all of their dependencies. My assembly descriptor looks like (similar to this question): <assembly xmlns="http://maven.apa

  • Maven Assembly Plugin - Include other child dependencies in assembly 2011-12-13

    I have four child pom under one parent. One of the children is to build a zip containing the other 3 modules jars. This works but it doesn't pick up their respective dependencies. module-build pom.xml : ... <plugin> <artifactId>maven-asse

  • What sort of configuration issues or problems might make Maven Assembly plugin go slowly? 2012-01-25

    Our multi-module Maven project used to take 4-6 minutes to build. Over the past few months, it has increased to 20+ minutes per build. One symptom is that sometimes the build appears to pause until I hit <enter>. However, the Maven build still

  • Why does the maven-assembly-plugin puts the same dependency in my zip multiple times? 2009-05-11

    I put together an assembly descriptor <assembly> <id>all</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <moduleSets> <moduleSet> <

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.135 (s). 11 q(s)