Juan Hernandez has uploaded a new change for review.

Change subject: packaging: Distribution specific RPM spec files
......................................................................

packaging: Distribution specific RPM spec files

Currently we use a single .spec file template for all the supported
distributions. To support all the distributions it contains many "%if"
statements that change behaviour. This makes it convoluted and
difficult to maintain. To avoid this issue this patch introduces
different spec file templates, one for each supported distribution.

Change-Id: I3ee2acddca2e42c11d5679fb4b8c5931c91ac986
Signed-off-by: Juan Hernandez <[email protected]>
(cherry picked from commit b5559822a65004f13b1b6a2ad19988fa32cebeb0)
---
M ovirt-engine-sdk-java/Makefile
M ovirt-engine-sdk-java/README.md
R ovirt-engine-sdk-java/spec.el6.in
A ovirt-engine-sdk-java/spec.el7.centos.in
C ovirt-engine-sdk-java/spec.el7.in
C ovirt-engine-sdk-java/spec.fc20.in
C ovirt-engine-sdk-java/spec.fc21.in
A ovirt-engine-sdk-java/version.py
8 files changed, 215 insertions(+), 449 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk-java 
refs/changes/39/36839/1

diff --git a/ovirt-engine-sdk-java/Makefile b/ovirt-engine-sdk-java/Makefile
index fce759a..99565a7 100644
--- a/ovirt-engine-sdk-java/Makefile
+++ b/ovirt-engine-sdk-java/Makefile
@@ -1,16 +1,25 @@
 all: rpm
 
-rpmrelease:=0.1$(rpmsuffix)
-rpmversion=3.5.0.6
+pomversion=$(shell ./version.py --pom)
+rpmversion=$(shell ./version.py --rpm)
+rpmdist=$(shell rpm --eval '%dist')
+rpmrelease=0.2$(rpmsuffix)$(rpmdist)
+
 RPMTOP=$(shell bash -c "pwd -P")/rpmtop
 NAME=ovirt-engine-sdk-java
 SPEC=$(NAME).spec
 
-TARBALL=$(NAME)-$(rpmversion).tar.gz
-SRPM=$(RPMTOP)/SRPMS/$(NAME)-$(rpmversion)-$(rpmrelease)*.src.rpm
+TARBALL=$(NAME)-$(pomversion).tar.gz
+SRPM=$(RPMTOP)/SRPMS/$(NAME)-$(rpmversion)-$(rpmrelease).src.rpm
 
-$(NAME).spec: $(NAME).spec.in
-       sed 's/^Version:.*/Version: $(rpmversion)/;s/^Release:.*/Release: 
$(rpmrelease)%{dist}/;s/%{release}/$(rpmrelease)/' $(NAME).spec.in > $(SPEC)
+$(SPEC): spec$(rpmdist).in
+       sed \
+               -e 's/@POM_VERSION@/$(pomversion)/g' \
+               -e 's/@RPM_VERSION@/$(rpmversion)/g' \
+               -e 's/@RPM_RELEASE@/$(rpmrelease)/g' \
+               -e 's/@TARBALL@/$(TARBALL)/g' \
+               < $< \
+               > $@
 
 .PHONY: dist tarball
 tarball: dist
diff --git a/ovirt-engine-sdk-java/README.md b/ovirt-engine-sdk-java/README.md
index 101dacd..9568556 100644
--- a/ovirt-engine-sdk-java/README.md
+++ b/ovirt-engine-sdk-java/README.md
@@ -101,7 +101,7 @@
 download the updated metadata. For example:
 
     sdk: Regenerate against the latest API
-    
+
     This patch regenerates the SDK using the latest API obtained from
     the engine built from commit fffffff, corresponding to tag
     ovirt-engine-3.5.7.
@@ -117,14 +117,14 @@
 is increased for each release, and reset to 0 when the other three numbers
 change.
 
+The `pom.xml` files need to be changed to remove the `-SNAPSHOT` suffix from
+the version number.
+
 Once the next release number is decided the `Makefile` *may* need to be changed
-to reflect that number and also change the RPM release number to `1`.
+to set the RPM release number to `1`.
 
