This repository was archived by the owner on Mar 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
lib/org/jruby/ext/references Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -49,14 +49,19 @@ namespace :java do
49
49
FileUtils . rm_rf ( classes_dir )
50
50
ext_dir = File . join ( base_dir , "ext" , "java" )
51
51
source_files = FileList [ "#{ base_dir } /**/*.java" ]
52
- FileUtils . mkdir_p ( classes_dir )
53
- `#{ ENV [ 'JAVA_HOME' ] } /bin/javac -classpath '#{ "#{ ENV [ 'JRUBY_HOME' ] } /lib/jruby.jar" } ' -d '#{ classes_dir } ' -sourcepath '#{ ext_dir } ' '#{ source_files . join ( "' '" ) } '`
54
- if $? == 0
55
- FileUtils . rm_rf ( jar_dir ) if File . exist? ( jar_dir )
56
- FileUtils . mkdir_p ( jar_dir )
57
- `#{ ENV [ 'JAVA_HOME' ] } /bin/jar cf '#{ File . join ( jar_dir , 'reference.jar' ) } ' -C '#{ classes_dir } ' org`
52
+ jar_file = File . join ( jar_dir , 'reference.jar' )
53
+ # Only build if any of the source files have changed
54
+ up_to_date = File . exist? ( jar_file ) && source_files . all? { |f | File . mtime ( f ) <= File . mtime ( jar_file ) }
55
+ unless up_to_date
56
+ FileUtils . mkdir_p ( classes_dir )
57
+ `#{ ENV [ 'JAVA_HOME' ] } /bin/javac -classpath '#{ "#{ ENV [ 'JRUBY_HOME' ] } /lib/jruby.jar" } ' -d '#{ classes_dir } ' -sourcepath '#{ ext_dir } ' '#{ source_files . join ( "' '" ) } '`
58
+ if $? == 0
59
+ FileUtils . rm_rf ( jar_dir ) if File . exist? ( jar_dir )
60
+ FileUtils . mkdir_p ( jar_dir )
61
+ `#{ ENV [ 'JAVA_HOME' ] } /bin/jar cf '#{ jar_file } ' -C '#{ classes_dir } ' org`
62
+ end
63
+ FileUtils . rm_rf ( classes_dir )
58
64
end
59
- FileUtils . rm_rf ( classes_dir )
60
65
end
61
66
end
62
67
You can’t perform that action at this time.
0 commit comments