[BAEL-2899] removed exception and added dependencies needed for correct compilation
This commit is contained in:
parent
6dcb51d24c
commit
9e0e8a6b0b
|
@ -14,6 +14,16 @@
|
|||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
|
@ -127,7 +137,7 @@
|
|||
<!-- MainClass in mainfest make a executable jar -->
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.baeldung.App</mainClass>
|
||||
<mainClass>com.baeldung.MyJointCompilationApp</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
|
||||
|
@ -154,10 +164,14 @@
|
|||
</repositories>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<junit.platform.version>1.0.0</junit.platform.version>
|
||||
<groovy.version>2.5.7</groovy.version>
|
||||
<hsqldb.version>2.4.0</hsqldb.version>
|
||||
<spock-core.version>1.1-groovy-2.4</spock-core.version>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
<java.version>1.8</java.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
<groovy.version>2.5.7</groovy.version>
|
||||
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-groovy-2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
@ -14,6 +14,16 @@
|
|||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
|
@ -44,6 +54,12 @@
|
|||
<scriptSourceDirectory>src/main/groovy</scriptSourceDirectory>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-eclipse-compiler</artifactId>
|
||||
<version>3.3.0-01</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
|
@ -94,11 +110,11 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20.1</version>
|
||||
<configuration>
|
||||
<useFile>false</useFile>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
<include>**/*Spec.java</include>
|
||||
</includes>
|
||||
<useFile>false</useFile>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
<include>**/*Spec.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Maven Assembly Plugin: needed to run the jar through command line -->
|
||||
|
@ -114,7 +130,7 @@
|
|||
<!-- MainClass in mainfest make a executable jar -->
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.baeldung.App</mainClass>
|
||||
<mainClass>com.baeldung.MyJointCompilationApp</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
|
||||
|
@ -140,12 +156,32 @@
|
|||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>bintray</id>
|
||||
<name>Groovy Bintray</name>
|
||||
<url>https://dl.bintray.com/groovy/maven</url>
|
||||
<releases>
|
||||
<!-- avoid automatic updates -->
|
||||
<updatePolicy>never</updatePolicy>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
|
||||
<properties>
|
||||
<junit.platform.version>1.0.0</junit.platform.version>
|
||||
<groovy.version>2.5.7</groovy.version>
|
||||
<hsqldb.version>2.4.0</hsqldb.version>
|
||||
<spock-core.version>1.1-groovy-2.4</spock-core.version>
|
||||
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
<groovy.version>2.5.7</groovy.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
|
|
|
@ -7,31 +7,36 @@ import groovy.util.ScriptException;
|
|||
import org.codehaus.groovy.jsr223.GroovyScriptEngineFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(App.class);
|
||||
public class MyJointCompilationApp {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(MyJointCompilationApp.class);
|
||||
private final GroovyClassLoader loader;
|
||||
private final GroovyShell shell;
|
||||
private final GroovyScriptEngine engine;
|
||||
private final ScriptEngine engineFromFactory;
|
||||
|
||||
private App() throws IOException {
|
||||
public MyJointCompilationApp() {
|
||||
loader = new GroovyClassLoader(this.getClass().getClassLoader());
|
||||
shell = new GroovyShell(loader, new Binding());
|
||||
engine = new GroovyScriptEngine(new URL[] {
|
||||
new File("src/main/groovy/com/baeldung/").toURI().toURL()
|
||||
}, this.getClass().getClassLoader());
|
||||
|
||||
URL url = null;
|
||||
try {
|
||||
url = new File("src/main/groovy/com/baeldung/").toURI().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
LOG.error("Exception while creating url", e);
|
||||
}
|
||||
engine = new GroovyScriptEngine(new URL[] {url}, this.getClass().getClassLoader());
|
||||
engineFromFactory = new GroovyScriptEngineFactory().getScriptEngine();
|
||||
}
|
||||
|
||||
|
@ -99,8 +104,8 @@ public class App {
|
|||
|
||||
public static void main(String[] args) throws InstantiationException, IllegalAccessException,
|
||||
ResourceException, ScriptException, IOException, javax.script.ScriptException {
|
||||
App app = new App();
|
||||
app.runStaticCompiledClasses();
|
||||
app.runDynamicCompiledClasses();
|
||||
MyJointCompilationApp myJointCompilationApp = new MyJointCompilationApp();
|
||||
myJointCompilationApp.runStaticCompiledClasses();
|
||||
myJointCompilationApp.runDynamicCompiledClasses();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue