Gradle + Embedded Jetty - spring

I have modified an existing Jetty project and after I builded, I got 404. Maybe I need to modify other files which I do not know.
I am using gradle to build. Here is the build.gradle :
apply plugin: 'java'
apply plugin: 'jetty'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-webmvc:4.1.6.RELEASE'
compile 'org.hibernate:hibernate-core:4.3.6.Final'
testImplementation 'junit:junit:4.12'
testCompile 'junit:junit:4.11'
testCompile 'org.hamcrest:hamcrest-all:1.3'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.14'
}
test {
exclude '**/*IntegrationTest*'
}
task integrationTest(type: Test) {
include '**/*IntegrationTest*'
doFirst {
jettyRun.contextPath = '/';
jettyRun.httpPort = 8080 // Port for test
jettyRun.daemon = true
jettyRun.execute()
}
doLast {
jettyStop.stopPort = 8091 // Port for stop signal
jettyStop.stopKey = 'stopKey'
jettyStop.execute()
}
}
// Embeded Jetty for testing
jettyRun{
contextPath = "spring4"
httpPort = 8080
}
jettyRunWar{
contextPath = "spring4"
httpPort = 8080
}
//For Eclipse IDE only
eclipse {
wtp {
component {
//define context path, default to project folder name
contextPath = 'spring4'
}
}
}
Here the other class:
package com.hello.webapp;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import com.hello.service.SignUpService;
#Path("/signUp")
public class SignUpWebapp {
private static SignUpService signUpService = new SignUpService();
#GET()
public String hello() {
return signUpService.sayHello();
}
}
here the simple service:
package com.hello.service;
public class SignUpService {
public String sayHello() {
return "signUp";
}
}
this is another the integration test class
package com.hello.webapp;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import org.junit.Test;
public class SignUpIntegrationTest {
private static String SIGNUP = "http://localhost:8080/signUp";
#Test
public void testHello() throws Exception {
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(SIGNUP);
String response = webTarget.request().get(String.class);
assertThat(response, is("signUp"));
}
}
So, when I run gradle integrationTest I get an error saying that Jetty is already running. And when I try to visit localhost/signUp I get a 404.

One solution is to use gretty instead:
apply plugin: 'org.akhikhl.gretty'
....
classpath 'org.akhikhl.gretty:gretty:1.4.0'
...
gretty {
port = 8083
contextPath = '/'
servletContainer = 'jetty9'
jvmArgs = [
'-Xms700m',
'-Xmx2048m'
]
loggingLevel='INFO'
debugPort = 5005 // default
debugSuspend = true // default
httpsEnabled = true
httpsPort = 8443
sslKeyStorePath = 'some.jks'
sslKeyStorePassword = 'somepwd'
}
and then gradle appStart
Let me know if that helps.

Related

How to merge Manifest sections with Gradle and shadowJar

