%global majorversion 2
Name:                metadata-extractor2
Version:             2.11.0
Release:             1
Summary:             Extracts EXIF, IPTC, XMP, ICC and other metadata from image files
License:             ASL 2.0
URL:                 http://drewnoakes.com/code/exif/
Source0:             http://github.com/drewnoakes/metadata-extractor/archive/refs/tags/%{version}.tar.gz
BuildRequires:       maven-local mvn(com.adobe.xmp:xmpcore) mvn(junit:junit)
BuildRequires:       mvn(org.apache.felix:maven-bundle-plugin) mvn(org.sonatype.oss:oss-parent:pom:)
Requires:            javapackages-tools
Provides:            mvn(com.drewnoakes:metadata-extractor) = %{version}-%{release}
BuildArch:           noarch
%description
Metadata Extractor is a straightforward Java library
for reading metadata from image files.

%package javadoc
Summary:             Javadoc for %{name}
%description javadoc
This package contains javadoc for %{name}.

%prep
%setup -q -n metadata-extractor-%{version}
find -name '*.jar' -delete
find -name '*.class' -delete
%pom_remove_plugin org.sonatype.plugins:nexus-staging-maven-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-gpg-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-source-plugin
%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-javadoc-plugin']/pom:executions"
%pom_xpath_set "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-jar-plugin']/pom:configuration/pom:archive/pom:manifest/pom:addClasspath" false
%pom_xpath_inject "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-jar-plugin']/pom:configuration/pom:archive/pom:manifest" "<mainClass>com.drew.imaging.ImageMetadataReader</mainClass>"
%pom_xpath_remove "pom:build/pom:directory"
%pom_xpath_remove "pom:build/pom:outputDirectory"
%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-javadoc-plugin']/pom:configuration/pom:bottom"
%pom_xpath_set "pom:project/pom:packaging" bundle
%pom_add_plugin org.apache.felix:maven-bundle-plugin . "
<extensions>true</extensions>
<executions>
  <execution>
    <id>bundle-manifest</id>
    <phase>process-classes</phase>
    <goals>
      <goal>manifest</goal>
    </goals>
  </execution>
</executions>"
for s in Source/com/drew/lang/GeoLocation.java \
 Source/com/drew/metadata/icc/IccDescriptor.java;do
  native2ascii -encoding UTF8 ${s} ${s}
done
sed -i 's/\r//' LICENSE README.md Resources/javadoc-stylesheet.css
%mvn_file :metadata-extractor %{name}
%mvn_alias :metadata-extractor "drew:metadata-extractor"
%mvn_compat_version ":metadata-extractor" %{majorversion}

%build
%mvn_build

%install
%mvn_install
%jpackage_script com.drew.imaging.ImageMetadataReader "" "" %{name}-%{majorversion}:xmpcore %{name} true

%files -f .mfiles
%{_bindir}/*
%doc README.md
%license LICENSE

%files javadoc -f .mfiles-javadoc
%license LICENSE

%changelog
* Mon May 30 2022 xigaoxinyan <xigaoxinyan@h-partners.com> - 2.11.0-1
- Update to 2.11.0

* Sat Aug 15 2020 shaoqiang kang <kangshaoqiang1@huawei.com> - 2.10.1-1
- Package init
