Is it possible to install somewhere jar-files to use them in Scriptrunner?
My example: I want to use HTMLUnit in my groovy script so that it'll be possible to write smth like
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.*;
Or get classes with Grab.
Where should I upload files from that library? Or that's not correct?
Thanks for your attention.
Probably a bit late now but I'll add this here for anyone else that's looking!
This should run straight out of the Groovy console in Jira/Confluence etc
//
// How to load and use an external library/dependency in ScriptRunner
//
// Faker : https://github.com/DiUS/java-faker
// Its library : http://dius.github.io/java-faker/apidocs/index.html
// Declarations: https://mvnrepository.com/artifact/com.github.javafaker/javafaker/1.0.2
//
// Other : http://docs.groovy-lang.org/latest/html/documentation/grape.html
//
// https://mvnrepository.com/artifact/com.github.javafaker/javafaker
@Grapes(
@Grab(group='com.github.javafaker', module='javafaker', version='1.0.2')
)
import com.github.javafaker.Faker
Faker fkr = new Faker(new Locale("en.AU"))
return "<p>" + fkr.chuckNorris.fact() + "</p>" +
"<p>Lorem: " + fkr.lorem().paragraph() + "</p>" +
"<p>HitchHikers: " + fkr.hitchhikersGuideToTheGalaxy().marvinQuote() + "</p>" +
"<p>Back to the Future: " + fkr.backToTheFuture().quote() + "</p>"
Hi @Tatyana Lukyanchikova , yeah I'm using @Grab. If the dependency is not downloaded automatically, you need to install it under maven dependencies on your Server. Usually (~/.m2) folder.
You can use mvn install:install-file command (https://intellipaat.com/community/6786/how-to-add-local-jar-files-to-a-maven-project).
I'm using following code and it works smoothly:)
@Grab('com.xlson.groovycsv:groovycsv:1.3')
import static com.xlson.groovycsv.CsvParser.parseCsv
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.