Files
mime-util/mime-util.spec

104 lines
3.3 KiB
RPMSpec

#
# spec file for package mime-util
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
Name: mime-util
Version: 2.1.3
Release: 0
Summary: Mime Type Detection Utility
License: Apache-2.0
Group: Development/Libraries/Java
URL: https://sourceforge.net/projects/%{name}/
Source0: https://sourceforge.net/projects/%{name}/files/%{name}/%{name}-%{version}/%{name}-%{version}-sources.jar
Source1: https://repo1.maven.org/maven2/eu/medsea/mimeutil/%{name}/%{version}/%{name}-%{version}.pom
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
BuildRequires: javapackages-local >= 6
BuildRequires: slf4j
BuildRequires: unzip
BuildArch: noarch
%description
Enable Java programs to detect MIME types based on file extensions, magic data
and content sniffing. Supports detection from java.io.File,
java.io.InputStream, java.net.URL and byte arrays.
%package javadoc
Summary: API documentation for %{name}
%description javadoc
API documentation for %{name}.
%prep
%setup -q -c
rm -rf META-INF
dos2unix $(find -name \*.java -or -name \*.txt)
%build
mkdir -p src/main/java
mv eu mime.cache src/main/java
mkdir -p target/classes
javac \
%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 9}%{!?pkg_vcmp:0}
--release 8 \
%else
-source 8 -target 8 \
%endif
-encoding latin1 -sourcepath src/main/java -d target/classes -cp $(build-classpath slf4j/api):src/main/java $(find src/main/java -name \*.java)
cp src/main/java/mime.cache target/classes
mkdir -p target/classes/eu/medsea/mimeutil
cp src/main/java/eu/medsea/mimeutil/{magic.mime,mime-types.properties} target/classes/eu/medsea/mimeutil
jar --create --verbose \
%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 17}%{!?pkg_vcmp:0}
--date="$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ)" \
%endif
--file=%{name}-%{version}.jar -C target/classes .
javadoc -encoding latin1 \
-notimestamp \
-source 8 \
-d target/apidocs \
-sourcepath src/main/java \
-cp $(build-classpath slf4j/api):. \
-Xdoclint:none \
eu.medsea.{mimeutil{,.{detector,handler}},util}
%install
# jar
install -dm 0755 %{buildroot}%{_javadir}
install -pm 0644 %{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar
# pom
install -dm 0755 %{buildroot}%{_mavenpomdir}
%{mvn_install_pom} %{SOURCE1} %{buildroot}%{_mavenpomdir}/%{name}.pom
%add_maven_depmap %{name}.pom %{name}.jar
# javadoc
install -dm 0755 %{buildroot}%{_javadocdir}/%{name}
cp -pr target/apidocs/* %{buildroot}%{_javadocdir}/%{name}
%fdupes %{buildroot}%{_javadocdir}/%{name}
%files -f .mfiles
%doc README.txt
%license LICENSE.txt
%files javadoc
%{_javadocdir}/%{name}
%license LICENSE.txt
%changelog