Skip to content

Commit

Permalink
Merge pull request #68 from ckrailo/issue_62
Browse files Browse the repository at this point in the history
Build should skip compilation if config.source.java doesn't exist.
  • Loading branch information
sam committed Nov 2, 2012
2 parents 4850aba + 31e25ff commit ea0de6b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Doubleshot
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Doubleshot.new do |config|
config.mvn_repository "http://maven.mirrors.travis-ci.org/nexus/content/shadows/central-m1/"
config.mvn_repository "http://maven.mirrors.travis-ci.org/nexus/content/repositories/central/"
end

config.mvn_repository "https://nexus.codehaus.org/content/groups/public/"
config.mvn_repository "https://oss.sonatype.org/content/groups/public/"
config.mvn_repository "http://mirrors.ibiblio.org/pub/mirrors/maven2"
Expand Down
24 changes: 24 additions & 0 deletions examples/call_java/Doubleshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# encoding: utf-8

Doubleshot.new do |config|

config.project = "call_java"
config.version = "0.1.0"

config.jar "com.fasterxml.jackson.core:jackson-core:2.0.6"

config.gemspec do |spec|
spec.summary = "An example using Ruby to call a Java library."
spec.description = <<-DESCRIPTION
This example shows that you can use Doubleshot for managing
your Java dependencies, even if you don't have any Java code
of your own to compile.
DESCRIPTION

spec.homepage = "https://github.com/sam/doubleshot/blob/master/examples/call_java"
spec.author = "Sam Smoot"
spec.email = "ssmoot@gmail.com"
spec.license = "MIT-LICENSE"
end

end
4 changes: 4 additions & 0 deletions examples/call_java/Doubleshot.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
JARS:
- com.fasterxml.jackson.core:jackson-core:jar:2.0.6
GEMS: []
7 changes: 7 additions & 0 deletions examples/call_java/lib/call_java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env jruby

require "doubleshot/setup"

java_import com.fasterxml.jackson.core.JsonFactory

puts com.fasterxml.jackson.core.JsonFactory.new.inspect
4 changes: 2 additions & 2 deletions examples/jackson/Doubleshot
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Doubleshot.new do |config|

config.gem "perfer", "= 0.2.0"
config.gem "json"

config.gemspec do |spec|
spec.summary = "A simple Jackson vs json-jruby benchmark."
spec.description = <<-DESCRIPTION
Expand All @@ -27,4 +27,4 @@ DESCRIPTION
spec.license = "MIT-LICENSE"
end

end
end
34 changes: 18 additions & 16 deletions lib/doubleshot/commands/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def self.start(args)
doubleshot.config.target.rmtree
end

compiler = Doubleshot::Compiler.new(doubleshot.config.source.java, doubleshot.config.target)

if doubleshot.config.project == "doubleshot"
puts "Bootstrapping Doubleshot build with Maven..."
doubleshot.bootstrap!
Expand All @@ -49,22 +47,26 @@ def self.start(args)
doubleshot.setup!
end

if options.classpath.empty?
doubleshot.classpath
else
options.classpath
end.each do |path|
compiler.classpath << path
end
if doubleshot.config.source.java.exist?
compiler = Doubleshot::Compiler.new(doubleshot.config.source.java, doubleshot.config.target)

puts "[INFO] Using #{compiler.classpath}"
puts
if options.classpath.empty?
doubleshot.classpath
else
options.classpath
end.each do |path|
compiler.classpath << path
end

if compiler.pending? || !options.conditional
puts "Compiling..."
compiler.build!
else
puts "Conditional build: No source changes."
puts "[INFO] Using #{compiler.classpath}"
puts

if compiler.pending? || !options.conditional
puts "Compiling..."
compiler.build!
else
puts "Conditional build: No source changes."
end
end

return 0
Expand Down

0 comments on commit ea0de6b

Please sign in to comment.