Name: yuicompressor
Version: 2.4.8
Release: 1%{?dist}
Summary: Tool that supports the compression of both JavaScript and CSS files
License: BSD and MPLv1.1
URL: http://yuilibrary.com/projects/yuicompressor/
# we are using prerelease version that is compatible with our rhino
Source0: https://github.com/yui/yuicompressor/archive/v%{version}.tar.gz
# originally taken from http://maven.glassfish.org/content/groups/glassfish/com/yahoo/platform/yui/yuicompressor/2.4.6/yuicompressor-2.4.6.pom
Source1: %{name}-pom-template.xml
Source2: %{name}.pod
# There is a pull request upstream at
# http://yuilibrary.com/projects/yuicompressor/ticket/2528105
# Thanks to Michal Srb msrb@redhat.com
# This patch should make yuicompressor work with our Rhino 1.7R4,
# tested also with 1.7R3 (in F18). Now it seems to be working.
# "java -jar yuicompressor-2.4.8.jar input_file.js" now produces compressed java script.
# However, if inout_file.js is empty or contains only comments (so no javascript at all),
# I get IndexOutOfBoundsException. But this is upstream bug, it also fails with unmodified
# yuicompressor (with rhino 1.7R2).
Patch0: 0001-Port-to-Rhino-1.7R4.patch
# We should upstream this
Patch1: %{name}-2.4.8-test-suite-fix.patch
BuildArch: noarch
BuildRequires: ant
BuildRequires: rhino >= 1.7R3-2
BuildRequires: jargs
BuildRequires: java-javadoc
BuildRequires: jpackage-utils
Requires: rhino >= 1.7R3-2
Requires: jargs
Requires: java
Requires: jpackage-utils
%description
YUI Compressor is an open source tool that supports the compression of
both JavaScript and CSS files. The JavaScript compression removes
comments and white-spaces as well as obfuscates local variables using
the smallest possible variable name. CSS compression is done using a
regular-expression-based CSS minifier.
%package javadoc
Summary: Javadoc for %{name}
%description javadoc
This package contains the API documentation for %{name}.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
iconv -f cp1252 -t UTF-8 LICENSE.TXT > LICENSE.TXT.conv
mv LICENSE.TXT.conv LICENSE.TXT
find . -name "*.class" -delete
find . -name "*.jar" -delete
rm -rf build lib/*
ln -sf $(build-classpath jargs) lib/jargs-1.0.jar
ln -sf $(build-classpath rhino) lib/rhino-1.7R2.jar
# we don't need this. Jars will be added in script
sed -i 's|.*unjar src.*||' build.xml
# this fails in rhino-js tests for some reasons
rm tests/preserve-case.css
# this fails in JS port of CSSMIN for some reasons
rm tests/jquery-1.6.4.js \
tests/opera-pixel-ratio.css \
tests/preserve-important.css
# TODO add pom file to jargs package see https://bugzilla.redhat.com/show_bug.cgi?id=821123
cp -p %{SOURCE1} pom.xml
sed -i "s|@version@|%{version}|" pom.xml
%pom_xpath_remove "pom:dependencies/pom:dependency[pom:artifactId='jargs']/pom:version"
%pom_xpath_inject "pom:dependencies/pom:dependency[pom:artifactId='jargs']" "
system
$(build-classpath jargs)"
%build
%ant build.jar
# javadoc generation
export CLASSPATH=$(build-classpath jargs rhino)
%javadoc -d javadoc -sourcepath src -subpackages com \
-link %{_javadocdir}/java
pod2man -c '' -r '' %{SOURCE2} %{name}.1
%install
# jars
install -Dpm 644 build/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar
# install script to run yuicompressor
%jpackage_script com.yahoo.platform.yui.compressor.Bootstrap "" "" yuicompressor:jargs:rhino %{name} true
# javadocs
mkdir -p %{buildroot}/%{_javadocdir}/%{name}
cp -rp javadoc/* %{buildroot}/%{_javadocdir}/%{name}
mkdir -p %{buildroot}%{_mavenpomdir}
install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
sed -i "s|@version@|%{version}|" %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
%add_maven_depmap
mkdir -p %{buildroot}%{_mandir}/man1
# fix doc versioned path
sed -i "s|@version@|%{version}|" %{name}.1
install -pm 644 %{name}.1 %{buildroot}%{_mandir}/man1/
%check
cd tests
./suite.sh
%files
%doc LICENSE.TXT README.md doc/CHANGELOG
%{_javadir}/%{name}.jar
%{_bindir}/%{name}
%{_mandir}/man1/*
%{_mavenpomdir}/JPP-%{name}.pom
%{_mavendepmapfragdir}/%{name}
%files javadoc
%doc LICENSE.TXT
%{_javadocdir}/%{name}
%changelog
* Thu May 30 2013 gil cattaneo - 2.4.8-1
- 2.4.8
* Sat May 12 2012 gil cattaneo - 2.4.8-0.2.sha6e2bc23
- add maven pom and manual
* Mon Oct 31 2011 Stanislav Ochotnicky - 2.4.8-0.1.sha6e2bc23
- Correct license utf-8 conversion
- Fix up javadoc generation
- Use proper versioned rhino BR/R
- Add readme and changelog as doc
* Tue Oct 11 2011 Stanislav Ochotnicky - 2.4.7-0.1.sha4c54e628
- Initial version of the package