diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml
index 7a742a3..8bce6d3 100644
--- a/.github/workflows/release-production.yml
+++ b/.github/workflows/release-production.yml
@@ -31,14 +31,25 @@ jobs:
- name: Test
run: mvn -B package --file pom.xml
+ - name: install Snapshot for Artifact Test
+ run: |
+ export VERSION=`echo ${{ github.event.release.tag_name }} | awk '{print substr($0, 2)}'`
+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
+ sed -e s/999-SNAPSHOT/${VERSION}/g jfr4jdbc-driver/pom.xml > jfr4jdbc-driver/versionedPom.xml
+ mvn -B package --no-transfer-progress -DskipTests --file jfr4jdbc-driver/versionedPom.xml
+ mvn -B --no-transfer-progress install:install-file -Dfile=target/jfr4jdbc-driver-${VERSION}.jar -DgroupId=dev.jfr4jdbc -DartifactId=jfr4jdbc-driver -Dversion=${VERSION} -Dpackaging=jar --file jfr4jdbc-driver/versionedPom.xml
+
+ - name: Artifact Test
+ run: |
+ sed -e s/999-SNAPSHOT/${VERSION}/g artifact-test/pom.xml > artifact-test/versionedPom.xml
+ mvn -B test --file artifact-test/versionedPom.xml
+
- name: Deploy Production
env:
OSSRH_USERNAME: ${{ secrets.MAVEN_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.MAVEN_USER_PASSWORD }}
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: |
- export VERSION=`echo ${{ github.event.release.tag_name }} | awk '{print substr($0, 2)}'`
- sed -e s/999-SNAPSHOT/${VERSION}/g jfr4jdbc-driver/pom.xml > jfr4jdbc-driver/versionedPom.xml
mvn -B deploy --no-transfer-progress -DskipTests --file jfr4jdbc-driver/versionedPom.xml
mkdir release && cp jfr4jdbc-driver/target/*.jar release
diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml
index afb8197..d919867 100644
--- a/.github/workflows/release-snapshot.yml
+++ b/.github/workflows/release-snapshot.yml
@@ -29,6 +29,14 @@ jobs:
- name: Test
run: mvn -B package --file pom.xml
+ - name: install Snapshot for Artifact Test
+ run: |
+ mvn -B package --no-transfer-progress -DskipTests --file jfr4jdbc-driver/pom.xml
+ mvn -B --no-transfer-progress install:install-file -Dfile=target/jfr4jdbc-driver-999-SNAPSHOT.jar -DgroupId=dev.jfr4jdbc -DartifactId=jfr4jdbc-driver -Dversion=999-SNAPSHOT -Dpackaging=jar --file jfr4jdbc-driver/pom.xml
+
+ - name: Artifact Test
+ run: mvn -B test --file artifact-test/pom.xml
+
- name: Deploy Snapshot
env:
OSSRH_USERNAME: ${{ secrets.MAVEN_USERNAME }}
diff --git a/artifact-test/pom.xml b/artifact-test/pom.xml
new file mode 100644
index 0000000..53d8a05
--- /dev/null
+++ b/artifact-test/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ dev.jfr4jdbc
+ artifact-test
+ 999-SNAPSHOT
+
+
+ UTF-8
+ 11
+ 11
+ true
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
+
+
+
+
+
+
+
+ dev.jfr4jdbc
+ jfr4jdbc-driver
+ 999-SNAPSHOT
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.9.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.9.2
+ test
+
+
+
\ No newline at end of file
diff --git a/artifact-test/src/test/java/dev/jfr4jdbc/artifact/MultiReleaseJarTest.java b/artifact-test/src/test/java/dev/jfr4jdbc/artifact/MultiReleaseJarTest.java
new file mode 100644
index 0000000..3add496
--- /dev/null
+++ b/artifact-test/src/test/java/dev/jfr4jdbc/artifact/MultiReleaseJarTest.java
@@ -0,0 +1,86 @@
+package dev.jfr4jdbc.artifact;
+
+import org.junit.jupiter.api.*;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+public class MultiReleaseJarTest {
+
+ private JarFile open() throws IOException {
+ File artifactDir = new File("../jfr4jdbc-driver/target");
+ File[] files = artifactDir.listFiles((dir, name) -> name.matches("jfr4jdbc-driver-.+\\.jar") && !(name.endsWith("-javadoc.jar") || name.endsWith("-sources.jar")));
+ assertEquals(1, files.length);
+ return new JarFile(files[0]);
+ }
+
+ @DisplayName("Multi Release Jar")
+ @Test
+ void isMultiRelease() throws Exception {
+
+ JarFile jarFile = open();
+ assertTrue(jarFile.isMultiRelease());
+ }
+
+ @DisplayName("Service Loader File exists")
+ @Test
+ void hasServiceLoaderFile() throws IOException {
+ JarFile jarFile = open();
+ assertNotNull(jarFile.getEntry("META-INF/services/java.sql.Driver"));
+ }
+
+ @DisplayName("Java 11 Directory exists")
+ @Test
+ void hasJava11Directory() throws IOException {
+ JarFile jarFile = open();
+ assertNotNull(jarFile.getEntry("META-INF/versions/11"));
+ }
+
+ private final int JAVA_8_VERSION = 52;
+ private final int JAVA_11_VERSION = 55;
+
+ @DisplayName("Classes for JDBC 4.2 exists")
+ @Test
+ void hasJdbc42() throws IOException {
+ JarFile jarFile = open();
+
+ assertEquals(JAVA_8_VERSION, readMajorVersion(jarFile, "dev/jfr4jdbc/Jfr4JdbcDataSource.class"));
+ assertEquals(JAVA_8_VERSION, readMajorVersion(jarFile, "dev/jfr4jdbc/Jfr4JdbcDataSource42.class"));
+ }
+
+ @DisplayName("Classes for JDBC 4.3 exists")
+ @Test
+ void hasJdbc43() throws IOException {
+ JarFile jarFile = open();
+
+ assertEquals(JAVA_11_VERSION, readMajorVersion(jarFile, "META-INF/versions/11/dev/jfr4jdbc/Jfr4JdbcDataSource.class"));
+ assertEquals(JAVA_11_VERSION, readMajorVersion(jarFile, "META-INF/versions/11/dev/jfr4jdbc/Jfr4JdbcDataSource43.class"));
+ }
+
+
+ private int readMajorVersion(JarFile jarFile, String path) throws IOException {
+
+ ZipEntry classFileEntry = jarFile.getEntry(path);
+ InputStream inputStream = jarFile.getInputStream(classFileEntry);
+
+ DataInputStream dataInputStream = new DataInputStream(inputStream);
+ String cafe = Integer.toHexString(dataInputStream.readUnsignedShort());
+ assertEquals("cafe", cafe);
+ String babe = Integer.toHexString(dataInputStream.readUnsignedShort());
+ assertEquals("babe", babe);
+
+ int minorVersion = dataInputStream.readUnsignedShort();
+ int majorVersion = dataInputStream.readUnsignedShort();
+
+ inputStream.close();
+
+ return majorVersion;
+ }
+
+}
\ No newline at end of file
diff --git a/artifact-test/src/test/java/dev/jfr4jdbc/artifact/ServiceLoaderTest.java b/artifact-test/src/test/java/dev/jfr4jdbc/artifact/ServiceLoaderTest.java
new file mode 100644
index 0000000..6eabc82
--- /dev/null
+++ b/artifact-test/src/test/java/dev/jfr4jdbc/artifact/ServiceLoaderTest.java
@@ -0,0 +1,21 @@
+package dev.jfr4jdbc.artifact;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+
+import java.sql.Driver;
+import java.util.ServiceLoader;
+
+public class ServiceLoaderTest {
+ @DisplayName("ServiceLoader loads Jfr4Jdbc")
+ @Test
+ void loadedTest() throws Exception {
+ ServiceLoader loader = ServiceLoader.load(Driver.class);
+ long jfrDriverCount = loader.stream().filter(d -> d.get().getClass().getCanonicalName().equals("dev.jfr4jdbc.Jfr4JdbcDriver")).count();
+
+ assertEquals(1, jfrDriverCount);
+ }
+}
diff --git a/jfr4jdbc-driver/pom.xml b/jfr4jdbc-driver/pom.xml
index 68d934d..4c4e5db 100644
--- a/jfr4jdbc-driver/pom.xml
+++ b/jfr4jdbc-driver/pom.xml
@@ -6,7 +6,7 @@
dev.jfr4jdbc
jfr4jdbc-driver
- ${jfr4jdbc.version}
+ 999-SNAPSHOT
jfr4jdbc
A JDBC wrapper driver recording JDK Flight Recorder events
https://github.com/chiroito/Jfr4Jdbc
@@ -15,7 +15,6 @@
UTF-8
1.8
1.8
- 999-SNAPSHOT