Created
November 14, 2016 15:40
-
-
Save coffeemancy/e479110448a52d24acab89c0331c25d5 to your computer and use it in GitHub Desktop.
test scala with ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* put this file in ~/.sbt/0.13/plugins/plugins.sbt */ | |
/* style */ | |
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0") | |
/* coursier -- faster dependencies */ | |
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M14") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# REQUIREMENTS | |
# | |
# Needs ruby and the watchr gem, which can be installed | |
# globally via: | |
# | |
# sudo gem install watchr | |
# USAGE | |
# | |
# watchr watch.rb | |
dep = Gem::Dependency.new("watchr", "~>0.7.0") | |
unless dep.matching_specs.max_by(&:version) | |
puts "You need to install '#{dep}'" | |
puts "e.g. 'sudo gem install watchr'" | |
exit! | |
end | |
IGNORED_DIRS = [] | |
IGNORED_PATTERNS = [] | |
is_watched = Proc.new do |f| | |
File.directory?(f) && | |
IGNORED_DIRS.none? { |d| f.start_with?(d) } && | |
IGNORED_PATTERNS.none? { |p| p.match(f) } | |
end | |
code_dirs = Dir["./src/**/main/**/*"].select(&is_watched). | |
map { |d| d[2..-1] } | |
test_dirs = Dir["./src/**/test/**/*"].select(&is_watched). | |
map { |d| d[2..-1] } | |
puts "Watching test dirs: #{test_dirs}" | |
puts "Watching code dirs: #{code_dirs}" | |
sbt_style = "sbt scalastyle" | |
sbt_test = "sbt test" | |
(code_dirs + test_dirs).map { |d| /#{d}\/.+\.scala$/ }.each do |to_watch| | |
watch(to_watch) do |md| | |
system(sbt_style) && system(sbt_test) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment