File maven.spec of Package maven

# spec file for package maven
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           maven-jansi
Version:        3.5.0
Release:        0
Summary:        Native JAnsi libraries bundled with Apache Maven
License:        Apache-2.0
Group:          Development/Tools/Building
Source4:        %{name}-rpmlintrc
BuildRequires:  dos2unix
BuildRequires:  unzip
%if 0%{?suse_version}
BuildRequires:  fdupes
Requires:       java >= 1.6
# Bugfix broken dependencies
%if 0%{?centos_version} == 505 || 0%{?rhel_version} == 505
# maven needs /usr/bin/which to run, but that is not in util-linux on centos5
Requires:       which
%if 0%{?suse_version} == 1110
# SLES-11: maven-wagon needs /usr/lib/, which is not installed by default
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

These libraries are intended to be used only with Apache Maven and should
not be used by other packages.

%package -n maven
BuildArch:      noarch
Summary:        Maven is a software project management and comprehension tool
Recommends:     maven-jansi = %{version}

%description -n maven
A software project management and comprehension tool.
Based on the concept of a project object model (POM), Maven can
manage a project's build, reporting and documentation from a
central piece of information

%setup -q -n apache-maven-%{version}
for winfile in conf/settings.xml bin/m2.conf lib/ext/README.txt; do
	dos2unix $winfile
	chmod a-x $winfile


%if 0%{?suse_version} == 1110
# SLE11:

install -d %{buildroot}%{_datadir}/java/maven/bin
install -p bin/m2.conf %{buildroot}%{_datadir}/java/maven/bin
install -p bin/mvn %{buildroot}%{_datadir}/java/maven/bin
install -p bin/mvnDebug %{buildroot}%{_datadir}/java/maven/bin
install -p bin/mvnyjp %{buildroot}%{_datadir}/java/maven/bin

install -d %{buildroot}%{_datadir}/java/maven/lib
# remove unapplicable jansi-native libs
rm -rf lib/jansi-native/{windows32,windows64,osx}

# keep native libraries for only the platform we build
%if "%{_arch}" == "x86_64"
    rm -rf lib/jansi-native/linux32
    # prevent debug sources from being created
    find lib -name '*.so' | xargs strip
    %if "%{_arch}" == "i586"
        rm -rf lib/jansi-native/linux64
        # prevent debug sources from being created
        find lib -name '*.so' | xargs strip
        rm -rf lib/jansi-native/linux*

cp -R lib/* %{buildroot}%{_datadir}/java/maven/lib

%if 0%{?suse_version}
# create hardlinks for license files to avoid rpmlint error:E: files-duplicated-waste
%fdupes %{buildroot}%{_datadir}/java/maven/lib

install -d %{buildroot}%{_datadir}/java/maven/conf
cp -R conf/* %{buildroot}%{_datadir}/java/maven/conf

install -d %{buildroot}%{_datadir}/java/maven/boot
install -p boot/* %{buildroot}%{_datadir}/java/maven/boot

install -d %{buildroot}%{_prefix}/bin
for binary in mvn mvnDebug mvnyjp; do
	ln -s %{_datadir}/java/maven/bin/$binary %{buildroot}%{_bindir}/

install -d %{buildroot}%{_sysconfdir}/bash_completion.d/
install -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/bash_completion.d/


%files -n maven
%dir %{_datadir}/java/maven
%dir %{_datadir}/java/maven/lib
%config %{_sysconfdir}/bash_completion.d/