forbidden-apis/forbidden-apis.spec
2020-08-19 14:32:15 +08:00

78 lines
2.9 KiB
RPMSpec

Name: forbidden-apis
Version: 2.5
Release: 1
Summary: Policeman's Forbidden API Checker
License: ASL 2.0
URL: https://github.com/policeman-tools/forbidden-apis
Source0: https://github.com/policeman-tools/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0: avoid-jarjar-bundling.patch
Patch1: fix-gradle-maven-build.patch
BuildArch: noarch
BuildRequires: gradle-local ivy-local maven-local ant ant-antunit ant-contrib ant-junit
BuildRequires: objectweb-asm plexus-utils maven-plugin-plugin sonatype-oss-parent
%description
Allows to parse Java byte code to find invocations of method/class/field
signatures and fail build (Apache Ant, Apache Maven, or Gradle).
%package javadoc
Summary: Javadoc for %{name}
%description javadoc
This package contains API documentation for %{name}.
%prep
%setup -q
%patch0
%patch1
find . -name "*.jar" -print -delete
find . -name "*.class" -print -delete
sed -i -e '/ivy:configure/d' build.xml
%pom_xpath_remove "target/artifact:pom" build.xml
%pom_xpath_remove "target/artifact:mvn" build.xml
%pom_xpath_remove "target/artifact:install" build.xml
%pom_xpath_inject "target[@name='maven-descriptor']" \
"<exec executable='xmvn'>
<arg value=\"-o\"/>
<arg value=\"-f\"/>
<arg value=\"\${maven-build-dir}/pom-build.xml\"/>
<arg value=\"plugin:helpmojo\"/>
<arg value=\"plugin:descriptor\"/>
<arg value=\"plugin:report\"/>
<arg value=\"-Dinjected.src.dir=src/main/java\"/>
<arg value=\"-Dinjected.output.dir=../../build/main\"/>
<arg value=\"-Dinjected.build.dir=\${maven-build-dir}\"/>
<arg value=\"-Dinjected.maven-plugin-plugin.version=\${maven-plugin-plugin.version}\"/>
</exec>" build.xml
sed -i -e '/maven-ant-tasks/d' ivy.xml
sed -i -e '/uri="antlib:org.apache.maven.artifact.ant/d' build.xml
sed -i -e '/apache-rat/d' ivy.xml
sed -i -e '/uri="antlib:org.apache.rat.anttasks/d' build.xml
%build
ant -Divy.mode=local jar documentation test-junit
%install
%pom_add_dep org.apache.ant:ant:1.7.0:provided build/maven/pom-deploy.xml
%pom_add_dep org.ow2.asm:asm:6.1.1 build/maven/pom-deploy.xml
%pom_add_dep org.ow2.asm:asm-commons:6.1.1 build/maven/pom-deploy.xml
%pom_add_dep org.codehaus.plexus:plexus-utils:1.1 build/maven/pom-deploy.xml
%pom_add_dep commons-cli:commons-cli:1.3.1 build/maven/pom-deploy.xml
%mvn_artifact build/maven/pom-deploy.xml dist/forbiddenapis-2.5.jar
%mvn_install -J build/docs
mkdir -p %{buildroot}%{_sysconfdir}/ant.d
echo "%{name} ant apache-commons-cli objectweb-asm/asm objectweb-asm/asm-commons plexus/utils" > %{name}-ant
install -pm 644 %{name}-ant %{buildroot}%{_sysconfdir}/ant.d/%{name}
%files -f .mfiles
%config(noreplace) %{_sysconfdir}/ant.d/%{name}
%license LICENSE.txt NOTICE.txt
%doc README.md
%files javadoc -f .mfiles-javadoc
%license LICENSE.txt NOTICE.txt
%changelog
* Thu Jul 30 2020 leiju <leiju4@huawei.com> - 2.5-1
- Package init