Skip to content

Commit 6fb2abd

Browse files
committed
get rid of the org.jruby rake plugin - avoid target/classpath.rb generation
1 parent 8fd357f commit 6fb2abd

File tree

3 files changed

+62
-51
lines changed

3 files changed

+62
-51
lines changed

Rakefile

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,19 @@ end
3232

3333
directory 'target/classes'
3434

35-
file 'target/classpath.rb' do
36-
sh 'mvn org.jruby.plugins:jruby-rake-plugin:classpath -Djruby.classpath.scope=test'
37-
end
38-
GENERATED << 'target/classpath.rb'
39-
4035
desc "Compile classes"
41-
task :compile => [:'target/classes'] do |t|
42-
sh 'mvn compile'
43-
end
36+
task(:compile => 'target/classes') { sh 'mvn compile' }
4437

4538
directory 'target/test-classes'
4639

4740
desc "Compile test classes"
48-
task :test_compile => ['target/test-classes'] do |t|
49-
sh 'mvn test-compile'
41+
task(:test_compile => 'target/test-classes') { sh 'mvn test-compile' }
42+
43+
desc "Copy .jar dependencies for (local) testing"
44+
task(:test_jars) { sh 'mvn test-compile -P jars' }
45+
46+
task(:test_prepare => ['target/classes', 'target/test-classes']) do
47+
sh 'mvn compile test-compile -P jars'
5048
end
5149

5250
desc "Unpack the rack gem"
@@ -104,7 +102,7 @@ namespace :resources do
104102
task :test => :test_resources
105103
end
106104

107-
task :speconly => ['target/classpath.rb', :resources, :test_resources] do
105+
task :speconly => [ :resources, :test_resources ] do
108106
if ENV['SKIP_SPECS'].to_s == 'true'
109107
puts "Skipping specs due to SKIP_SPECS=#{ENV['SKIP_SPECS']}"
110108
else
@@ -117,7 +115,7 @@ task :speconly => ['target/classpath.rb', :resources, :test_resources] do
117115
end
118116

119117
desc "Run specs"
120-
task :spec => [:compile, :test_compile, :speconly]
118+
task :spec => [:test_prepare, :speconly]
121119
task :test => :spec
122120

123121
POM_FILE = 'pom.xml'
@@ -132,14 +130,6 @@ GEM_VERSION =
132130

133131
JAR_VERSION = GEM_VERSION.sub(/\.(\D+\w*)/, '-\1') # 1.1.1.SNAPSHOT -> 1.1.1-SNAPSHOT
134132

135-
desc "Print the (Maven) class-path"
136-
task :classpath => 'target/classpath.rb' do
137-
require './target/classpath'
138-
classpath = Maven.classpath
139-
classpath = classpath.reject { |p| p =~ /target\/(test-)?classes$/ }
140-
puts *classpath
141-
end
142-
143133
file (target_jruby_rack = 'target/gem/lib/jruby-rack.rb') do |t|
144134
mkdir_p File.dirname(t.name)
145135
File.open(t.name, "wb") do |f|

pom.xml

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -132,36 +132,36 @@
132132
<scope>provided</scope>
133133
</dependency>
134134
<dependency>
135-
<groupId>log4j</groupId>
136-
<artifactId>log4j</artifactId>
137-
<version>1.2.17</version>
138-
<scope>provided</scope>
135+
<groupId>log4j</groupId>
136+
<artifactId>log4j</artifactId>
137+
<version>1.2.17</version>
138+
<scope>provided</scope>
139139
</dependency>
140140
<dependency>
141-
<groupId>org.springframework</groupId>
142-
<artifactId>spring-core</artifactId>
143-
<version>3.1.4.RELEASE</version>
144-
<scope>test</scope>
141+
<groupId>org.springframework</groupId>
142+
<artifactId>spring-core</artifactId>
143+
<version>3.1.4.RELEASE</version>
144+
<scope>test</scope>
145145
</dependency>
146146
</dependencies>
147147

148148
<build>
149149
<defaultGoal>install</defaultGoal>
150150
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
151151
<resources>
152-
<resource>
153-
<directory>${basedir}/src/main/ruby</directory>
154-
</resource>
155-
<resource>
156-
<directory>${basedir}/src/main/tld</directory>
157-
<targetPath>META-INF</targetPath>
158-
</resource>
152+
<resource>
153+
<directory>${basedir}/src/main/ruby</directory>
154+
</resource>
155+
<resource>
156+
<directory>${basedir}/src/main/tld</directory>
157+
<targetPath>META-INF</targetPath>
158+
</resource>
159159
</resources>
160160
<testSourceDirectory>${basedir}/src/spec/java</testSourceDirectory>
161161
<testResources>
162-
<testResource>
163-
<directory>${basedir}/src/spec/ruby</directory>
164-
</testResource>
162+
<testResource>
163+
<directory>${basedir}/src/spec/ruby</directory>
164+
</testResource>
165165
</testResources>
166166
<plugins>
167167
<plugin>
@@ -258,12 +258,6 @@
258258
</execution>
259259
</executions>
260260
</plugin>
261-
<!--
262-
<plugin>
263-
<groupId>org.jruby</groupId>
264-
<artifactId>jruby-rake-plugin</artifactId>
265-
<version>${jruby.version}</version>
266-
</plugin>-->
267261
</plugins>
268262
<extensions>
269263
<extension>
@@ -273,5 +267,33 @@
273267
</extension>
274268
</extensions>
275269
</build>
270+
271+
<profiles>
272+
<profile>
273+
<id>jars</id>
274+
<build>
275+
<plugins>
276+
<plugin>
277+
<groupId>org.apache.maven.plugins</groupId>
278+
<artifactId>maven-dependency-plugin</artifactId>
279+
<version>2.8</version>
280+
<executions>
281+
<execution>
282+
<phase>process-sources</phase>
283+
<goals>
284+
<goal>copy-dependencies</goal>
285+
</goals>
286+
<configuration>
287+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
288+
<excludeGroupIds>org.jruby</excludeGroupIds>
289+
</configuration>
290+
</execution>
291+
</executions>
292+
</plugin>
293+
</plugins>
294+
</build>
295+
</profile>
296+
</profiles>
297+
276298
</project>
277299

src/spec/ruby/spec_helper.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
require 'rspec'
99

1010
require 'java'
11-
begin
12-
require File.expand_path('target/classpath.rb', File.dirname(__FILE__) + '/../../..')
13-
rescue LoadError => e
14-
puts "classpath.rb script missing try running `rake clean compile` first"
15-
raise e
16-
end unless defined?(Maven.set_classpath)
17-
Maven.set_classpath
11+
target = File.expand_path('target', "#{File.dirname(__FILE__)}/../../..")
12+
jars = File.exist?(lib = "#{target}/lib") && ( Dir.entries(lib) - [ '.', '..' ] )
13+
raise "missing .jar dependencies please run `rake test_jars'" if ! jars || jars.empty?
14+
$CLASSPATH << File.expand_path('classes', target)
15+
$CLASSPATH << File.expand_path('test-classes', target)
16+
jars.each { |jar| $CLASSPATH << File.expand_path(jar, lib) }
1817

1918
# Java imports :
2019
java_import 'javax.servlet.ServletContext'

0 commit comments

Comments
 (0)