SHARE
TWEET

java.coffee

a guest Aug 27th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. path = require 'path'
  2. {command} = GrammarUtils = require '../grammar-utils'
  3.  
  4. windows = GrammarUtils.OperatingSystem.isWindows()
  5.  
  6. args = (filepath, jar) ->
  7.   jar = (jar ? path.basename(filepath)).replace /\.kt$/, '.jar'
  8.   cmd = "kotlinc '#{filepath}' -include-runtime -d #{jar} && java -jar #{jar}"
  9.   return GrammarUtils.formatArgs(cmd)
  10.  
  11. module.exports =
  12.  
  13.   Java:
  14.     'File Based': {
  15.       command
  16.       args: (context) ->
  17.         className = GrammarUtils.Java.getClassName context
  18.         classPackages = GrammarUtils.Java.getClassPackage context
  19.         sourcePath = GrammarUtils.Java.getProjectPath context
  20.         if windows
  21.           return ["/c javac -Xlint #{context.filename} --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml && java #{className}"]
  22.         else ['-c', "javac -J-Dfile.encoding=UTF-8 -sourcepath '#{sourcePath}' -d /tmp '#{context.filepath}' && java -Dfile.encoding=UTF-8 -cp /tmp #{classPackages}#{className}"]
  23.     }
  24.   Kotlin:
  25.     'Selection Based': {
  26.       command
  27.       args: (context) ->
  28.         code = context.getCode()
  29.         tmpFile = GrammarUtils.createTempFileWithCode(code, '.kt')
  30.         return args(tmpFile)
  31.     }
  32.     'File Based': {
  33.       command
  34.       args: ({filepath, filename}) -> args(filepath, "/tmp/#{filename}")
  35.     }
  36.   Processing:
  37.     'File Based':
  38.       command: 'processing-java'
  39.       args: ({filepath}) -> ["--sketch=#{path.dirname(filepath)}", "--run"]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top