What I need
We package our products with Gradle and shadowJar. Some of the libraries we use, utilize individual sections in Jar Manifests, specifically attributes like Implementation-Title and
Implementation-Version. These sometimes show in (the outputs of) our products, so I'd like them to survive the shawdowJar-Process.
Example
lib1.jar/META-INF/MANIFEST.MF
Manifest-Version: 1.0
...
Name: org/some/lib
...
Implementation-Title: someLib
Implementation-Version: 2.3
...
lib2.jar/META-INF/MANIFEST.MF
Manifest-Version: 1.0
...
Name: org/some/other/lib
...
Implementation-Title: someOtherLib
Implementation-Version: 5.7-RC
...
=>
product.jar/META-INF/MANIFEST.MF
Manifest-Version: 1.0
...
Name: org/some/lib
...
Implementation-Title: someLib
Implementation-Version: 2.3
...
Name: org/some/other/lib
...
Implementation-Title: someOtherLib
Implementation-Version: 5.7-RC
...
What I found out
It is rather easy to manipulate the resulting Manifest with shadowJar:
project.shadowJar {
manifest {
attributes(["Implementation-Title" : "someLib"], "org/some/lib")
attributes(["Implementation-Title" : "someOtherLib"], "org/some/other/lib")
}
}
generates exactly what I want, statically.
shadowJar can provide me with a list of dependencies. However, when I iterate over the FileCollection like this
project.shadowJar {
manifest {
for (dependency in includedDependencies) {
// read in jar file and set attributes
}
}
}
Gradle is not happy: "Cannot change dependencies of dependency configuration ':project:products:<ProductName>:compile' after it has been included in dependency resolution."
When I define a new task
def dependencies = [];
project.tasks.register('resolveDependencies') {
doFirst {
gradleProject.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
dependencies.add(it.file)
}
}
}
project.tasks['shadowJar'].dependsOn(project.tasks['resolveDependencies']);
project.shadowJar {
manifest {
// dependencies will be empty when this code is called
for (dependency in dependencies) {
// read in jar file and set attributes
}
}
}
The dependencies are not resolved in time.
What I'd like to know
How can I access the dependencies without upsetting Gradle? Alternatively, is there another way to merge the named individual sections with shadowJar?
According to https://github.com/johnrengelman/shadow/issues/369 the Transformer interface of shadowJar should be used to do this.
So here comes:
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer;
import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext;
import java.io.ByteArrayOutputStream;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.Map.Entry;
import shadow.org.apache.tools.zip.ZipOutputStream;
import shadow.org.apache.tools.zip.ZipEntry;
import shadow.org.codehaus.plexus.util.IOUtil;
import org.gradle.api.file.FileTreeElement;
import static java.nio.charset.StandardCharsets.*
import static java.util.jar.JarFile.*;
/**ManifestVersionMergeTransformer appends all version information sections from manifest files to the resulting manifest file.
* #author Robert Lichtenberger
*/
public class ManifestMergeTransformer implements Transformer {
String includePackages; // regular expression that must match a given package
String excludePackages; // regular expression that must not match a given package
private Manifest manifest;
#Override
public boolean canTransformResource(FileTreeElement element) {
MANIFEST_NAME.equalsIgnoreCase(element.relativePath.pathString);
}
#Override
public void transform(TransformerContext context) {
if (manifest == null) {
manifest = new Manifest(context.is);
} else {
Manifest toMerge = new Manifest(context.is);
for (Entry<String, Attributes> entry : toMerge.getEntries().entrySet()) {
if (mustInclude(entry.getKey())) {
manifest.getEntries().put(entry.getKey(), entry.getValue());
}
}
}
IOUtil.close(context.is);
}
private boolean mustInclude(String packageName) {
return (includePackages == null || packageName.matches(includePackages)) && (excludePackages == null || !packageName.matches(excludePackages));
}
#Override
public boolean hasTransformedResource() {
return true;
}
#Override
public void modifyOutputStream(ZipOutputStream os, boolean preserveFileTimestamps) {
ZipEntry entry = new ZipEntry(MANIFEST_NAME);
entry.time = TransformerContext.getEntryTimestamp(preserveFileTimestamps, entry.time);
os.putNextEntry(entry);
if (manifest != null) {
ByteArrayOutputStream manifestContents = new ByteArrayOutputStream();
manifest.write(manifestContents);
os.write(manifestContents.toByteArray());
}
}
}

IntelliJ Could not set unknown property 'mainClassName' for root project 'Blue Bot' of type org.gradle.api.Project

I am following a tutorial to make a basic Discord Bot, (https://medium.com/discord-bots/making-a-basic-discord-bot-with-java-834949008c2b) and i got the error, Could not set unknown property 'mainClassName' for root project 'Blue Bot' of type org.gradle.api.Project and I don't know how to fix it. Here is my build.grade code
plugins {
id 'java'
}
mainClassName = "Main"
group 'BlueBot'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'net.dv8tion:JDA:4.0.0_62'
}
and here is my Main.java code
import net.dv8tion.jda.api.AccountType;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import javax.security.auth.login.LoginException;
public class Main extends ListenerAdapter {
public static void main(String[] args) throws LoginException {
JDABuilder builder = new JDABuilder(AccountType.BOT);
String token = "enter token here";
builder.setToken(token);
builder.addEventListeners(new Main());
builder.build();
}
#Override
public void onMessageReceived(MessageReceivedEvent event) {
System.out.println("We received a message from " +
event.getAuthor().getName() + ": " +
event.getMessage().getContentDisplay()
);
if (event.getMessage().getContentRaw().equals("I am lonely")) {
event.getChannel().sendMessage("Who isn't?").queue();
}
}
}
Let me know if you need more info.
You need to apply the application plugin:
plugins {
id 'application'
}

`runBlocking` coroutine builder is not resolved in the project (Other builders are resolved)

