@@ -10,7 +10,11 @@ import path from "path"
10
10
import GrammarUtils from "../grammar-utils"
11
11
const { command } = GrammarUtils
12
12
13
- function JavaArgs ( sourcePath , filepath , className , classPackages , tempFolder ) {
13
+ function JavaArgs ( filepath , context ) {
14
+ const sourcePath = GrammarUtils . Java . getProjectPath ( context )
15
+ const className = GrammarUtils . Java . getClassName ( context )
16
+ const classPackages = GrammarUtils . Java . getClassPackage ( context )
17
+ const tempFolder = GrammarUtils . createTempFolder ( "jar-" )
14
18
const cmd = `javac -encoding UTF-8 -sourcepath '${ sourcePath } ' -d '${ tempFolder } ' '${ filepath } ' && java -D'file.encoding'='UTF-8' -cp '${ tempFolder } ' ${ classPackages } ${ className } `
15
19
return GrammarUtils . formatArgs ( cmd )
16
20
}
@@ -21,21 +25,13 @@ export const Java = {
21
25
args ( context ) {
22
26
const code = context . getCode ( )
23
27
const tmpFile = GrammarUtils . createTempFileWithCode ( code , ".java" )
24
- const sourcePath = GrammarUtils . Java . getProjectPath ( context )
25
- const className = GrammarUtils . Java . getClassName ( context )
26
- const classPackages = GrammarUtils . Java . getClassPackage ( context )
27
- const tempFolder = GrammarUtils . createTempFolder ( "jar-" )
28
- return JavaArgs ( sourcePath , tmpFile , className , classPackages , tempFolder )
28
+ return JavaArgs ( tmpFile , context )
29
29
} ,
30
30
} ,
31
31
"File Based" : {
32
32
command,
33
33
args ( context ) {
34
- const sourcePath = GrammarUtils . Java . getProjectPath ( context )
35
- const className = GrammarUtils . Java . getClassName ( context )
36
- const classPackages = GrammarUtils . Java . getClassPackage ( context )
37
- const tempFolder = GrammarUtils . createTempFolder ( "jar-" )
38
- return JavaArgs ( sourcePath , context . filepath , className , classPackages , tempFolder )
34
+ return JavaArgs ( context . filepath , context )
39
35
} ,
40
36
} ,
41
37
}
0 commit comments