-The `.spec.in` and `pom.xml` files need to be changed to remove the `-SNAPSHOT`
-suffix from the version number.
-
-The `%changelog` in the `.spec.in` should be updated so that it contains short
-descriptions of bugs fixed and relevant changes.
+The `%changelog` in all the `spec.*.in` should be updated so that it contains
+short descriptions of bugs fixed and relevant changes.
 
 Look at commit ea06203 (with command, `git show ea06203`) for a typical release
 commit.
@@ -135,11 +135,10 @@
     $ git push origin 3.5.7.0 HEAD:refs/heads/sdk_3.5
 
 To finish the release you need to do an additional change that prepares for the
-next development iteration, basically setting the version number to the next
-expected one in the `Makefile` and in `setup.py` and adding the `-SNAPSHOT`
-suffix. Commit e9b76aa is a good example. Note that this change will usually
-contain the correct next version number, so usually there is no need to change
-it when doing next release.
+next development iteration, basically adding the `-SNAPSHOT` suffix in the
+`pom.xml` file. Commit e9b76aa is a good example. Note that this file will
+usually already contain the correct next version number, so usually there is no
+need to change the version number itself, only add the `-SNAPSHOT` suffix.
 
 Packaging
 ---------
@@ -153,3 +152,7 @@
 
 The generated `.rpm` file will be available in the `rpmtop/RPMS/noarch`
 directory.
+
+Note that there are several `spec.*.in` templates, one for each supported
+distribution. Whenever making a packaging change remember to make it in
+all the relevant templates.
diff --git a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in 
b/ovirt-engine-sdk-java/spec.el6.in
similarity index 82%
rename from ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
rename to ovirt-engine-sdk-java/spec.el6.in
index f84a409..26b98f9 100644
--- a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
+++ b/ovirt-engine-sdk-java/spec.el6.in
@@ -1,100 +1,34 @@
-%global     package_version 3.5.0.6
-%global     package_maven_version 3.5.0.6-SNAPSHOT
-%global     _javadocname javadoc
+%global pom_version @POM_VERSION@
 
-%if 0%{?fedora}
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%endif
-
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%else
-%global     install_poms 0
-%global     require_maven 0
-%global     require_java_dep 0
-%global     mvn mvn
-%global     mvnout target
-%endif
-%endif
-
-Name:           ovirt-engine-sdk-java
-Version:        %{package_version}
-Release:        1%{?dist}
-Summary:        oVirt Engine Software Development Kit (Java)
-Group:          Development/Libraries
-License:        ASL 2.0
-URL:            http://ovirt.org
-Source0:        http://ovirt.org/releases/stable/src/%{name}-%{version}.tar.gz
+Name: ovirt-engine-sdk-java
+Version: @RPM_VERSION@
+Release: @RPM_RELEASE@
+Summary: oVirt Engine Software Development Kit (Java)
+Group: Development/Libraries
+License: ASL 2.0
+URL: http://ovirt.org
+Source: http://ovirt.org/releases/stable/src/@TARBALL@
 
 BuildArch: noarch
 
-%if 0%{?fedora}
-BuildRequires:  java-devel
-%endif
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-BuildRequires:  java-devel
-%else
-BuildRequires:  java7-devel
-%endif
-%endif
-BuildRequires:  jpackage-utils
+BuildRequires: java7-devel
+BuildRequires: jpackage-utils
 
-%if %{require_java_dep}
-BuildRequires:  apache-commons-logging
-BuildRequires:  apache-commons-compress
-BuildRequires:  httpcomponents-client >= 4.2
-BuildRequires:  junit
-BuildRequires:  xerces-j2
-BuildRequires:  maven-local
-%endif
-
-%if %{require_maven}
-BuildRequires:  maven
-BuildRequires:  maven-compiler-plugin
-BuildRequires:  maven-install-plugin
-BuildRequires:  maven-jar-plugin
-BuildRequires:  maven-javadoc-plugin
-BuildRequires:  maven-source-plugin
-%endif
-
-Requires: java
 Requires: httpcomponents-client >= 4.2
-Requires: log4j
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%else
 Requires: jakarta-commons-beanutils
 Requires: jakarta-commons-codec
 Requires: jakarta-commons-logging
