# Copyright (c) 2011, Red Hat, Inc
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the <ORGANIZATION> nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Stanislav Ochotnicky <sochotnicky@redhat.com>
#          [your name here]


#==============================================================================
#
# add_maven_depmap is simplified version of jpackage-style add_to_maven_depmap
# -f addition to fragment name
# -a is "g1:a1,g2:a2" formatted string with additional depmaps (groupId:artifactId,...)
# %1 is the pom filename relative to mavenpomdir
# %2 is the path to jar file (when omitted we deal with parent pom file without jar)
#
# add_maven_depmap automatically parses pom file and it will fail with incorrect pom
# or jar filename
#

%add_maven_depmap(f:a:) \
install -dm 755 $RPM_BUILD_ROOT/%{_mavendepmapfragdir}\
_jpath="jar_missing_in_jar_paths" \
if [ -f %{buildroot}/%{_javadir}/%2 ]; then \
	_jpath="%{buildroot}/%{_javadir}/%2" \
elif [ -f %{buildroot}/%{_javajnidir}/%2 ]; then \
	_jpath="%{buildroot}/%{_javajnidir}/%2" \
elif [ -f %{buildroot}/%{_jnidir}/%2 ]; then \
	_jpath="%{buildroot}/%{_jnidir}/%2" \
fi \
%{_datadir}/java-utils/maven_depmap %{-a} \\\
          %{buildroot}%{_mavendepmapfragdir}/%{name}%{-f*:-%{-f*}} \\\
          %{buildroot}%{_mavenpomdir}/%1 \\\
%if %# == 2 \
          "${_jpath}" \\\
%endif \
\
%{nil}

#==============================================================================


