Changeset: e238d748680d for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/e238d748680d
Added Files:
        src/test/assembly/test-jar-with-deps.xml
Modified Files:
        pom.xml
Branch: mvn
Log Message:

Create a jdbctests.jar for compatibility with Mtest

Make sure it contains Junit and a Junit test runner.
The test runner can be run with the command

    java -cp target/monetdb-jdbc-12.1-SNAPSHOT.jar:target/jdbctests.jar 
org.junit.platform.console.ConsoleLauncher execute -p org.monetdb


diffs (136 lines):

diff --git a/pom.xml b/pom.xml
--- a/pom.xml
+++ b/pom.xml
@@ -73,6 +73,13 @@
             <scope>test</scope>
         </dependency>
 
+        <!-- this serves as the main class for the jdbctests.jar -->
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-console</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>
@@ -139,6 +146,12 @@
                     <version>3.11.2</version>
                 </plugin>
 
+                <plugin>
+                    <groupId>com.coderplus.maven.plugins</groupId>
+                    <artifactId>copy-rename-maven-plugin</artifactId>
+                    <version>1.0.1</version>
+                </plugin>
+
             </plugins>
         </pluginManagement>
 
@@ -176,6 +189,56 @@
                 </executions>
             </plugin>
 
+            <!-- Generate a jar that includes all dependencies such as Junit.
+                 The result gets a name like 
monetdb-jdbc-12.1-SNAPSHOT-test-jar-with-deps.jar.
+                 This can be changed by uncommenting the <finalName> and 
<appendAssemblyId> settings
+                 but that causes a warning that cannot be suppressed.
+                 So instead we will use yet another plugin to rename the thing.
+             -->
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                     <!-- <finalName>jdbctests</finalName> -->
+                     <!-- <appendAssemblyId>false</appendAssemblyId> -->
+                    <descriptors>
+                        
<descriptor>src/test/assembly/test-jar-with-deps.xml</descriptor>
+                    </descriptors>
+                    <archive>
+                        <manifest>
+                            
<mainClass>org.junit.platform.console.ConsoleLauncher</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-tests-jar-with-deps</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <!-- Rename the jar-with-deps created above -->
+            <plugin>
+                <groupId>com.coderplus.maven.plugins</groupId>
+                <artifactId>copy-rename-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>rename-jar-with-deps</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>rename</goal>
+                        </goals>
+                        <configuration>
+                            
<sourceFile>${project.build.directory}/${build.finalName}-test-jar-with-deps.jar</sourceFile>
+                            
<destinationFile>${project.build.directory}/jdbctests.jar</destinationFile>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-source-plugin</artifactId>
@@ -212,7 +275,6 @@
                 nexus-staging-maven-plugin
                 maven-release-plugin
                 maven-gpg-plugin
-
             -->
 
         </plugins>
diff --git a/src/test/assembly/test-jar-with-deps.xml 
b/src/test/assembly/test-jar-with-deps.xml
new file mode 100644
--- /dev/null
+++ b/src/test/assembly/test-jar-with-deps.xml
@@ -0,0 +1,35 @@
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0";
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 
https://maven.apache.org/xsd/assembly-2.2.0.xsd";>
+
+    <id>test-jar-with-deps</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <dependencySets>
+
+        <!-- this pulls in our test code -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <includes>
+                
<include>${project.groupId}:${project.artifactId}:test-jar</include>
+            </includes>
+            <useProjectAttachments>true</useProjectAttachments>
+            <unpack>true</unpack>
+            <scope>test</scope>
+        </dependencySet>
+
+        <!-- this pulls in all dependencies -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <excludes>
+                <exclude>${project.groupId}:${project.artifactId}:jar</exclude>
+            </excludes>
+            <unpack>true</unpack>
+            <scope>test</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>
\ No newline at end of file
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to