Skip to content

Commit

Permalink
fix(issue #72): introduce *-with-asm jar which shades ASM and JaC… (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
famod authored Feb 18, 2020
1 parent 112d30e commit c9c1946
Show file tree
Hide file tree
Showing 44 changed files with 378 additions and 207 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

# Maven
target/
dependency-reduced-pom.xml

# TestNG
test-output/

# JBoss AS
transaction.log
# Misc
*.log

# Floobits configuration
.floo*
51 changes: 48 additions & 3 deletions README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
image:https://travis-ci.org/arquillian/arquillian-extension-jacoco.svg?branch=master["Build Status", link="https://travis-ci.org/arquillian/arquillian-extension-jacoco"]
image:https://img.shields.io/maven-central/v/org.jboss.arquillian.extension/arquillian-jacoco["Maven Central", link="https://maven-badges.herokuapp.com/maven-central/org.jboss.arquillian.extension/arquillian-jacoco"]


== Arquillian Jacoco Extension

Automagic Remote InContainer Codecoverage

=== Usage

==== Maven pom.xml
==== Maven default setup

Add the following to your pom.xml:

Expand All @@ -17,8 +19,8 @@ Set the versions to use:
----
...
<properties>
<version.jacoco>0.8.2</version.jacoco>
<version.arquillian_jacoco>1.0.0.Final-SNAPSHOT</version.arquillian_jacoco>
<version.jacoco>0.8.3</version.jacoco>
<version.arquillian_jacoco>1.0.0</version.arquillian_jacoco>
</properties>
...
----
Expand Down Expand Up @@ -77,6 +79,49 @@ Activate this profile on command line by using the -P flag:
mvn test -Pjacoco
----

Please note that `prepare-agent` will set a property that is picked up by `maven-surefire-plugin` by default
(see https://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html[documentation]).

==== Maven setup with shaded ASM and jacoco-core

JaCoCo requires ASM to work properly. Since ASM is also used by many other libraries like Apache CXF, you might run into version conflicts. +
E.g. JBoss EAP 6.4 ships CXF 2.7 which requires ASM 3 but JaCoCo requires ASM 7+.

As a workaround, this extension provides an alternate `with-asm` flavour that includes "private" ASM and JaCoCo packages, shaded via `maven-shade-plugin`.

You only need a single dependency for this setup:
[source, xml]
----
...
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco-with-asm</artifactId>
<version>${version.arquillian_jacoco}</version>
<scope>test</scope>
</dependency>
</dependencies>
----

Please note the absence of the `jacoco-core` dependency.

==== (Optional) arquillian.xml

This extension can by configured via `arquillian.xml`, e.g.:

[source, xml]
----
...
<extension qualifier="jacoco">
<property name="includes">org.foo.*; org.bar.*</property>
<property name="excludes">org.bar.baz.*</property>
<property name="appendAsmLibrary">true</property>
</extension>
----

`appendAsmLibrary` will deploy the ASM library (which is used by JaCoCo) to the server. Defaults to `true`. +
This can be set to `false` in case the container already provides a suitable version of ASM. +
In case the `with-asm` flavour is used this property _must_ be set to `true`.

==== Sonar

Expand Down
87 changes: 87 additions & 0 deletions arquillian-jacoco-with-asm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<!-- Parent -->
<parent>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco-parent</artifactId>
<version>1.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>arquillian-jacoco-with-asm</artifactId>
<name>Arquillian Extension Jacoco with ASM</name>
<description>Jacoco integration to add code coverage to Arquillian, with relocated ASM and JaCoCo</description>

<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Need to re-define JaCoCo with compile scope instead of provided due to limitations of maven-shade-plugin,
see also: https://issues.apache.org/jira/browse/MSHADE-181 -->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${version.maven-shade-plugin}</version>
<executions>
<execution>
<id>shade</id>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.jboss.arquillian.extension.jacoco.org.objectweb.asm</shadedPattern>
</relocation>
<relocation>
<pattern>org.jacoco</pattern>
<shadedPattern>org.jboss.arquillian.extension.jacoco.org.jacoco</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<includes>
<include>org.ow2.asm:*</include>
<include>org.jacoco:*</include>
<include>org.jboss.arquillian.extension:*</include>
</includes>
</artifactSet>
<filters>
<!-- drop module-info.class and MANIFEST.MF files which would clash anyway -->
<!-- drop signatures -->
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<!-- generate a MANIFEST.MF -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit c9c1946

Please sign in to comment.