{"id":65,"date":"2013-06-15T01:09:20","date_gmt":"2013-06-15T01:09:20","guid":{"rendered":"https:\/\/code4reference.com\/?p=65"},"modified":"2023-10-01T13:35:06","modified_gmt":"2023-10-01T13:35:06","slug":"code4referencegradle-build-file-for-jmeter-plugin-development-code4reference","status":"publish","type":"post","link":"https:\/\/code4reference.com\/?p=65","title":{"rendered":"Gradle build file for JMeter plugin development"},"content":{"rendered":"<p>Recently I was working on JMeter test-plan. I had to write some custom functions which are not provided by JMeter. I somehow figured out implementation of custom-functions but soon faced the build problem. It took a little while to define the build.gradle to compile and generate jar file. Later I thought to share it here. If you are looking for JMeter plugin tutorial then you have to wait for a little while. If you are just looking for build.gradle for building your source code then please carry on.<br \/>\nLet\u2019s start, first you need to have directory structure similar to, as shown below.<\/p>\n<pre>JMeter\n\u251c\u2500\u2500 build.gradle\n\u2514\u2500\u2500 src\n    \u2514\u2500\u2500 java\n        \u2514\u2500\u2500 com\n            \u2514\u2500\u2500 code4reference\n                \u2514\u2500\u2500 jmeter\n                    \u2514\u2500\u2500 functions\n                        \u2514\u2500\u2500 YourFunctionDefinition.java            \n<\/pre>\n<p>In this build.gradle file you need to take care of three things, First <code>dependencies<\/code> closure should be defined with <code>compile 'org.apache.jmeter:ApacheJMeter_core:2.9'<\/code> attribute, Second <code>srcDir<\/code> should point to the correct directory. In given gradle file, it is pointing to <code>src\/java<\/code> since source code are present under this directory. Third <code>Jar<\/code> task should be defined. This task will create the jar file which you can place in <code>\/lib\/ext<\/code> directory.<\/p>\n<pre>\napply plugin: 'java'\n\njar.baseName = 'C4RJMeter'  \/\/custom jar file name.\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    \/\/This JMeter plugin source code build depends on JMeter2.9 version.\n    compile 'org.apache.jmeter:ApacheJMeter_core:2.9'\n    compile 'org.apache.jmeter:ApacheJMeter_components:2.9'\n}\n\nsourceSets {\n   main {\n      java {\n         srcDir 'src\/java'  \/\/JMeter plugin source directory.\n      }\n   }\n}\n\njar {\n   manifest {\n      attributes 'Implementation-Title': 'Code4Reference',\n         'Built-By': System.getProperty('user.name'),\n         'Built-Date': new Date(),\n         'Built-JDK': System.getProperty('java.version')\n   }\n}\n<\/pre>\n<p>Once your source code and build.gradle are ready, you can run <code>gradle jar<\/code>. This command builds the jar file and keeps in the <code>libs<\/code> directory.<\/p>\n<pre>\nJMeter\n\u2514\u2500\u2500 build\n    \u2514\u2500\u2500 libs\n        \u2514\u2500\u2500 C4RJMeter.jar\n<\/pre>\n<p>Feel free to comment on the post or website. If you liked the post then please share it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was working on JMeter test-plan. I had to write some custom functions which are not provided by JMeter. I somehow figured out implementation of custom-functions but soon faced the build problem. It took a little while to define the build.gradle to compile and generate jar file. Later I thought to share it here. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65"}],"version-history":[{"count":1,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":356,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions\/356"}],"wp:attachment":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}