doubleshot 0.4.0-java → 0.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/Doubleshot CHANGED
@@ -4,7 +4,7 @@ Doubleshot.new do |config|
4
4
 
5
5
  config.project = "doubleshot"
6
6
  config.group = "org.sam.doubleshot"
7
- config.version = "0.4.0"
7
+ config.version = "0.5.0"
8
8
 
9
9
  config.gem "minitest", ">= 3.0.1"
10
10
  config.gem "minitest-wscolor", ">= 0"
data/README.markdown ADDED
@@ -0,0 +1,136 @@
1
+ #Doubleshot
2
+
3
+ Latest test results:
4
+
5
+ [![Build Status](https://secure.travis-ci.org/sam/doubleshot.png)](http://travis-ci.org/sam/doubleshot)
6
+
7
+ ##Overview
8
+
9
+ Doubleshot is for Developers using JRuby.
10
+
11
+ It lets you write Java and Ruby, perform Continuous Testing (meaning whenever a file changes, both Java and Ruby code is sandboxed and reloaded and the appropriate tests run), and package it all up as a Gem or JAR.
12
+
13
+ It's a substitute for writing your own Maven tasks, declaring Maven Dependencies, managing Ruby dependencies with Bundler, and packaging everything up as a Gem with a Rakefile.
14
+
15
+ Before Doubleshot you might have a ```Buildfile``` (using Buildr), ```Jarfile``` and ```Gemfile```. Or a ```pom.xml```, ```Gemfile``` and ```Rakefile```. However you slice it, you'd be using multiple tools, with different syntaxes and styles, that required you to run them in a specific order to actually get your project to run.
16
+
17
+ Doubleshot simplifies all that. One Doubleshot file defines your Gem dependencies *and* your JAR dependencies, and declares how to either test or package it all up as a Gem or a JAR. Once you have a Doubleshot file (take a look at the [examples](https://github.com/sam/doubleshot/tree/master/examples) folder for some basics), then you have a few simple commands you can run to do what you need. Here's the output of ```doubleshot help```:
18
+
19
+ ```
20
+ Usage: doubleshot COMMAND [ OPTIONS ]
21
+
22
+ Summary: Command line tool for creating and managing doubleshot projects.
23
+
24
+ doubleshot init # Generate a Doubleshot file for your project.
25
+
26
+ doubleshot test # A test harness that watches files, builds your
27
+ # source, and executes tests based on filename
28
+ # conventions. The location of your tests is
29
+ # determined by the 'config.source.tests'
30
+ # attribute of your Doubleshot configuration.
31
+
32
+ doubleshot build # Download all dependencies and compile sources so that you
33
+ # can use the project directly without installation, such
34
+ # as with IRB.
35
+ #
36
+ # NOTE: Packaging and testing have a dependency on this
37
+ # command. You don't need to build as a prerequisite.
38
+
39
+ doubleshot gem # Package your project as a Rubygem, bundling any
40
+ # JAR dependencies and Java classes in with the distribution.
41
+
42
+ doubleshot jar # Package your project as a JAR.
43
+
44
+ doubleshot install # Install your project as a Rubygem.
45
+
46
+ doubleshot pom # Generate a pom.xml based on your Doubleshot file.
47
+ ```
48
+
49
+ To get a descriptive ```Doubleshot``` that comments all the options, just run ```doubleshot init``` in your project. It'll read existing ```myproject.gemspec``` and ```pom.xml``` files, and use them to generate a Doubleshot file. Take a look at the ```Doubleshot.example``` file in this project if you just want to read up now.
50
+
51
+ **Pro-Tip:** Similar to a ```Gem::Specification```, a ```Doubleshot::Configuration``` provides a ```#to_ruby``` method, so that example was generated in IRB from the actual project configuration (the existing ```Doubleshot``` file in the project) like this:
52
+
53
+ ```ruby
54
+ require "lib/doubleshot"
55
+ Pathname("Doubleshot.example").open("w+") do |example|
56
+ example << Doubleshot::current.config.to_ruby
57
+ end
58
+ ```
59
+
60
+ ##Requirements
61
+ * Java 6 or later
62
+ * Maven
63
+ * JRuby 1.7 or later
64
+ * Ruby 1.9 syntax only
65
+
66
+ ##Installation
67
+
68
+ ```
69
+ gem install doubleshot
70
+ ```
71
+
72
+ ##Development
73
+
74
+ Here's how to get Doubleshot running locally yourself. You'll need Java, Maven and JRuby (1.7.x or -head) installed. Then, clone the repo:
75
+
76
+ ```
77
+ git clone git://github.com/sam/doubleshot.git
78
+ ```
79
+
80
+ Doubleshot bootstraps its own build using a slightly different process than what is used for projects actually using it. It's a chicken and egg situation. Since Doubleshot depends on some Java code to resolve JAR dependencies, and we can't compile without our dependencies, we can't use Doubleshot's normal code to resolve its own JAR dependencies. That's why Doubleshot has a ```pom.xml``` (generated with the ```doubleshot pom``` command). We shell out to the Maven command line while bootstrapping the build.
81
+
82
+ All that just to clarify the process. The only thing left you actually need to do at this point is run one of the ```doubleshot ``` commands to package or test. The internal bootstrapping will take care of the rest:
83
+
84
+ ```
85
+ bin/doubleshot test --ci
86
+ ```
87
+
88
+ ##Project Layout
89
+
90
+ The *default* project using Doubleshot as its build-tool will have the following layout:
91
+
92
+ ```
93
+ /
94
+ ext/
95
+ java/
96
+ Hello.java # Java sources appear under the ext/java folder.
97
+ lib/
98
+ world.rb # Ruby sources go in the standard location.
99
+ test/
100
+ helper.rb
101
+ hello_spec.rb # specs match up to lib/**/*.rb or ext/java/**/*.java
102
+ world_spec.rb
103
+ Doubleshot # Your Doubleshot file replaces your project's gemspec
104
+ # and JBundler's Jarfile.
105
+ ```
106
+
107
+ Your tests should be executable and look something like this:
108
+
109
+ ```Ruby
110
+ #!/usr/local/env jruby
111
+
112
+ require_relative "helper.rb"
113
+
114
+ java_import org.sam.doubleshot.example.Hello
115
+
116
+ describe Hello do
117
+ it "must rock you" do
118
+ Hello.rock(:you).must_equal true
119
+ end
120
+ end
121
+ ```
122
+
123
+ ...and ```helper.rb``` would look something like this:
124
+
125
+ ```Ruby
126
+ require "doubleshot"
127
+ require "minitest/autorun"
128
+ ...
129
+ ```
130
+
131
+ ##FAQ
132
+
133
+ ###Does Doubleshot support Ruby 1.8.x syntax?
134
+ No.
135
+
136
+ ##Happy coding!
data/lib/doubleshot.rb CHANGED
@@ -89,6 +89,27 @@ class Doubleshot
89
89
  load_gems! unless @config.runtime.gems.empty? && @config.development.gems.empty?
90
90
  load_jars! unless @config.runtime.jars.empty? && @config.development.jars.empty?
91
91
  end
92
+
93
+ def build!(conditional = true)
94
+ if !conditional && @config.target.exist?
95
+ @config.target.rmtree
96
+ end
97
+
98
+ return unless @config.source.java.exist?
99
+
100
+ compiler = Doubleshot::Compiler.new(@config.source.java, @config.target)
101
+
102
+ lockfile.jars.each do |jar|
103
+ compiler.classpath << jar.path
104
+ end
105
+
106
+ if !conditional || compiler.pending?
107
+ puts "Compiling..."
108
+ compiler.build! true
109
+ else
110
+ puts "Conditional build: No source changes."
111
+ end
112
+ end
92
113
 
93
114
  def load_gems!
94
115
  if lockfile.gems.empty?
@@ -35,10 +35,6 @@ class Doubleshot::CLI::Commands::Build < Doubleshot::CLI
35
35
  options = self.options.parse!(args)
36
36
  doubleshot = Doubleshot::current
37
37
 
38
- if options.conditional && doubleshot.config.target.exist?
39
- doubleshot.config.target.rmtree
40
- end
41
-
42
38
  if doubleshot.config.project == "doubleshot"
43
39
  puts "Bootstrapping Doubleshot build with Maven..."
44
40
  doubleshot.bootstrap!
@@ -47,28 +43,7 @@ class Doubleshot::CLI::Commands::Build < Doubleshot::CLI
47
43
  doubleshot.setup!
48
44
  end
49
45
 
50
- if doubleshot.config.source.java.exist?
51
- compiler = Doubleshot::Compiler.new(doubleshot.config.source.java, doubleshot.config.target)
52
-
53
- if options.classpath.empty?
54
- doubleshot.classpath
55
- else
56
- options.classpath
57
- end.each do |path|
58
- compiler.classpath << path
59
- end
60
-
61
- puts "[INFO] Using #{compiler.classpath}"
62
- puts
63
-
64
- if compiler.pending? || !options.conditional
65
- puts "Compiling..."
66
- compiler.build!
67
- else
68
- puts "Conditional build: No source changes."
69
- end
70
- end
71
-
46
+ doubleshot.build! options.conditional
72
47
  return 0
73
48
  end
74
49
  end
@@ -34,7 +34,8 @@ class Doubleshot::CLI::Commands::Gem < Doubleshot::CLI
34
34
  return 1
35
35
  end
36
36
  else
37
- Doubleshot::CLI::Commands::Build.start(args)
37
+ doubleshot.setup!
38
+ doubleshot.build! false
38
39
  end
39
40
 
40
41
  target = doubleshot.config.target
@@ -38,7 +38,8 @@ class Doubleshot::CLI::Commands::Jar < Doubleshot::CLI
38
38
  return 1
39
39
  end
40
40
  else
41
- Doubleshot::CLI::Commands::Build.start(args)
41
+ doubleshot.setup!
42
+ doubleshot.build!
42
43
  end
43
44
 
44
45
  unless Pathname::glob(doubleshot.config.source.java + "**/*.java").empty?
@@ -19,7 +19,6 @@ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
19
19
  options.ci_test = false
20
20
  options.on "--ci", "Run all tests, then exit. (No continuous listening for file changes.)" do
21
21
  options.ci_test = true
22
- options.build = true
23
22
  end
24
23
 
25
24
  options.force_tests = false
@@ -106,13 +105,16 @@ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
106
105
 
107
106
  def run
108
107
  if @ci_test
108
+ if @config.project == "doubleshot"
109
+ Doubleshot::current.bootstrap!
110
+ Doubleshot::current.build! false
111
+ end
109
112
  exit_status = run_all_specs
110
113
  unless @force_tests
111
114
  @@pid_file.delete if @@pid_file.exist?
112
115
  end
113
116
  exit_status
114
117
  else
115
- Doubleshot::CLI::Commands::Build.start([ "--conditional" ])
116
118
  # Output here just so you know when changes will be
117
119
  # picked up after you start the program.
118
120
  puts "Listening for changes..."
@@ -151,7 +153,8 @@ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
151
153
 
152
154
  if test && test.exist?
153
155
  if path.extname == ".java"
154
- Doubleshot::CLI::Commands::Build.start([])
156
+ Doubleshot::current.setup!
157
+ Doubleshot::current.build! false
155
158
  end
156
159
 
157
160
  duration = Time::measure do
@@ -180,8 +183,6 @@ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
180
183
  duration = Time::measure do
181
184
  puts "\n --- Running all tests ---\n\n"
182
185
 
183
- Doubleshot::CLI::Commands::Build.start([ "--conditional" ])
184
-
185
186
  script = <<-RUBY
186
187
  begin
187
188
  #{
@@ -35,11 +35,17 @@ class Doubleshot
35
35
  EOS
36
36
 
37
37
  GEM_REPOSITORY_MESSAGE = <<-EOS.margin
38
- # TODO
38
+ # Add your custom ruby gem repositories here.
39
+ #
40
+ # Default is http://rubygems.org
41
+ # (defined in Resolver::GemResolver::DEFAULT_REPOSITORY)
39
42
  EOS
40
43
 
41
44
  MVN_REPOSITORY_MESSAGE = <<-EOS.margin
42
- # TODO
45
+ # Add your custom Maven repositories here.
46
+ #
47
+ # Default is http://repo1.maven.org/maven2
48
+ # (defined in Resolver::JarResolver::DEFAULT_REPOSITORY)
43
49
  EOS
44
50
 
45
51
  SOURCE_RUBY_MESSAGE = <<-EOS.margin
@@ -487,7 +493,6 @@ class Doubleshot
487
493
  spec.author = #{spec.author.inspect}
488
494
  spec.email = #{spec.email.inspect}
489
495
  spec.license = #{spec.license.inspect}
490
- spec.executables = #{spec.executables.inspect}
491
496
  end
492
497
  EOS
493
498
  end
@@ -1,3 +1,5 @@
1
1
  require_relative "../doubleshot"
2
2
 
3
- Doubleshot::current.setup!
3
+ doubleshot = Doubleshot::current
4
+ doubleshot.setup!
5
+ doubleshot.build!
Binary file
@@ -362,7 +362,6 @@ describe Doubleshot::Configuration do
362
362
  spec.author = "Sam Smoot"
363
363
  spec.email = "ssmoot@gmail.com"
364
364
  spec.license = "MIT-LICENSE"
365
- spec.executables = ["doubleshot"]
366
365
  end
367
366
  EOS
368
367
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: doubleshot
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.0
5
+ version: 0.5.0
6
6
  platform: java
7
7
  authors:
8
8
  - Sam Smoot
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-13 00:00:00.000000000 Z
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -145,7 +145,7 @@ files:
145
145
  - !binary |-
146
146
  UkVBRE1FLU9MRC50ZXh0aWxl
147
147
  - !binary |-
148
- UkVBRE1FLnRleHRpbGU=
148
+ UkVBRE1FLm1hcmtkb3du
149
149
  - lib/doubleshot/cli/options.rb
150
150
  - lib/doubleshot/cli.rb
151
151
  - lib/doubleshot/commands/build.rb
data/README.textile DELETED
@@ -1,68 +0,0 @@
1
- h1. Doubleshot
2
-
3
- Latest test results:
4
-
5
- !https://secure.travis-ci.org/sam/doubleshot.png(Build Status)!:http://travis-ci.org/sam/doubleshot
6
-
7
- h2. Overview
8
-
9
- Doubleshot is for Developers using JRuby.
10
-
11
- It let's you write Java and Ruby, perform Continuous Testing (meaning whenever a file changes, both Java and Ruby code is sandboxed and reloaded and the appropriate tests run), and package it all up as a Gem or JAR.
12
-
13
- It's a substitute for writing your own Maven tasks, declaring Maven Dependencies, having Ruby dependencies managed by Bundler, and a Rakefile for packaging everything up as a Gem.
14
-
15
- Before Doubleshot you might have a @Buildfile@ (using Buildr), @Jarfile@ and @Gemfile@. Or a @pom.xml@, @Gemfile@ and @Rakefile@. However you slice it, you'd be using multiple tools, with different syntaxes and styles, that required you to run them in a specific order to actually get your project to run.
16
-
17
- Doubleshot simplifies all that. You have one Doubleshot file that defines your Gem dependencies, your JAR dependencies, and declares how to either test or package it all up as a Gem or a JAR. Once you have a Doubleshot file (take a look at the examples folder for some basics), then you have a few simple commands you can run to do what you need. Here's the output of @doubleshot help@:
18
-
19
- bc.. Usage: doubleshot COMMAND [ OPTIONS ]
20
-
21
- Summary: Command line tool for creating and managing doubleshot projects.
22
-
23
- doubleshot init # Generate a Doubleshot file for your project.
24
-
25
- doubleshot test # A test harness that watches files, builds your
26
- # source, and executes tests based on filename
27
- # conventions. The location of your tests is
28
- # determined by the 'config.source.tests'
29
- # attribute of your Doubleshot configuration.
30
-
31
- doubleshot build # Download all dependencies and compile sources so that you
32
- # can use the project directly without installation, such
33
- # as with IRB.
34
- #
35
- # NOTE: Packaging and testing have a dependency on this
36
- # command. You don't need to build as a prerequisite.
37
-
38
- doubleshot gem # Package your project as a Rubygem, bundling any
39
- # JAR dependencies and Java classes in with the distribution.
40
-
41
- doubleshot jar # Package your project as a JAR.
42
-
43
- doubleshot install # Install your project as a Rubygem.
44
-
45
- doubleshot pom # Generate a pom.xml based on your Doubleshot file.
46
-
47
- p. To get a descriptive @Doubleshot@ that comments all the options, just run @doubleshot init@ in your project. It'll read existing @myproject.gemspec@ and @pom.xml@ files, and use them to generate a Doubleshot file. Take a look at the @Doubleshot.example@ file in this project if you just want to read up now.
48
-
49
- Pro-Tip: Similarly to a @Gem::Specification@, a @Doubleshot::Configuration@ provides a @#to_ruby@ method, so that example was generated in IRB from the actual project configuration (the existing @Doubleshot@ file in the project) like this:
50
-
51
- bc.. require "lib/doubleshot"
52
- Pathname("Doubleshot.example").open("w+") do |example|
53
- example << Doubleshot::current.config.to_ruby
54
- end
55
-
56
- h2. Development
57
-
58
- Here's how to get Doubleshot running locally yourself. You'll need Java, Maven and JRuby (1.7.x or -head) installed. Then, clone the repo:
59
-
60
- bc. git clone git://github.com/sam/doubleshot.git
61
-
62
- Doubleshot bootstraps it's own build using a slightly different process than used for projects actually using it. It's a chicken and egg situation. Since Doubleshot depends on some Java code to resolve JAR dependencies, and we can't compile without our dependencies, we can't use Doubleshot's normal code to resolve it's own JAR dependencies. That's why Doubleshot has a @pom.xml@ (generated with the @doubleshot pom@ command). We shell out to the Maven command line while bootstrapping the build.
63
-
64
- All that just to clarify the process. The only thing left you actually need to do at this point is run one of the @doubleshot@ commands to package or test. The internal bootstrapping will take care of the rest:
65
-
66
- bc. bin/doubleshot test --ci
67
-
68
- Happy coding!