diff --git a/.gitignore b/.gitignore
index 336ae31..bab2310 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-/postgresql-jdbc-9.4-1200.src.tar.gz
+/REL9.4.1209.tar.gz
+/REL1.0.8.tar.gz
diff --git a/postgresql-jdbc.spec b/postgresql-jdbc.spec
index 5ba0252..d00c976 100644
--- a/postgresql-jdbc.spec
+++ b/postgresql-jdbc.spec
@@ -26,37 +26,56 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
+
+
+# Configuration for rpmbuild, might be specified by options
+# like e.g. 'rpmbuild --define "runselftest 0"'.
+
+%{!?runselftest:%global runselftest 1}
+
%global section devel
-%global upstreamrel 1200
-%global upstreamver 9.4-%{upstreamrel}
+%global upstreamrel 1209
+%global upstreammajor 9.4
+%global source_path pgjdbc/src/main/java/org/postgresql
+%global parent_ver 1.0.8
+%global parent_poms_builddir ./pgjdbc-parent-poms
+
+%global pgjdbc_mvn_options -DwaffleEnabled=false -DosgiEnabled=false \\\
+ -DexcludePackageNames=org.postgresql.osgi:org.postgresql.sspi
Summary: JDBC driver for PostgreSQL
Name: postgresql-jdbc
-Version: 9.4.%{upstreamrel}
-Release: 3%{?dist}
+Version: %upstreammajor.%{upstreamrel}
+Release: 1%{?dist}
# ASL 2.0 applies only to postgresql-jdbc.pom file, the rest is BSD
License: BSD and ASL 2.0
Group: Applications/Databases
URL: http://jdbc.postgresql.org/
-Source0: http://jdbc.postgresql.org/download/%{name}-%{upstreamver}.src.tar.gz
-# originally http://repo2.maven.org/maven2/postgresql/postgresql/8.4-701.jdbc4/postgresql-8.4-701.jdbc4.pom:
-Source1: %{name}.pom
+Source0: https://github.com/pgjdbc/pgjdbc/archive/REL%version.tar.gz
+Source1: postgres-testing.sh
-# Revert back fix for travis build which breaks our ant-build for version 1.9.2
-# & 1.9.4.
-# ~> downstream
-# ~> 1118667
-Patch0: postgresql-jdbc-9.3-1102-revert-88b9a034.patch
+# Upstream moved parent pom.xml into separate project (even though there is only
+# one dependant project on it?). Let's try to not complicate packaging by
+# having separate spec file for it, too.
+Source2: https://github.com/pgjdbc/pgjdbc-parent-poms/archive/REL%parent_ver.tar.gz
BuildArch: noarch
-BuildRequires: java-devel >= 1:1.8
+BuildRequires: java-devel >= 1.8
BuildRequires: jpackage-utils
-BuildRequires: ant
-BuildRequires: ant-junit
-BuildRequires: junit
+BuildRequires: maven-local
+BuildRequires: java-comment-preprocessor
+BuildRequires: properties-maven-plugin
+BuildRequires: maven-enforcer-plugin
+BuildRequires: maven-plugin-bundle
+BuildRequires: maven-plugin-build-helper
+
+%if %runselftest
+BuildRequires: postgresql-server
+BuildRequires: postgresql-contrib
+%endif
+
# gettext is only needed if we try to update translations
#BuildRequires: gettext
Requires: jpackage-utils
@@ -67,86 +86,138 @@ PostgreSQL is an advanced Object-Relational database management
system. The postgresql-jdbc package includes the .jar files needed for
Java programs to access a PostgreSQL database.
+
+%package parent-poms
+Summary: Build dependency management for pgjdbc.
+
+%description parent-poms
+Pom files bringing dependencies required for successful PostgreSQL JDBC driver
+build.
+
+
%package javadoc
-Summary: API docs for %{name}
-Group: Documentation
+Summary: API docs for %{name}
+Group: Documentation
%description javadoc
This package contains the API Documentation for %{name}.
+
%prep
-%setup -c -q
-mv -f %{name}-%{upstreamver}.src/* .
-rm -f %{name}-%{upstreamver}.src/.gitignore
-rm -f %{name}-%{upstreamver}.src/.travis.yml
-rmdir %{name}-%{upstreamver}.src
+%setup -c -q -a 2 -n pgjdbc-REL%version
+
+mv pgjdbc-REL%version/* .
+mv pgjdbc-parent-poms-REL%parent_ver pgjdbc-parent-poms
# remove any binary libs
find -name "*.jar" -or -name "*.class" | xargs rm -f
-%patch0 -p1 -b .revert-travis-fix
+
+%pom_disable_module ubenchmark
+
+# Hack #0! For upstream it is to some extent important to have the parent-poms
+# project separated. Having it like that on downstream level does not help at
+# all. Note that we have to revert this patch before we do the installation.
+sed -i.hack-parent-poms \
+ 's!!../pgjdbc-parent-poms/pgjdbc-core-parent/pom.xml!' \
+ pgjdbc/pom.xml
+sed -i.hack-parent-poms \
+ '/pgjdbc-versions/a pgjdbc-parent-poms/pgjdbc-versions/pom.xml' \
+ pom.xml
+
+# Hack #1! This directory is missing for some reason, it is most probably some
+# misunderstanding between maven, maven-compiler-plugin and
+# java-comment-preprocessor? Not solved yet. See rhbz#1325060.
+mkdir -p pgjdbc/target/generated-sources/annotations
+
%build
-export OPT_JAR_LIST="ant/ant-junit junit"
-export CLASSPATH=
-
# Ideally we would run "sh update-translations.sh" here, but that results
# in inserting the build timestamp into the generated messages_*.class
# files, which makes rpmdiff complain about multilib conflicts if the
# different platforms don't build in the same minute. For now, rely on
# upstream to have updated the translations files before packaging.
-ant jar publicapi
+# Include PostgreSQL testing methods and variables.
+%if %runselftest
+. %{SOURCE1}
+
+PGTESTS_LOCALE=C.UTF-8
+
+cat < build.local.properties
+server=localhost
+port=$PGTESTS_PORT
+database=test
+username=test
+password=test
+privilegedUser=$PGTESTS_ADMIN
+privilegedPassword=$PGTESTS_ADMINPASS
+preparethreshold=5
+loglevel=0
+protocolVersion=0
+EOF
+
+# Start the local PG cluster.
+pgtests_start
+%endif
+
+# First "build" the parent-poms ..
+cd %parent_poms_builddir
+%mvn_build -- %pgjdbc_mvn_options
+cd ..
+# .. and then build pgjdbc.
+
+%if %runselftest
+%mvn_build -- %pgjdbc_mvn_options
+%else
+%mvn_build -- %pgjdbc_mvn_options -Dmaven.test.skip=true
+%endif
+
+# Hack #0! Revert the patch above.
+for i in `find -name '*.hack-parent-poms'`
+do
+ mv $i ${i%%%%.hack-parent-poms}
+done
+
%install
-install -d $RPM_BUILD_ROOT%{_javadir}
-# Per jpp conventions, jars have version-numbered names and we add
-# versionless symlinks.
-install -m 644 jars/postgresql-%{upstreamver}.jdbc41.jar $RPM_BUILD_ROOT%{_javadir}/%{name}.jar
-
+%mvn_install
+cd %parent_poms_builddir
+%mvn_install
pushd $RPM_BUILD_ROOT%{_javadir}
# Also, for backwards compatibility with our old postgresql-jdbc packages,
# add these symlinks. (Probably only the jdbc3 symlink really makes sense?)
-ln -s postgresql-jdbc.jar postgresql-jdbc2.jar
-ln -s postgresql-jdbc.jar postgresql-jdbc2ee.jar
-ln -s postgresql-jdbc.jar postgresql-jdbc3.jar
+ln -s %{name}/postgresql.jar postgresql-jdbc.jar
+ln -s %{name}/postgresql.jar postgresql-jdbc2.jar
+ln -s %{name}/postgresql.jar postgresql-jdbc2ee.jar
+ln -s %{name}/postgresql.jar postgresql-jdbc3.jar
popd
-# Install the pom after inserting the correct version number
-sed 's/UPSTREAM_VERSION/%{upstreamver}/g' %{SOURCE1} >JPP-%{name}.pom
-install -d -m 755 $RPM_BUILD_ROOT%{_mavenpomdir}/
-install -m 644 JPP-%{name}.pom $RPM_BUILD_ROOT%{_mavenpomdir}/JPP-%{name}.pom
-%add_maven_depmap
-
-install -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}
-cp -ra build/publicapi $RPM_BUILD_ROOT%{_javadocdir}/%{name}
-install -d build/publicapi docs/%{name}
-
%check
-%if 0%{?runselftest}
-# Note that this requires to have PostgreSQL properly configured; for this
-# reason the testsuite is turned off by default (see org/postgresql/test/README)
-test_log=test.log
-# TODO: more reliable testing
-ant test 2>&1 | tee "$test_log" || :
-( test -f "$test_log" && ! grep FAILED "$test_log" )
-
-%endif
%files -f .mfiles
-%doc LICENSE README.md doc/*
+%license LICENSE
+%doc README.md
+%{_javadir}/%{name}.jar
%{_javadir}/%{name}2.jar
%{_javadir}/%{name}2ee.jar
%{_javadir}/%{name}3.jar
+%files parent-poms -f %parent_poms_builddir/.mfiles
+
%files javadoc
-%doc LICENSE
+%license LICENSE
%doc %{_javadocdir}/%{name}
+
%changelog
+* Wed Jul 20 2016 Pavel Raiskup - 9.4.1209-1
+- update to latest release version, thanks to Pavel Kajaba, Michael Simacek and
+ Vladimir Sitnikov for big help
+
* Thu Feb 04 2016 Fedora Release Engineering - 9.4.1200-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
diff --git a/sources b/sources
index b92bd4a..ca19b55 100644
--- a/sources
+++ b/sources
@@ -1 +1,2 @@
-6feafab5bc01ae9854e3cd8532adad54 postgresql-jdbc-9.4-1200.src.tar.gz
+c69ee412c0465529eb0c2f0d29b9e0a7 REL9.4.1209.tar.gz
+c15959ae73c9afc52b77897b26216f97 REL1.0.8.tar.gz