diff --git a/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala b/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala index a8bc190..4cceaf0 100644 --- a/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala +++ b/native-cli/src/main/scala/org/mule/weave/dwnative/cli/DataWeaveCLI.scala @@ -3,16 +3,14 @@ package org.mule.weave.dwnative.cli import java.io.File import java.io.FileOutputStream -import org.mule.weave.dwnative.AnsiColor -import org.mule.weave.dwnative.DataWeaveUtils import org.mule.weave.dwnative.NativeRuntime -import org.mule.weave.dwnative.WeaveProperties +import org.mule.weave.dwnative.utils.AnsiColor +import org.mule.weave.dwnative.utils.DataWeaveUtils +import org.mule.weave.dwnative.utils.WeaveProperties import org.mule.weave.v2.interpreted.module.WeaveDataFormat import org.mule.weave.v2.model.EvaluationContext import org.mule.weave.v2.module.DataFormatManager import org.mule.weave.v2.parser.ast.variables.NameIdentifier -import org.mule.weave.v2.parser.exception.LocatableException -import org.mule.weave.v2.parser.phase.CompilationException import org.mule.weave.v2.parser.phase.ModuleLoaderManager import org.mule.weave.v2.runtime.ScriptingBindings import org.mule.weave.v2.runtime.utils.AnsiColor.red diff --git a/native-common/src/main/scala/org/mule/weave/dwnative/AnsiColor.scala b/native-common/src/main/scala/org/mule/weave/dwnative/utils/AnsiColor.scala similarity index 86% rename from native-common/src/main/scala/org/mule/weave/dwnative/AnsiColor.scala rename to native-common/src/main/scala/org/mule/weave/dwnative/utils/AnsiColor.scala index 7d3b668..7d26478 100644 --- a/native-common/src/main/scala/org/mule/weave/dwnative/AnsiColor.scala +++ b/native-common/src/main/scala/org/mule/weave/dwnative/utils/AnsiColor.scala @@ -1,4 +1,4 @@ -package org.mule.weave.dwnative +package org.mule.weave.dwnative.utils object AnsiColor { diff --git a/native-common/src/main/scala/org/mule/weave/dwnative/DataWeaveUtils.scala b/native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala similarity index 89% rename from native-common/src/main/scala/org/mule/weave/dwnative/DataWeaveUtils.scala rename to native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala index 78619ec..866f4e4 100644 --- a/native-common/src/main/scala/org/mule/weave/dwnative/DataWeaveUtils.scala +++ b/native-common/src/main/scala/org/mule/weave/dwnative/utils/DataWeaveUtils.scala @@ -1,7 +1,8 @@ -package org.mule.weave.dwnative +package org.mule.weave.dwnative.utils import java.io.File +import org.mule.weave.dwnative.CustomWeaveDataFormat import org.mule.weave.v2.env.StaticServiceProvider import org.mule.weave.v2.env.WeaveRuntime import org.mule.weave.v2.model.ServiceRegistration @@ -38,6 +39,13 @@ object DataWeaveUtils { if (defaultDWHomeDir.exists()) { defaultDWHomeDir } else { + val dwScriptPath = System.getenv("_") + if(dwScriptPath != null) { + val scriptPath = new File(dwScriptPath) + if(scriptPath.isFile && scriptPath.getName == "dw"){ + return scriptPath.getAbsoluteFile.getParentFile + } + } println(AnsiColor.yellow(s"[warning] Unable to detect Weave Home directory so local directory is going to be used. Please either define the env variable WEAVE_HOME or copy the weave distro into `${defaultDWHomeDir.getAbsolutePath}`.")) new File("..") } diff --git a/native-lib/src/main/scala/org/mule/weave/dwnative/lib/DataWeaveNativeLibrary.java b/native-lib/src/main/scala/org/mule/weave/dwnative/lib/DataWeaveNativeLibrary.java index c90b2f3..d0c6dfc 100644 --- a/native-lib/src/main/scala/org/mule/weave/dwnative/lib/DataWeaveNativeLibrary.java +++ b/native-lib/src/main/scala/org/mule/weave/dwnative/lib/DataWeaveNativeLibrary.java @@ -4,11 +4,9 @@ import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.mule.weave.dwnative.DataWeaveUtils; import org.mule.weave.dwnative.NativeRuntime; import org.mule.weave.dwnative.WeaveExecutionResult; -import org.mule.weave.dwnative.WeaveInput; -import org.mule.weave.v2.module.reader.SourceProvider$; +import org.mule.weave.dwnative.utils.DataWeaveUtils; import org.mule.weave.v2.runtime.ScriptingBindings; import java.io.File;