Jmeter + Maven: how to add a jar file to JMeter /lib/ext folder - maven

I have a Jmeter-Maven project and I'd like to put a modified jar file in "/lib/ext" folder.
I've added it to “/src/test/jmeter/lib/ext”, but seems it doesn't work.
Do I need to add dependencies to my POM file or so?
Any suggestions?
Thanks in advance for answers!

You can add libraries to "lib/ext" folder as follows:
<configuration>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-casutg:2.4</artifact>
</jmeterExtensions>
</configuration>
Replace kg.apc:jmeter-plugins-casutg:2.4 with your own artifact in form of:
groupId:artifactId:version
References:
Guide to naming conventions on groupId, artifactId and version
Adding jar's to the /lib/ext directory
Five Ways To Launch a JMeter Test without Using the JMeter GUI

Related

add external libraries jar to jmeter-maven-plugin

Hello I'm using this https://github.com/jmeter-maven-plugin/jmeter-maven-plugin currently which the sample project works fine with a simple jmeter test.
However, I was wondering how does jars get added to the /lib folder.
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.174</version>
I need the above dependencies for my testplan in which my preprocessors uses certain imports from within it.
In JMeter its just drag and drop all jars related into the folder.
I tried adding the top code into the pom file to no avail since after running it the log file says unable to resolve import. There seem to be plugins documentation but I thought dependencies labelled on the pom files gets built with any JMeter tests.
Any help or clarification is appreciated.
See Adding jar's to the /lib directory
add any additional Java libraries to JMeter's lib/ directory by using the <testPlanLibraries> configuration element
<configuration>
<testPlanLibraries>
<artifact>org.apache.activemq:activemq-spring:5.15.2</artifact>
In your case
<artifact>com.amazonaws:aws-java-sdk-s3:1.12.174</artifact>

Extract current folder name within maven pom.xml file

I am looking for a way to dynamically extract the current folder name within maven pom.xml file.
For Example:
if the pom.xml file is at /home/jenkins/workspace/bdms-ci/bdms-bcr/pom.xml
then bdms-bcr is the current folder.
See a code snippet:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<testClassesDirectory>../../bdms-ci-improve/${project.basedir}/target/test-classes</testClassesDirectory>
<classesDirectory>../../bdms-ci-improve/${project.basedir}/target/classes</classesDirectory>
</configuration>
</plugin>
${project.basedir} will bring the full path which is not good since only the current folder is needed.
I tried to work with MavenProject class from the maven api document:
${project.file.parentFile.name} or ${project.file.name}, but it didn't work.
remember it is maven multi project and everything has to be dynamically.
The whole issue is for jenkins ci build which use parallel-test-executor plugin. I would like to compile once in the main job and then all the other test execute jobs will will only test by looking into the compiled code.
Using maven 3.2.3
#guymi,
Seems like you should be able to simply use ${project.artifactId} or perhaps ${parent.artifactId}.
EDIT
Or does your artifactId name disagree with the directory it's stored in?
If so, that's possible but not good practice and should be avoided.
It is not possible to do it. simple as that.
A workaround solution is by using artifactId with the same name as folder name. then you can do:
../../bdms-ci-improve/${project.artifactId}/target/test-classes</testClassesDirectory>

Version in jar name

When I import mvn project into Intellij the jar file it generates doesn't include version. But mvn generated jar has name-version.jar format. So I end up with two jar files one with version and another without one. I can of course, change module name in Intellij settings to include version. But that will be reset whenever I change pom file.
Maybe somebody else had a better idea?
The jar name that Maven generates on disk is controlled by /project/build/finalName so if you edit your pom.xml to look like
<project>
...
<build>
...
<finalName>${artifactId}</finalName>
...
</build>
...
</project>
and then Maven will be generating the jar file without the version.
Note
finalName only controls the name of the file on disk. Once that file is transferred into the local repository cache or a remote repository it will be renamed to match the repository layout (i.e. ${artifactId}-${version}.${type} or ${artifactId}-${version}-${classifier}.${type} for artifacts with a classifier). You cannot change the format used by the repository.
I add the above note because the first thing everyone seems to want to do upon learning about the finalName parameter is try and change the name in the repository.
use version tag of the maven
<version>0.0.1-SNAPSHOT</version>
do not let intellij to create jar files without version tag.

Load a properties inside a jar

Can I load a properties file inside a jar in a maven plugin execution?
I have a jar with a system-properties (among other things). I can download and expand it, but I wonder if I there is a way to configure a maven plugin (maven jetty plugin) to load these properties. I was thinking in the:
<configuration>
<systemPropertiesFile></systemPropertiesFile>
</configuration>
You'll probably have to use dependency:unpack first to write the properties to a temporary file, and then the properties-maven-plugin to read the properties from that file.

how to let maven war plugin to create multiple war file

i used selenium-mave-plugin for integration test, which require the war file named: project.artifactId-version(say: myproj-0.1-SNAPSHOT.war) while the default war created by maven-war-plugin is project.artifactId.war(say myproj-SNAPSHOT.war).
in order to let selenium plugin, i override the maven-war-plugin in that selenium profile as:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<warName>${project.artifactId}-${project.version}</warName>
</configuration>
</plugin>
now when i build the project, it failed at rpm:rpm, complaining:
source location ..../myProj.war does not exist
my question is if it's possible to create 2 war files: myProj.war and myProj-0.1-SNAPSHOT.war so both rpm and selenium plugins are happy? Thanks
For rpm plugin, please make sure you use the location directive. If you need further help, please post your full pom.xml.
As for selenium, it doesn't really need to know where your .war file resides. Only the web application server needs to know. Sadly, you didn't provide information in which phase of maven the "does not exist" error occured. So I can only guess it's while starting jetty, tomcat or another web application server.
You should run your full build (including tests) with: mvn clean verify integration-test rpm:prm.

Resources