CDI TCKCommunity Documentation
One of the requirements of an implementation passing the TCK is for it to pass the CDI signature test. This section describes how the signature file is generated and how to run it against your implementation.
The sigtest plugin is availble from Maven Central using a dependency like:
...
<plugin>
<groupId>org.netbeans.tools</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
The source for the sigtest plugin can be found here: https://github.com/jtulach/netbeans-apitest
To run the signature test, use a pom file like that found in https://github.com/eclipse-ee4j/cdi-tck/blob/master/impl/src/main/resources/sigtest-pom.xml and shown here:
<?xml version="1.0"?>
<!-- Sample maven pom to verify signatures -->
<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">
<modelVersion>4.0.0</modelVersion>
<!-- For access to staging repos, add -Pstaging -->
<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.6</version>
</parent>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-sigtest</artifactId>
<version>4.0</version>
<name>CDI TCK Signature Tests</name>
<description>CDI TCK Signature test validation of CDI dependent API jars</description>
<properties>
<!-- Set the api jar artifact versions here -->
<annotation.api.version>2.1.0</annotation.api.version>
<atinject.api.version>2.0.1</atinject.api.version>
<interceptor.api.version>2.1.0</interceptor.api.version>
<el.api.version>5.0.0</el.api.version>
<cdi.api.version>4.0.0-RC5</cdi.api.version>
</properties>
<!-- Set the api jar artifact dependencies here -->
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${annotation.api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>${el.api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.interceptor</groupId>
<artifactId>jakarta.interceptor-api</artifactId>
<version>${interceptor.api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>${atinject.api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.lang-model</artifactId>
<version>${cdi.api.version}</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>${cdi.api.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<overWriteReleases>true</overWriteReleases>
<outputDirectory>target/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.netbeans.tools</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sigtest</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<sigfile>cdi-api-jdk11.sig</sigfile>
<packages>jakarta.decorator,jakarta.enterprise,jakarta.interceptor</packages>
<classes>target/classes</classes>
<report>cdi-sig-report.txt</report>
</configuration>
</plugin>
</plugins>
</build>
</project>
Your version should specify the dependencies on these jars as used in your compatible implementation.
Scotts-iMacPro:resources starksm$ mvn -f sigtest-pom.xml verify [INFO] Scanning for projects... [INFO] [INFO] -----------------< jakarta.enterprise:cdi-tck-sigtest >----------------- [INFO] Building CDI TCK Signature Tests 4.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] ... [INFO] --- sigtest-maven-plugin:1.5:check (sigtest) @ cdi-tck-sigtest --- [INFO] Packages: jakarta.decorator,jakarta.enterprise [INFO] SignatureTest report Base version: 4.0.0-SNAPSHOT Tested version: 4.0 Check mode: bin [throws removed] Constant checking: on Warning: The return type java.lang.reflect.Member can't be resolved Warning: The return type java.lang.reflect.Member can't be resolved Warning: The return type java.lang.reflect.Member can't be resolved [INFO] /Users/starksm/Dev/JBoss/Jakarta/cdi-tck/impl/src/main/resources/cdi-sig-report.txt: 0 failures in /Users/starksm/Dev/JBoss/Jakarta/cdi-tck/impl/src/main/resources/cdi-api-jdk11.sig [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.941 s [INFO] Finished at: 2021-12-13T11:38:06-06:00 [INFO] ------------------------------------------------------------------------
You can ignore the following warnings: "The return type java.lang.reflect.Member can't be resolved"
The important thing is that the mvn version shows "BUILD SUCCESS".
Another example that just specifies a compatible implementation test as the dependency to validate the API artifact signatures from the transitive dependencies is pom file like that found in https://github.com/eclipse-ee4j/cdi-tck/blob/master/impl/src/main/resources/sigtest-weld-pom.xml and shown here:
<?xml version="1.0"?>
<!-- Sample maven pom to verify signatures using only the weld-core-imp artifiact and its dependencies -->
<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">
<modelVersion>4.0.0</modelVersion>
<!-- For access to staging repos, add -Pstaging -->
<parent>
<groupId>org.eclipse.ee4j</groupId>
<artifactId>project</artifactId>
<version>1.0.6</version>
</parent>
<groupId>jakarta.enterprise</groupId>
<artifactId>cdi-tck-weld-sigtest</artifactId>
<version>4.0</version>
<name>CDI TCK Signature Tests</name>
<description>CDI TCK Signature test validation of CDI dependent API jars</description>
<properties>
<!-- Set the Weld version to test -->
<weld.version>5.0.0.Beta1</weld.version>
</properties>
<!-- Set the api jar artifact dependencies here -->
<dependencies>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-impl</artifactId>
<version>${weld.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/classes</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.netbeans.tools</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sigtest</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<sigfile>cdi-api-jdk11.sig</sigfile>
<packages>jakarta.decorator,jakarta.enterprise,jakarta.interceptor</packages>
<classes>target/classes</classes>
<report>cdi-sig-report.txt</report>
</configuration>
</plugin>
</plugins>
</build>
</project>
CDI Lite requires the same signature tests as Full. Even though CDI Lite does not require some of the Jakarta Interceptors behaviors, we did not want to restrict what CDI Lite implementations might provide in the way of interceptors, for example, an implementation that supports both Lite and Full. An implementation of CDI Lite can simply depend on the Jakarta Interceptors API artifact to meet the signature test requirements.
Just for fun (and to confirm that the signature test is working correctly), you can try the following:
1) Edit cdi-api-jdk11.sig
2) Modify one of the class signatures - in the following example we change one of the constructors for BusyConversationException - here’s the original:
CLSS public jakarta.enterprise.context.BusyConversationException cons public BusyConversationException() cons public BusyConversationException(java.lang.String) cons public BusyConversationException(java.lang.String,java.lang.Throwable) cons public BusyConversationException(java.lang.Throwable) supr jakarta.enterprise.context.ContextException hfds serialVersionUID
Let’s change the default (empty) constructor parameter to one with a java.lang.Integer parameter instead:
CLSS public jakarta.enterprise.context.BusyConversationException cons public BusyConversationException(java.lang.Integer) cons public BusyConversationException(java.lang.String) cons public BusyConversationException(java.lang.String,java.lang.Throwable) cons public BusyConversationException(java.lang.Throwable) supr jakarta.enterprise.context.ContextException hfds serialVersionUID
3) Now when we run the signature test using the above command, we should get the following errors:
Missing Constructors -------------------- jakarta.enterprise.context.BusyConversationException: constructor public jakarta.enterprise.context.BusyConversationException.BusyConversationException(java.lang.Integer) Added Constructors ------------------ jakarta.enterprise.context.BusyConversationException: constructor public jakarta.enterprise.context.BusyConversationException.BusyConversationException() STATUS:Failed.2 errors