-%endif
-%endif
-%if 0%{?fedora}
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%endif
+Requires: java
+Requires: jpackage-utils
 
 %description
 This package contains The oVirt-Engine Java Software Development Kit.
 With this package, custom java software can be built for oVirt-Engine.
 
 %package javadoc
-Summary:    Javadocs for %{name}
-Group:      Documentation
-Requires:   jpackage-utils
+Summary: Javadocs for %{name}
+Group: Documentation
+Requires: jpackage-utils
 
 %description javadoc
 This package contains the API documentation for %{name}.
@@ -103,36 +37,24 @@
 %setup -q -n %{name}
 
 %build
-%{mvn} install javadoc:aggregate
+mvn install javadoc:aggregate
 
 %install
-install -d -m 755 "%{buildroot}%{_javadir}/%{name}"
-install -d -m 755 "%{buildroot}%{_mavenpomdir}"
+mkdir -p %{buildroot}%{_javadir}/%{name}
+cp target/%{name}-%{pom_version}.jar 
%{buildroot}%{_javadir}/%{name}/%{name}.jar
 
-install -pm 644 "%{mvnout}/%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}"
-ln -s "%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}/%{name}.jar"
-
-%if %{install_poms}
-install -pm 644 "pom.xml" "%{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}.pom"
-%add_maven_depmap "JPP.%{name}-%{name}.pom" "%{name}/%{name}.jar"
-%endif
-
-mkdir -p "%{buildroot}%{_javadocdir}/%{name}"
-install -pm 644 
"%{mvnout}/%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}"
-ln -s "%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}/%{name}-%{_javadocname}.jar"
+mkdir -p %{buildroot}%{_javadocdir}/%{name}
+cp target/%{name}-%{pom_version}-javadoc.jar 
%{buildroot}%{_javadocdir}/%{name}/%{name}-javadoc.jar
 
 %files
-%{_javadir}/%{name}/
-%if %{install_poms}
-%{_mavenpomdir}/JPP.%{name}-%{name}.pom
-%{_mavendepmapfragdir}/%{name}
-%endif
+%{_javadir}/%{name}
 %doc AUTHORS.md
 %doc README.md
 %doc LICENSE.md
 
 %files javadoc
 %{_javadocdir}/%{name}
+%doc LICENSE.md
 
 %changelog
 * Wed Sep 10 2014 Juan Hernandez <[email protected]> - 3.5.0.5-1
diff --git a/ovirt-engine-sdk-java/spec.el7.centos.in 
b/ovirt-engine-sdk-java/spec.el7.centos.in
new file mode 120000
index 0000000..e2b7310
--- /dev/null
+++ b/ovirt-engine-sdk-java/spec.el7.centos.in
@@ -0,0 +1 @@
+spec.el7.in
\ No newline at end of file
diff --git a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in 
b/ovirt-engine-sdk-java/spec.el7.in
similarity index 81%
copy from ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
copy to ovirt-engine-sdk-java/spec.el7.in
index f84a409..1325bf0 100644
--- a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
+++ b/ovirt-engine-sdk-java/spec.el7.in
@@ -1,100 +1,26 @@
-%global     package_version 3.5.0.6
-%global     package_maven_version 3.5.0.6-SNAPSHOT
-%global     _javadocname javadoc
-
-%if 0%{?fedora}
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%endif
-
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%else
-%global     install_poms 0
-%global     require_maven 0
-%global     require_java_dep 0
-%global     mvn mvn
-%global     mvnout target
-%endif
-%endif
-
-Name:           ovirt-engine-sdk-java
-Version:        %{package_version}
-Release:        1%{?dist}
-Summary:        oVirt Engine Software Development Kit (Java)
-Group:          Development/Libraries
-License:        ASL 2.0
-URL:            http://ovirt.org
-Source0:        http://ovirt.org/releases/stable/src/%{name}-%{version}.tar.gz
+Name: ovirt-engine-sdk-java
+Version: @RPM_VERSION@
+Release: @RPM_RELEASE@
+Summary: oVirt Engine Software Development Kit (Java)
+Group: Development/Libraries
+License: ASL 2.0
+URL: http://ovirt.org
+Source: http://ovirt.org/releases/stable/src/@TARBALL@
 
 BuildArch: noarch
 
