Embedding

Objenesis is jarjar and maven-shade-plugin compliant.

# Ant

A jarjar ant task is available. You just need to replace your usual jar task with jarjar. Depending on the complexity of your project, you will then have different parameters. Here's an example:

    	<jarjar jarfile="${temp directory}/easymockclassextension.jar">
    	  <fileset dir="tmp" includes="org/easymock/classextension/*.class
    	    org/easymock/classextension/internal/*.class"/>
    	  <zipfileset src="lib/objenesis-${project.version}.jar"/>
    	  <rule pattern="org.objenesis.**"
    	    result="org.easymock.classextension.internal.objenesis.@1"/>
    	</jarjar>

# Maven

For jarjar, multiple unofficial plugins exist (here, here and here). However, you can use the antrun plugin to call the jarjar ant task.

Or you can use the maven-shade-plugin. Here's an example:

          <plugin>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
              <artifactSet>
                <includes>
                  <include>org.objenesis:objenesis</include>
                </includes>
              </artifactSet>
              <relocations>
                <relocation>
                  <pattern>org.objenesis</pattern>
                  <shadedPattern>org.easymock.classextension.internal.objenesis</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </plugin>