As the title suggest, the coroutine builder runBlocking is missing in the coroutine liblary I just added in my build.gradle. Funny thing is every other thing appears to be available, GlobalScope, CoroutineScope.launch CoroutineScope.async all present. runBlocking isn't. What am I doing wrong?
here is my build.gradle
buildscript {
ext {
ktor_version = "1.1.1"
kotlin_version = "1.3.20-eap-52"
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.44"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
plugins {
id 'kotlin-multiplatform' version '1.3.20-eap-100'
}
repositories {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-js-wrappers' }
maven { url 'https://dl.bintray.com/kotlinx/kotlinx' }
maven { url "https://kotlin.bintray.com/kotlinx" }
jcenter()
mavenCentral()
}
group 'books'
version '0.0.0'
apply plugin: 'maven-publish'
apply plugin: "org.jetbrains.kotlin.frontend"
kotlin {
jvm() {
compilations.all {
tasks[compileKotlinTaskName].kotlinOptions {
jvmTarget = "1.8"
}
}
}
js() {
compilations.all {
tasks[compileKotlinTaskName].kotlinOptions {
def optDir = compileKotlinTaskName.contains("Test") ? "test/${project.name}.test.js" : "main/${project.name}.js"
kotlinOptions.metaInfo = true
kotlinOptions.outputFile = "$project.buildDir.path/js/$optDir"
kotlinOptions.sourceMap = true
kotlinOptions.moduleKind = 'commonjs'
kotlinOptions.main = "call"
}
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$ktor_version"
}
}
commonTest {
dependsOn commonMain
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmMain {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$ktor_version"
implementation kotlin('stdlib-jdk8')
}
}
jvmTest {
dependsOn jvmMain
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
jsMain {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$ktor_version"
implementation kotlin('stdlib-js')
}
}
jsTest {
dependsOn jsMain
dependencies {
implementation kotlin('test-js')
}
}
}
}
task runJest(type: Exec) {
group = "verification"
commandLine "sh", "runJest.sh"
}
runJest.dependsOn(jsTest)
task testAll() {
group = "verification"
dependsOn(jvmTest, runJest)
}
kotlinFrontend {
npm {
devDependency("karma")
}
sourceMaps = true
webpackBundle {
bundleName = "main"
host = "0.0.0.0"
contentPath = file("$buildDir.path/resources/main")
}
}
With that gradle configuration, I have been able to write tests well (Learning TDD) with kotlin-multiplatform. And here is my sample below
import kotlin.test.*
import com.luge.books.*
import kotlinx.coroutines.*
class BookTest {
#BeforeTest
fun setup() {
val book = Book()
}
#Test
fun testingInstantiation() {
val book = Book()
assertEquals(book.year, 1990, "Books do match the year")
}
#Test
fun willFail() {
assertFalse(false)
}
#Test
fun testingCoroutines() {
val job = GlobalScope.launch {
delay(5000)
println("Doing stuff")
assertTrue(false)
}
}
}
If you look closely, the test testingCoroutines passes, but since I am launching from the GlobalScope, it just fires and forgets and the test returns without throwing any error. If I incoporate runBlocking, the IDE highlights it with red color (you know, as something it doesn't understant), end even the kotlin compiler shouts, unresolved reference runBlockin. Help please....
After struggling here and there, I finally knew that runBlocking is only available in kotlin/jvm. So, it is not in kotlin/js or kotlin/common.
Just for future references, if you want to run multiplatform tests, then use this work around

Spring 4 + Embedded Tomcat 7

I try to build a web app using Spring Web MVC 4.3.2 and embedded Tomcat 7.0.64.
I did not manage to write the correct main method to start embedded Tomcat. It works for Spring Controller sending #ResponseBody content (JSON) but failed for JSP views.
public static void main(String[] args) throws Exception {
String appBase = ".";// What to put here ?
Tomcat tomcat = new Tomcat();
String contextPath = "";
String port = System.getProperty("server.port");
tomcat.setPort(port == null ? 8080 : Integer.valueOf(port));
tomcat.getHost().setAppBase(appBase);
Context context = tomcat.addWebapp(contextPath, appBase);
// So that it works when in it's launched from IntelliJ or Eclipse
// Also need that a folder named "META-INF" exists in build/classes/main
// https://bz.apache.org/bugzilla/show_bug.cgi?id=52853#c19
((StandardJarScanner) context.getJarScanner()).setScanAllDirectories(true);
tomcat.start();
tomcat.getServer().await();
}
For JSP view it says : The requested resource is not available (WEB-INF/views/home.jsp) HTTP 404
If I set the appBase variable to the absolute path where the JSPs are, it works. But, of course, it is not a solution as it would not work on another machine. I need a relative path.
If I set appBase varibale to "src/main/webapp", then Tomcat fails to start with the following error : java.lang.IllegalArgumentException: Document base C:\blabla\spring-jsp-embedded-tomcat\tomcat.8080\src\main\webapp\src\main\webapp does not exist or is not a readable directory.
Morevover, the jar that is built with Gradle fat jar technique does not contain the WEB-INF dir.
How can I do to make a simple Spring MVC app working with an embedded Tomcat and JSPs (to be launched with java -cp path/to/my/jar com.app.Launcher) ?
build.gradle :
apply plugin: 'java'
sourceCompatibility = 1.7
version = '1.0'
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
repositories {
maven { url "http://repo1.maven.org/maven2" }
}
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.6.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.6.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.6.2'
compile 'org.springframework:spring-webmvc:4.3.2.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0'
compile 'javax.servlet:javax.servlet-api:3.0.1'
compile 'javax.servlet.jsp:jsp-api:2.2'
compile 'javax.servlet:jstl:1.2'
// Embedded Tomcat
// 2 mandatory libs
compile 'org.apache.tomcat.embed:tomcat-embed-core:7.0.64'
compile 'org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.64'
// To enable JSPs
compile 'org.apache.tomcat.embed:tomcat-embed-jasper:7.0.64'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Tomcat launcher :
public class Launcher {
public static void main(String[] args) throws Exception {
String contextPath = "";
// String appBase = "C:/absolute/path/to/webapp/dir"; // It works but of course I need a relative path
// String appBase = "."; // Works only for Controller sending back ResponseBody (JSON) but fail to find jsp files
String appBase = "src/main/webapp"; // Tomcat does not start properly
Tomcat tomcat = new Tomcat();
String port = System.getProperty("server.port");
tomcat.setPort(port == null ? 8080 : Integer.valueOf(port));
tomcat.getHost().setAppBase(appBase);
Context context = tomcat.addWebapp(contextPath, appBase);
// So that it works when in it's launched from IntelliJ or Eclipse
// Also need that a folder named "META-INF" exists in build/classes/main
// https://bz.apache.org/bugzilla/show_bug.cgi?id=52853#c19
((StandardJarScanner) context.getJarScanner()).setScanAllDirectories(true);
tomcat.start();
tomcat.getServer().await();
}
}
Spring web app initializer :
public class MyWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
#Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[] { RootConfig.class };
}
#Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[] { WebConfig.class };
}
}
WebConfig :
#Configuration
#EnableWebMvc
#ComponentScan("com.app")
public class WebConfig extends WebMvcConfigurerAdapter {
#Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");
resolver.setExposeContextBeansAsAttributes(true);
return resolver;
}
#Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
Folder structure :
Apparently, embedded Tomcat expects static resources to be in a META-INF/resources directory. I followed this : tutorial and I checked how the final jar was structured.
So I modified the Gradle build script to put the JSPs there.
sourceSets {
main {
resources.srcDirs = ["src/main/webapp"]
output.resourcesDir = "$buildDir/classes/main/META-INF/resources"
}
}
And now it works. However, I have the feeling that it's a makeshift job. If someone has a more satisfying and educational answer, I would be pleased to get it.