-%if 0%{?fedora}
-BuildRequires:  java-devel
-%endif
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-BuildRequires:  java-devel
-%else
-BuildRequires:  java7-devel
-%endif
-%endif
-BuildRequires:  jpackage-utils
-
-%if %{require_java_dep}
-BuildRequires:  apache-commons-logging
-BuildRequires:  apache-commons-compress
-BuildRequires:  httpcomponents-client >= 4.2
-BuildRequires:  junit
-BuildRequires:  xerces-j2
-BuildRequires:  maven-local
-%endif
-
-%if %{require_maven}
-BuildRequires:  maven
-BuildRequires:  maven-compiler-plugin
-BuildRequires:  maven-install-plugin
-BuildRequires:  maven-jar-plugin
-BuildRequires:  maven-javadoc-plugin
-BuildRequires:  maven-source-plugin
-%endif
-
-Requires: java
-Requires: httpcomponents-client >= 4.2
-Requires: log4j
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%else
-Requires: jakarta-commons-beanutils
-Requires: jakarta-commons-codec
-Requires: jakarta-commons-logging
-%endif
-%endif
-%if 0%{?fedora}
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%endif
+BuildRequires: apache-commons-beanutils
+BuildRequires: httpcomponents-client
+BuildRequires: log4j
+BuildRequires: maven-local
 
 %description
 This package contains The oVirt-Engine Java Software Development Kit.
 With this package, custom java software can be built for oVirt-Engine.
 
 %package javadoc
-Summary:    Javadocs for %{name}
-Group:      Documentation
-Requires:   jpackage-utils
+Summary: Javadocs for %{name}
+Group: Documentation
 
 %description javadoc
 This package contains the API documentation for %{name}.
@@ -103,36 +29,20 @@
 %setup -q -n %{name}
 
 %build
-%{mvn} install javadoc:aggregate
+%mvn_build
 
 %install
-install -d -m 755 "%{buildroot}%{_javadir}/%{name}"
-install -d -m 755 "%{buildroot}%{_mavenpomdir}"
+%mvn_install
 
-install -pm 644 "%{mvnout}/%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}"
-ln -s "%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}/%{name}.jar"
-
-%if %{install_poms}
-install -pm 644 "pom.xml" "%{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}.pom"
-%add_maven_depmap "JPP.%{name}-%{name}.pom" "%{name}/%{name}.jar"
-%endif
-
-mkdir -p "%{buildroot}%{_javadocdir}/%{name}"
-install -pm 644 
"%{mvnout}/%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}"
-ln -s "%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}/%{name}-%{_javadocname}.jar"
-
-%files
-%{_javadir}/%{name}/
-%if %{install_poms}
-%{_mavenpomdir}/JPP.%{name}-%{name}.pom
-%{_mavendepmapfragdir}/%{name}
-%endif
+%files -f .mfiles
+%{_javadir}/%{name}
 %doc AUTHORS.md
 %doc README.md
 %doc LICENSE.md
 
-%files javadoc
+%files javadoc -f .mfiles-javadoc
 %{_javadocdir}/%{name}
+%doc LICENSE.md
 
 %changelog
 * Wed Sep 10 2014 Juan Hernandez <[email protected]> - 3.5.0.5-1
diff --git a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in 
b/ovirt-engine-sdk-java/spec.fc20.in
similarity index 81%
copy from ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
copy to ovirt-engine-sdk-java/spec.fc20.in
index f84a409..1325bf0 100644
--- a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
+++ b/ovirt-engine-sdk-java/spec.fc20.in
@@ -1,100 +1,26 @@
-%global     package_version 3.5.0.6
-%global     package_maven_version 3.5.0.6-SNAPSHOT
-%global     _javadocname javadoc
-
-%if 0%{?fedora}
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%endif
-
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%else
-%global     install_poms 0
-%global     require_maven 0
-%global     require_java_dep 0
-%global     mvn mvn
-%global     mvnout target
-%endif
-%endif
-
-Name:           ovirt-engine-sdk-java
-Version:        %{package_version}
-Release:        1%{?dist}
-Summary:        oVirt Engine Software Development Kit (Java)
-Group:          Development/Libraries
-License:        ASL 2.0
-URL:            http://ovirt.org
-Source0:        http://ovirt.org/releases/stable/src/%{name}-%{version}.tar.gz
+Name: ovirt-engine-sdk-java
+Version: @RPM_VERSION@
+Release: @RPM_RELEASE@
+Summary: oVirt Engine Software Development Kit (Java)
+Group: Development/Libraries
+License: ASL 2.0
+URL: http://ovirt.org
+Source: http://ovirt.org/releases/stable/src/@TARBALL@
 
 BuildArch: noarch
 
-%if 0%{?fedora}
-BuildRequires:  java-devel
-%endif
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-BuildRequires:  java-devel
-%else
-BuildRequires:  java7-devel
-%endif
-%endif
-BuildRequires:  jpackage-utils
-
-%if %{require_java_dep}
-BuildRequires:  apache-commons-logging
-BuildRequires:  apache-commons-compress
-BuildRequires:  httpcomponents-client >= 4.2
-BuildRequires:  junit
-BuildRequires:  xerces-j2
-BuildRequires:  maven-local
-%endif
-
-%if %{require_maven}
-BuildRequires:  maven
-BuildRequires:  maven-compiler-plugin
-BuildRequires:  maven-install-plugin
-BuildRequires:  maven-jar-plugin
-BuildRequires:  maven-javadoc-plugin
-BuildRequires:  maven-source-plugin
-%endif
-
-Requires: java
-Requires: httpcomponents-client >= 4.2
-Requires: log4j
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%else
-Requires: jakarta-commons-beanutils
-Requires: jakarta-commons-codec
-Requires: jakarta-commons-logging
-%endif
-%endif
-%if 0%{?fedora}
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%endif
+BuildRequires: apache-commons-beanutils
+BuildRequires: httpcomponents-client
+BuildRequires: log4j
+BuildRequires: maven-local
 
 %description
 This package contains The oVirt-Engine Java Software Development Kit.
 With this package, custom java software can be built for oVirt-Engine.
 
 %package javadoc
-Summary:    Javadocs for %{name}
-Group:      Documentation
-Requires:   jpackage-utils
+Summary: Javadocs for %{name}
+Group: Documentation
 
 %description javadoc
 This package contains the API documentation for %{name}.
@@ -103,36 +29,20 @@
 %setup -q -n %{name}
 
 %build
-%{mvn} install javadoc:aggregate
+%mvn_build
 
 %install
-install -d -m 755 "%{buildroot}%{_javadir}/%{name}"
-install -d -m 755 "%{buildroot}%{_mavenpomdir}"
+%mvn_install
 
-install -pm 644 "%{mvnout}/%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}"
-ln -s "%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}/%{name}.jar"
-
-%if %{install_poms}
-install -pm 644 "pom.xml" "%{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}.pom"
-%add_maven_depmap "JPP.%{name}-%{name}.pom" "%{name}/%{name}.jar"
-%endif
-
-mkdir -p "%{buildroot}%{_javadocdir}/%{name}"
-install -pm 644 
"%{mvnout}/%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}"
-ln -s "%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}/%{name}-%{_javadocname}.jar"
-
-%files
-%{_javadir}/%{name}/
-%if %{install_poms}
-%{_mavenpomdir}/JPP.%{name}-%{name}.pom
-%{_mavendepmapfragdir}/%{name}
-%endif
+%files -f .mfiles
+%{_javadir}/%{name}
 %doc AUTHORS.md
 %doc README.md
 %doc LICENSE.md
 
-%files javadoc
+%files javadoc -f .mfiles-javadoc
 %{_javadocdir}/%{name}
+%doc LICENSE.md
 
 %changelog
 * Wed Sep 10 2014 Juan Hernandez <[email protected]> - 3.5.0.5-1
