自动化工具 rake 帮你编译 java

hellohell · 2018年07月10日 · 1295 次阅读

最近准备搞安卓了,但 java 忘光了,开始往回捡;
其实 wo 不喜欢用 ide(安卓好像必须用..打脸) 直到遇到了 package/import

如何编译?

  • 命令行, 把 *.java 文件放到同一个目录里, java -d . *.java
  • 或者分别传入 *.java 进行编译
  • ide

搞了个 rake,起码能用

require 'find'
dir=Dir.pwd

def source_files dir,sfs
    Dir.glob(File.join(dir,'*')) do |f|
      source_files(f,sfs) if File.directory?(f)
      sfs<< File.join(dir,'*.java') if not sfs.include?(f) and f=~/.java$/
    end
    sfs
end

namespace :admin do
  desc "Compile java source files"
  task :compile do
    sfs=source_files dir,[]
    sfs=sfs.join " "
    %x<javac -d . #{sfs}>
    puts 'done'
  end
end

其实 应该用 shell 搞,但不会,以后搞定
这个帖子有什么意义呢?没意义; 不想陷在 ide 各种按钮/配置中,写几 b 的程序用上百兆的辅助工具;

共收到 0 条回复 时间 点赞
hellohell 关闭了讨论 07月10日 06:34
hellohell 重新开启了讨论 07月11日 11:25
hellohell 关闭了讨论 07月11日 11:26
hellohell 重新开启了讨论 07月11日 11:26
hellohell 关闭了讨论 07月11日 11:28
hellohell 关闭了讨论 07月11日 11:30
hellohell 重新开启了讨论 07月11日 11:30
hellohell 关闭了讨论 07月11日 11:31
hellohell 重新开启了讨论 07月11日 11:33
hellohell 关闭了讨论 07月11日 11:33
需要 登录 後方可回應,如果你還沒有帳號按這裡 注册