gradle task and imports on groovy file

I have the following buil.gradle
apply plugin: "groovy"
repositories {
mavenCentral()
jcenter()
}
dependencies {
groovy group: "org.codehaus.groovy", name:"groovy-all", version: "1.8.6"
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.53.0'
compile "org.testng:testng:6.3.1"
compile group: 'com.jcraft', name: 'jsch', version: '0.1.53'
compile group: 'net.schmizz', name: 'sshj', version: '0.3.1'
compile group: 'commons-lang', name: 'commons-lang', version: '2.3'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.21'
compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
compile group: 'net.sf.expectit', name: 'expectit-core', version: '0.8.1'
compile group: 'net.sf.expectit', name: 'expectit-ant', version: '0.8.1'
compile group: 'net.sf.expectit', name: 'expectit-parent', version: '0.8.1', ext: 'pom'
compile "log4j:log4j:1.2.17"
testCompile "org.spockframework:spock-core:0.7-groovy-1.8"
testCompile "junit:junit:4.10"
testCompile "cglib:cglib-nodep:2.2.2"
testCompile "org.objenesis:objenesis:1.2"
testRuntime "org.slf4j:slf4j-api:1.7.10"
}
sourceSets {
test { groovy {
srcDir 'foo/bar/'
} }
}
buildscript {
repositories {
mavenCentral()
jcenter()
}
}
task runA << {
new GroovyShell().run(file('foo/bar/ATest.groovy'));
}
If I run gradle clean -Dtest.single=A test it works and test runs with success but if I run gradle -q runA it shows unrecognized imports like:
foo/bar/ATest.groovy: 16: unable to resolve class net.schmizz.sshj.SSHClient
# line 16, column 1.
import net.schmizz.sshj.SSHClient;
^
foo/bar/ATest.groovy: 28: unable to resolve class org.openqa.selenium.firefox.FirefoxDriver
# line 28, column 1.
import org.openqa.selenium.firefox.FirefoxDriver;
^
Here is my ATest.groovy
package foo.bar;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets;
import java.nio.file.Files
import java.nio.file.Paths;
import java.security.PublicKey
import org.apache.log4j.Logger;
import org.junit.Before
import org.junit.After
import org.junit.Test;
import org.junit.*;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Shell;
import net.schmizz.sshj.transport.verification.HostKeyVerifier;
import net.sf.expectit.Expect;
import net.sf.expectit.ExpectBuilder;
import static net.sf.expectit.filter.Filters.removeColors;
import static net.sf.expectit.filter.Filters.removeNonPrintable;
import static net.sf.expectit.matcher.Matchers.contains;
import static net.sf.expectit.matcher.Matchers.regexp;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select
import java.util.regex.Pattern
import javax.naming.directory.InvalidAttributesException;
import java.util.concurrent.TimeUnit
import org.apache.log4j.Logger;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
public class ATest{
private WebDriver driver;
private static final Logger logger = Logger.getLogger(ATest.class);
Properties props = new Properties();
private StringBuffer verificationErrors = new StringBuffer();
private Expect expect = null;
Session session = null;
SSHClient ssh = null;
#Before
public void setUp() throws Exception {
logger.info("========================================================================");
logger.info("Starting...");
// setting up Webdriver instance
try {
driver = new FirefoxDriver();
}
catch (Exception e) {
logger.info("Could not open Firefox instance: " + e.getMessage());
fail("Could not open Firefox instance: " + e.getMessage());
}
// setting up SSH connection
try {
ssh = new SSHClient();
ssh.addHostKeyVerifier(
new HostKeyVerifier() {
#Override
public boolean verify(String s, int i, PublicKey publicKey) {
return true;
}
});
ssh.connect(props.getProperty("host"), Integer.parseInt(props.getProperty("port")));
ssh.authPassword(props.getProperty("user"), props.getProperty("password"));
session = ssh.startSession();
session.allocateDefaultPTY();
} catch (Exception e) {
fail("Could not open SSH connection with " + props.getProperty("host") + "\nError: " + e.getMessage());
}
// start a interactive remote shell
Shell shell = session.startShell();
expect = new ExpectBuilder().withOutput(shell.getOutputStream())
.withInputs(shell.getInputStream(), shell.getErrorStream())
//.withEchoInput(System.out)
.withInputFilters(removeColors(), removeNonPrintable())
.withExceptionOnFailure()
.build();
try {
Thread.sleep(3000);
// log as 'su' user in the remote shell
expect.sendLine(props.getProperty("suuser"));
expect.expect(contains("Password: "));
expect.sendLine(props.getProperty("supassword"));
expect.expect(regexp("root#"));
}
catch (Exception e) {
fail("Error: " + e.getMessage());
}
}
#Test
public void run() {
...
}
#After
public void tearDown() throws Exception {
if (driver != null) {
driver.quit();
}
}
}
Am I missing some config?
This is expected behavior. When you run a test with gradle, it's gradle job to configure the classpath, classloader - namely, the whole environment.
If you run the the file, script on your it's your job to provide the configuration.
Have a look at GroovyShells, constructor summary. It takes a ClassLoader object and a CompileConfiguration. It's your job to provide these objects.

Resources