diff --git a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in 
b/ovirt-engine-sdk-java/spec.fc21.in
similarity index 81%
copy from ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
copy to ovirt-engine-sdk-java/spec.fc21.in
index f84a409..9f7af16 100644
--- a/ovirt-engine-sdk-java/ovirt-engine-sdk-java.spec.in
+++ b/ovirt-engine-sdk-java/spec.fc21.in
@@ -1,100 +1,26 @@
-%global     package_version 3.5.0.6
-%global     package_maven_version 3.5.0.6-SNAPSHOT
-%global     _javadocname javadoc
-
-%if 0%{?fedora}
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%endif
-
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-%global     install_poms 1
-%global     require_maven 1
-%global     require_java_dep 1
-%global     mvn xmvn
-%global     mvnout target
-%else
-%global     install_poms 0
-%global     require_maven 0
-%global     require_java_dep 0
-%global     mvn mvn
-%global     mvnout target
-%endif
-%endif
-
-Name:           ovirt-engine-sdk-java
-Version:        %{package_version}
-Release:        1%{?dist}
-Summary:        oVirt Engine Software Development Kit (Java)
-Group:          Development/Libraries
-License:        ASL 2.0
-URL:            http://ovirt.org
-Source0:        http://ovirt.org/releases/stable/src/%{name}-%{version}.tar.gz
+Name: ovirt-engine-sdk-java
+Version: @RPM_VERSION@
+Release: @RPM_RELEASE@
+Summary: oVirt Engine Software Development Kit (Java)
+Group: Development/Libraries
+License: ASL 2.0
+URL: http://ovirt.org
+Source: http://ovirt.org/releases/stable/src/@TARBALL@
 
 BuildArch: noarch
 
-%if 0%{?fedora}
-BuildRequires:  java-devel
-%endif
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-BuildRequires:  java-devel
-%else
-BuildRequires:  java7-devel
-%endif
-%endif
-BuildRequires:  jpackage-utils
-
-%if %{require_java_dep}
-BuildRequires:  apache-commons-logging
-BuildRequires:  apache-commons-compress
-BuildRequires:  httpcomponents-client >= 4.2
-BuildRequires:  junit
-BuildRequires:  xerces-j2
-BuildRequires:  maven-local
-%endif
-
-%if %{require_maven}
-BuildRequires:  maven
-BuildRequires:  maven-compiler-plugin
-BuildRequires:  maven-install-plugin
-BuildRequires:  maven-jar-plugin
-BuildRequires:  maven-javadoc-plugin
-BuildRequires:  maven-source-plugin
-%endif
-
-Requires: java
-Requires: httpcomponents-client >= 4.2
-Requires: log4j
-%if 0%{?rhel}
-%if 0%{?rhel} >= 7
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%else
-Requires: jakarta-commons-beanutils
-Requires: jakarta-commons-codec
-Requires: jakarta-commons-logging
-%endif
-%endif
-%if 0%{?fedora}
-Requires: apache-commons-beanutils
-Requires: apache-commons-codec
-Requires: apache-commons-logging
-%endif
+BuildRequires: apache-commons-beanutils
+BuildRequires: httpcomponents-client
+BuildRequires: log4j12
+BuildRequires: maven-local
 
 %description
 This package contains The oVirt-Engine Java Software Development Kit.
 With this package, custom java software can be built for oVirt-Engine.
 
 %package javadoc
-Summary:    Javadocs for %{name}
-Group:      Documentation
-Requires:   jpackage-utils
+Summary: Javadocs for %{name}
+Group: Documentation
 
 %description javadoc
 This package contains the API documentation for %{name}.
@@ -103,36 +29,20 @@
 %setup -q -n %{name}
 
 %build
-%{mvn} install javadoc:aggregate
+%mvn_build
 
 %install
-install -d -m 755 "%{buildroot}%{_javadir}/%{name}"
-install -d -m 755 "%{buildroot}%{_mavenpomdir}"
+%mvn_install
 
-install -pm 644 "%{mvnout}/%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}"
-ln -s "%{name}-%{package_maven_version}.jar" 
"%{buildroot}%{_javadir}/%{name}/%{name}.jar"
-
-%if %{install_poms}
-install -pm 644 "pom.xml" "%{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}.pom"
-%add_maven_depmap "JPP.%{name}-%{name}.pom" "%{name}/%{name}.jar"
-%endif
-
-mkdir -p "%{buildroot}%{_javadocdir}/%{name}"
-install -pm 644 
"%{mvnout}/%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}"
-ln -s "%{name}-%{package_maven_version}-%{_javadocname}.jar" 
"%{buildroot}%{_javadocdir}/%{name}/%{name}-%{_javadocname}.jar"
-
-%files
-%{_javadir}/%{name}/
-%if %{install_poms}
-%{_mavenpomdir}/JPP.%{name}-%{name}.pom
-%{_mavendepmapfragdir}/%{name}
-%endif
+%files -f .mfiles
+%{_javadir}/%{name}
 %doc AUTHORS.md
 %doc README.md
 %doc LICENSE.md
 
