Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
machaval committed Apr 3, 2021
1 parent 48bfaef commit 3fb0072
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ subprojects {
group 'org.mule.weave.native'
version nativeVersion

compileScala {
targetCompatibility = "11"
sourceCompatibility = "11"
}


compileJava {
sourceCompatibility = '11'
targetCompatibility = '11'
}
// compileScala {
// targetCompatibility = "11"
// sourceCompatibility = "11"
// }
//
//
// compileJava {
// sourceCompatibility = '11'
// targetCompatibility = '11'
// }


publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import sun.misc.SignalHandler

import java.io.File
import java.io.FileOutputStream
import java.io.OutputStream
import java.io.PrintWriter
import java.io.StringWriter
import java.nio.file.Files
Expand Down Expand Up @@ -362,12 +363,12 @@ class DataWeaveCLIRunner {
| --verbose or -v | Enable Verbose Mode.
| --output or -o | Specifies output file for the transformation if not standard output will be used.
| --main or -m | The full qualified name of the mapping to be execute.
| --file or -f | Path to the file
| --file or -f | Path to the file
| --eval | Evaluates the script instead of writing it
| --version | The version of the CLI and Runtime
| --clean-cache | Cleans the cache where all artifacts are being downloaded this force to download all artifacts every time
| --remote-debug | Enables remote debugging
| --telemetry | Enables telemetry reporting
| --telemetry | Enables telemetry reporting
|
| Example:
|
Expand Down Expand Up @@ -477,9 +478,9 @@ class DataWeaveCLIRunner {
}
}
} else {
val out = if (config.outputPath.isDefined) new FileOutputStream(config.outputPath.get) else System.out
val out: OutputStream = if (config.outputPath.isDefined) new FileOutputStream(config.outputPath.get) else System.out
val defaultOutputType = Option(System.getenv(DW_DEFAULT_OUTPUT_MIMETYPE_VAR)).getOrElse("application/json")
val result: WeaveExecutionResult = nativeRuntime.run(module.content, module.nameIdentifier, scriptingBindings, out, defaultOutputType, config.profile, config.remoteDebug, config.telemetry)
val result: WeaveExecutionResult = nativeRuntime.run(module.content, module.nameIdentifier, scriptingBindings, Some(out), defaultOutputType, config.profile, config.remoteDebug, config.telemetry)
//load inputs from
if (result.success()) {
exitCode = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.mule.weave.v2.exception.InvalidLocationException
import org.mule.weave.v2.interpreted.CustomRuntimeModuleNodeCompiler
import org.mule.weave.v2.interpreted.RuntimeModuleNodeCompiler
import org.mule.weave.v2.interpreted.module.WeaveDataFormat
import org.mule.weave.v2.io.service.DefaultFileService
import org.mule.weave.v2.model.EvaluationContext
import org.mule.weave.v2.model.ServiceManager
import org.mule.weave.v2.model.service.ProtocolUrlSourceProviderResolverService
Expand All @@ -19,7 +18,6 @@ import org.mule.weave.v2.model.service.UrlProtocolHandler
import org.mule.weave.v2.model.service.UrlSourceProviderResolverService
import org.mule.weave.v2.model.values.BinaryValue
import org.mule.weave.v2.module.reader.AutoPersistedOutputStream
import org.mule.weave.v2.module.reader.DefaultAutoPersistedOutputStream
import org.mule.weave.v2.module.reader.SourceProvider
import org.mule.weave.v2.parser.ast.variables.NameIdentifier
import org.mule.weave.v2.parser.exception.LocatableException
Expand Down Expand Up @@ -109,28 +107,28 @@ class NativeRuntime(resourcesCacheDir: File, libDir: File, path: Array[File], ex
}

def run(script: String, nameIdentifier: String, inputs: ScriptingBindings): WeaveExecutionResult = {
run(script,nameIdentifier, inputs, new DefaultAutoPersistedOutputStream(DefaultFileService))
run(script, nameIdentifier, inputs, None)
}


def run(script: String, nameIdentifier: String, inputs: ScriptingBindings, out: OutputStream, defaultOutputMimeType: String = "application/json", profile: Boolean = false, remoteDebug: Boolean = false, telemetry: Boolean = false): WeaveExecutionResult = {
def run(script: String, nameIdentifier: String, inputs: ScriptingBindings, out: Option[OutputStream], defaultOutputMimeType: String = "application/json", profile: Boolean = false, remoteDebug: Boolean = false, telemetry: Boolean = false): WeaveExecutionResult = {
try {
val dataWeaveScript: DataWeaveScript = compileScript(script, inputs, NameIdentifier(nameIdentifier), defaultOutputMimeType, profile)
if(remoteDebug) {
if (remoteDebug) {
dataWeaveScript.enableDebug()
}
if(telemetry){
if (telemetry) {
dataWeaveScript.enableTelemetry()
dataWeaveScript.enableMemoryTelemetry()
}
val serviceManager: ServiceManager = createServiceManager()
val result: DataWeaveResult =
if (profile) {
time(() => dataWeaveScript.write(inputs, serviceManager, Some(out)), "Execution")
time(() => dataWeaveScript.write(inputs, serviceManager, out), "Execution")
} else {
dataWeaveScript.write(inputs, serviceManager, Some(out))
dataWeaveScript.write(inputs, serviceManager, out)
}
WeaveSuccessResult(out, result.getCharset().name())
WeaveSuccessResult(out.get, result.getCharset().name())
} catch {
case cr: CompilationException => {
WeaveFailureResult(cr.getMessage())
Expand Down Expand Up @@ -176,10 +174,10 @@ class NativeRuntime(resourcesCacheDir: File, libDir: File, path: Array[File], ex
def eval(script: String, inputs: ScriptingBindings, nameIdentifier: String, profile: Boolean, debug: Boolean = false, telemetry: Boolean = false): ExecuteResult = {
try {
val dataWeaveScript: DataWeaveScript = compileScript(script, inputs, NameIdentifier(nameIdentifier), "application/dw", profile)
if(debug) {
if (debug) {
dataWeaveScript.enableDebug()
}
if(telemetry){
if (telemetry) {
dataWeaveScript.enableTelemetry()
dataWeaveScript.enableMemoryTelemetry()
}
Expand Down Expand Up @@ -268,7 +266,7 @@ case class WeaveSuccessResult(outputStream: OutputStream, charset: String) exten
case ap: AutoPersistedOutputStream => {
implicit val context: EvaluationContext = EvaluationContext()
try {
new String(BinaryValue.getBytesFromSeekableStream(ap.toInputStream, close = true), charset)
new String(BinaryValue.getBytesFromSeekableStream(ap.toInputStream, close = true, memoryService = context.serviceManager.memoryService), charset)
} finally {
context.close()
}
Expand Down

0 comments on commit 3fb0072

Please sign in to comment.