1

I hava some Java code, this is going to be used in Bean Shell.

The Java code I have already exported from IDEA and generated to a jar file, so it does not hava maven groupId.

How can I add this jar file to the jmeter/lib directory?

Here is the jmeter-maven-plugin wiki

Thanks.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Mr.LiuDC
  • 109
  • 1
  • 3
  • 13

2 Answers2

1

This is you who defines groupId/artifactId for your jar file, once you have the .jar you can install it into your local Maven repository using Maven Install Plugin like

mvn install:install-file -Dfile=/path/to/your.jar -DgroupId=com.example -DartifactId=my-cool-jar -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true

Once done you should be normally able to add the .jar to JMeter Classpath like:

<testPlanLibraries>
     <artifact>com.example:my-cool-jar:1.0</artifact>
</testPlanLibraries>

And last but not the least, since JMeter 3.1 you should not be using Beanshell, consider switching to JSR223 Test Elements and Groovy language

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I knew that way,but as I said the jar artifact is not a maven project,there is no groupId. I hava tried the `maven-resources-plugin`, it‘s working. Thanks anyway. – Mr.LiuDC Jun 27 '20 at 11:45
0

You can add jar to Test Plan:

Click Browse and add your file, then you can call your java code from Beanshell or JSR223 script

Notice that if your jar has dependencies, you will have to add them too.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233