-%files javadoc
+%files javadoc -f .mfiles-javadoc
 %{_javadocdir}/%{name}
+%doc LICENSE.md
 
 %changelog
 * Wed Sep 10 2014 Juan Hernandez <[email protected]> - 3.5.0.5-1
diff --git a/ovirt-engine-sdk-java/version.py b/ovirt-engine-sdk-java/version.py
new file mode 100755
index 0000000..00dec6f
--- /dev/null
+++ b/ovirt-engine-sdk-java/version.py
@@ -0,0 +1,101 @@
+#!/usr/bin/python
+
+import lxml.etree
+import optparse
+import os
+import re
+import sys
+
+
+def main():
+    # Create the command line parser:
+    usage = "Usage: %prog [OPTIONS]..."
+    parser = optparse.OptionParser(usage)
+    parser.description = \
+        "A simple tool to extract version numbers from the POM file."
+
+    # Help option:
+    help = parser.get_option("--help")
+    help.help = "Show this help message and exit."
+
+    # Option to request the POM version:
+    parser.add_option(
+        "--pom",
+        dest="pom",
+        action="store_true",
+        default=False,
+        help=(
+            "Extract the version from the POM."
+        )
+    )
+
+    # Option to request the RPM version:
+    parser.add_option(
+        "--rpm",
+        dest="rpm",
+        action="store_true",
+        default=False,
+        help=(
+            "Calculate the RPM version from the POM version, removing the "
+            "SNAPSHOT suffix if required."
+        )
+    )
+
+    # Parse the command line:
+    options, args = parser.parse_args()
+
+    # Check that the given options don't conflict (only one of --pom or --rpm
+    # can be specified):
+    if options.pom and options.rpm:
+        parser.print_usage()
+        print("Only one of the --pom and --rpm optios is allowed.")
+        sys.exit(1)
+
+    # Check that at least one of the required options has been specified:
+    if not options.pom and not options.rpm:
+        parser.print_usage()
+        print("At least one of the --pom or --rpm options must be used.")
+        sys.exit(1)
+
+    # Check that the POM file exists:
+    pom_path = "pom.xml"
+    if not os.path.exists(pom_path):
+        print("The POM file \"%s\" doesn't exist." % pom_path)
+        sys.exit(1)
+
+    # Parse the POM document:
+    try:
+        pom_document = lxml.etree.parse(pom_path)
+    except lxml.etree.XMLSyntaxError:
+        print("Can't parse POM file \"%s\"." % pom_path)
+        sys.exit(1)
+
+    # Extract the version number:
+    namespaces = {
+        "pom": "http://maven.apache.org/POM/4.0.0";,
+    }
+    version_nodes = pom_document.xpath(
+        "/pom:project/pom:version",
+        namespaces=namespaces
+    )
+    if not version_nodes:
+        print("Can't find version number inside POM file \"%s\"." % pom_path)
+        sys.exit(1)
+    version_node = version_nodes[0]
+    pom_version = version_node.text
+
+    # Calculate the RPM version number, removing the SNAPSHOT suffix if needed:
+    rpm_version = re.sub(r"-SNAPSHOT$", "", pom_version)
+
+    # Output the requested data:
+    if options.pom:
+        print(pom_version)
+    elif options.rpm:
+        print(rpm_version)
+
+    # Done
+    sys.exit(0)
+
+
+if __name__ == "__main__":
+    main()


-- 
To view, visit http://gerrit.ovirt.org/36839
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ee2acddca2e42c11d5679fb4b8c5931c91ac986
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk-java
Gerrit-Branch: sdk_3.5
Gerrit-Owner: Juan Hernandez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to