Skip to content

Commit

Permalink
Add maven flag to create tests jar with dependencies
Browse files Browse the repository at this point in the history
Sometimes it is usefull to be able to run a test or a benchmark on the other
machine than a development one. For example it is prefered to run benchmarks on
a solid desktop or on a server machine to overcome overheating deviations in benchmark
execution time.

Since most of the modules have complex dependency tree it is very hard to copy
every dependency to the remote server and write a cmd line that has all the dependencies
included.

This commit is supposed to address this issue.

Now we can tell maven to assemble an uber(fat) jar that includes the entire "test" scope
classpath for a particular module.

For example after running:

./mvnw clean install -P tests-with-dependencies -pl presto-geospatial

The uber jar that contains the entire class path of the "test" scope of the "presto-geospatial"
module is created and placed to that modules target directory:

./presto-geospatial/target/presto-geospatial-0.197-SNAPSHOT-tests-with-dependencies.jar

Now using this jar we can easly run any benchmark from that module via the command line:

java \
  -cp ./presto-geospatial/target/presto-geospatial-*-tests-with-dependencies.jar \
  com.facebook.presto.plugin.geospatial.BenchmarkSTIntersects
  • Loading branch information
arhimondr authored and mbasmanova committed Mar 20, 2018
1 parent 3401761 commit 257c561
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1201,4 +1201,47 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>tests-with-dependencies</id>
<!--
Assembles an uber (fat) jar that includes the entire "test" scope classpath for a module.
For example after running:
./mvnw clean install -P tests-with-dependencies -pl presto-geospatial
The uber jar that contains the entire "test" scope class path of the "presto-geospatial"
is created and placed to that modules target directory:
./presto-geospatial/target/presto-geospatial-0.197-SNAPSHOT-tests-with-dependencies.jar
Now using this jar we can easily run any benchmark from that module via command line:
java \
-cp ./presto-geospatial/target/presto-geospatial-*-tests-with-dependencies.jar \
com.facebook.presto.plugin.geospatial.BenchmarkSTIntersects
-->
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>${air.main.basedir}/src/assembly/tests-with-dependencies.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
37 changes: 37 additions & 0 deletions src/assembly/tests-with-dependencies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>tests-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</unpackOptions>
<scope>test</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/test-classes</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>

0 comments on commit 257c561

Please sign in to comment.