Name:          snmp4j
Version:       2.4.1
Release:       1
Summary:       The Object Oriented SNMP API for Java Managers and Agents
License:       Apache 2.0
URL:           http://www.snmp4j.org/
Source0:       https://oosnmp.net/dist/release/org/snmp4j/%{name}/%{version}/%{name}-%{version}-distribution.tar.gz

BuildRequires: maven-local
BuildRequires: mvn(junit:junit)
BuildRequires: mvn(log4j:log4j:1.2.17)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)

BuildArch:     noarch

%description
SNMP4J is an enterprise class free open source and
state-of-the-art SNMP implementation for Java 2SE 1.4 or
later. SNMP4J supports command generation (managers) as
well as command responding (agents). Its clean object
oriented design is inspired by SNMP++, which is a
well-known SNMPv1/v2c/v3 API for C++ (see http://www.agentpp.com).


%package javadoc
Summary:       Javadoc for %{name}

%description javadoc
This package contains javadoc for %{name}.

%prep
%setup -q -n %{name}-%{version}
# cleanup
find -name "*.jar" -delete
find -name "*.class" -delete

# remove wagon-webdav-jackrabbit
%pom_xpath_remove "pom:build/pom:extensions"

# required by Apache Camel
%pom_xpath_remove "pom:plugin[pom:artifactId='maven-jar-plugin']/pom:configuration/pom:excludes"
%pom_xpath_inject "pom:plugin[pom:artifactId='maven-jar-plugin']/pom:configuration" '
<archive>
  <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>'
%pom_add_plugin org.apache.felix:maven-bundle-plugin . '
<extensions>true</extensions>
<configuration>
  <instructions>
    <Export-Package>org.snmp4j.*;version="${project.version}"</Export-Package>
    <Import-Package>javax.crypto*,javax.net.ssl,javax.security*,org.apache.log4j*;resolution:=optional,*</Import-Package>
  </instructions>
</configuration>
<executions>
  <execution>
    <id>bundle-manifest</id>
    <phase>process-classes</phase>
    <goals>
      <goal>manifest</goal>
    </goals>
  </execution>
</executions>'

%pom_remove_plugin :maven-assembly-plugin
%pom_remove_plugin :maven-source-plugin

for s in src/main/java/org/snmp4j/PDUv1.java \
 src/main/java/org/snmp4j/Snmp.java \
 src/main/java/org/snmp4j/SNMP4JSettings.java \
 src/main/java/org/snmp4j/mp/MessageProcessingModel.java \
 src/main/java/org/snmp4j/mp/MPv3.java \
 src/main/java/org/snmp4j/security/TSM.java \
 src/main/java/org/snmp4j/security/USM.java \
 src/main/java/org/snmp4j/security/UsmUser.java \
 src/main/java/org/snmp4j/transport/DefaultSshTransportMapping.java; do
  native2ascii -encoding UTF8 ${s} ${s}
done

%pom_change_dep :log4j ::1.2.17

# Convert from dos to unix line ending
for file in CHANGES.txt \
 LICENSE-2_0.txt \
 NOTICE \
 snmp4j_usage.txt \
 mibs/OOSNMP-USM-MIB.txt \
 mibs/SNMP-USM-HMAC-SHA2-MIB.txt
do
 sed -i.orig 's|\r||g' $file
 touch -r $file.orig $file
 rm $file.orig
done

# AssertionFailedError: null
rm src/test/java/org/snmp4j/SnmpTest.java

%mvn_file :%{name} %{name}
%mvn_alias :%{name} "org.apache.servicemix.bundles:org.apache.servicemix.bundles.snmp4j"

%build

%mvn_build

%install
%mvn_install

%files -f .mfiles
%doc CHANGES.txt snmp4j_usage.txt mibs
%license LICENSE-2_0.txt NOTICE

%files javadoc -f .mfiles-javadoc
%license LICENSE-2_0.txt NOTICE

%changelog
* Thu Aug 19 2021 Python_Bot <Python_Bot@openeuler.org> - 2.4.1-1
- Initial package

