%global gem_rack_version 1.2.2
Name: jruby-rack
Version: 1.0.10
Release: 3%{?dist}
Summary: Rack adapter for JRuby and Servlet Containers
Group: Development/Libraries
License: MIT
URL: https://github.com/jruby/jruby-rack
# git clone git://github.com/jruby/jruby-rack.git jruby-rack-1.0.10
# (cd jruby-rack-1.0.10/ && git archive --format=tar --prefix=jruby-rack-1.0.10/ 1.0.10 | xz > ../jruby-rack-1.0.10-src.tar.xz)
Source0: https://github.com/jruby/jruby-rack/archive/%{version}.tar.gz
# suitable for use tomcat and 7.x apis
Patch0: %{name}-1.0.10-servlet30.patch
# support `rake gem` on RubyGems 2.0 (removed Gem::Builder)
Patch1: %{name}-1.0.10-rubygems2.patch
BuildRequires: java-devel
#BuildRequires: jruby-rake-plugin fails jruby dont work properly
BuildRequires: apache-commons-logging
BuildRequires: bytelist >= 1.0.8-3
BuildRequires: geronimo-jms
BuildRequires: jnr-constants >= 0.7-6
BuildRequires: jruby
BuildRequires: jruby-yecht
BuildRequires: log4j
BuildRequires: slf4j
BuildRequires: tomcat-el-2.2-api
BuildRequires: tomcat-jsp-2.2-api
BuildRequires: tomcat-servlet-3.0-api
BuildRequires: rubygem-builder
BuildRequires: rubygem-bundler
BuildRequires: rubygem-rake
BuildRequires: rubygem-rspec
BuildRequires: rubygem-rspec-core
Requires: apache-commons-logging
# see https://bugzilla.redhat.com/show_bug.cgi?id=819587
Requires: bytelist >= 1.0.8-3
Requires: geronimo-jms
# see https://bugzilla.redhat.com/show_bug.cgi?id=819583
Requires: jnr-constants >= 0.7-6
Requires: jruby
Requires: log4j
Requires: slf4j
Requires: tomcat-el-2.2-api
Requires: tomcat-jsp-2.2-api
Requires: tomcat-servlet-3.0-api
Requires: java
BuildArch: noarch
%description
JRuby-Rack is a combined Java and Ruby library that adapts the
Java Servlet API to Rack. For JRuby only.
%package -n rubygem-jruby-rack
Group: Development/Languages
Summary: Rack adapter for JRuby and Servlet Containers
Requires: %{name} = %{version}-%{release}
%description -n rubygem-jruby-rack
JRuby-Rack is a combined Java and Ruby library that adapts the
Java Servlet API to Rack. For JRuby only.
%package javadoc
Group: Documentation
Summary: Javadoc for %{name}
%description javadoc
This package contains javadoc for %{name}.
%prep
%setup -q
find . -name '*.jar' -delete
find . -name '*.class' -delete
%pom_xpath_remove "pom:build/pom:extensions"
%pom_remove_plugin org.jruby.plugins:jruby-rake-plugin
%pom_xpath_remove "pom:dependencies/pom:dependency[pom:groupId ='org.jruby']/pom:artifactId"
%pom_xpath_inject "pom:dependencies/pom:dependency[pom:groupId ='org.jruby']" "jruby"
%pom_remove_dep org.apache.geronimo.specs:geronimo-servlet_2.5_spec
%pom_add_dep org.apache.tomcat:tomcat-servlet-api
%pom_remove_dep org.apache.geronimo.specs:geronimo-jsp_2.1_spec
%pom_add_dep org.apache.tomcat:tomcat-jsp-api::provided
%pom_remove_dep org.apache.geronimo.specs:geronimo-el_1.0_spec
%pom_add_dep org.apache.tomcat:tomcat-el-api::provided
%if %{?fedora} > 18
%pom_add_dep org.jruby.extras:bytelist
%pom_add_dep com.github.jnr:jnr-constants
%else
%pom_xpath_inject "pom:project/pom:dependencies" "
org.jruby.extras
bytelist
system
$(build-classpath bytelist)
"
%pom_xpath_inject "pom:project/pom:dependencies" "
org.jruby.extras
constantine
system
$(build-classpath constantine)
"
%endif
%patch0 -p0
%patch1 -p0
# TODO this task fail: Could not find RSpec 1.3.x `spec' executable
sed -i "s|, :speconly||" Rakefile
# set mvn user repository
sed -i "s|~/.m2/|$PWD/.m2/|" Rakefile
%build
export CLASSPATH=$(build-classpath commons-logging bytelist geronimo-jms log4j slf4j/api tomcat-el-2.2-api tomcat-jsp-2.2-api tomcat-servlet-3.0-api):/usr/share/jruby-yecht.jar
jruby -S rake -f Rakefile --trace install gem
mkdir -p .%{_datadir}/jruby/lib/ruby/gems/1.8
jruby -S gem install --local --install-dir .%{_datadir}/jruby/lib/ruby/gems/1.8 \
--force $PWD/target/%{name}-%{version}.gem
mkdir -p target/site/apidocs
%javadoc -classpath $CLASSPATH:$(build-classpath jruby):$PWD/target/%{name}-%{version}.jar \
-d target/site/apidocs -sourcepath src/main/java -subpackages org.jruby.rack
%install
mkdir -p %{buildroot}%{_javadir}
install -pm 644 target/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar
mkdir -p %{buildroot}%{_mavenpomdir}
install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
%add_maven_depmap JPP-%{name}.pom %{name}.jar
mkdir -p %{buildroot}%{_javadocdir}/%{name}
cp -pr target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name}
mkdir -p %{buildroot}%{_datadir}/jruby/lib/ruby/gems/1.8
cp -a .%{_datadir}/jruby/lib/ruby/gems/1.8/* \
%{buildroot}%{_datadir}/jruby/lib/ruby/gems/1.8/
rm -r %{buildroot}%{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}/lib/%{name}-%{version}.jar
ln -sf ../../../../../../../../java/%{name}.jar %{buildroot}%{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}/lib/%{name}-%{version}.jar
%files
%{_javadir}/%{name}.jar
%{_mavenpomdir}/JPP-%{name}.pom
%{_mavendepmapfragdir}/%{name}
%doc History.txt LICENSE.txt README.md TODO
%files -n rubygem-jruby-rack
%exclude %{_datadir}/jruby/lib/ruby/gems/1.8/cache
%dir %{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}
%doc %{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}/History.txt
%doc %{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}/LICENSE.txt
%doc %{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}/README.md
%{_datadir}/jruby/lib/ruby/gems/1.8/gems/%{name}-%{version}/lib/*
%{_datadir}/jruby/lib/ruby/gems/1.8/specifications/*
%files javadoc
%{_javadocdir}/%{name}
%doc LICENSE.txt
%changelog
* Thu Aug 16 2012 gil cattaneo 1.0.10-3
- Used pom macros
- Fixed BuildRequires list
* Thu Aug 16 2012 gil cattaneo 1.0.10-2
- Added tomcat 7.x apis support
- Added rubygem subpackage (jruby only)
* Sat May 12 2012 gil cattaneo 1.0.10-1
- update to 1.0.10
* Mon May 07 2012 gil cattaneo 1.0.9-1
- initial rpm