Skip to content

Commit

Permalink
Add source distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Mar 6, 2020
1 parent 64f336c commit 46f0474
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 41 deletions.
14 changes: 9 additions & 5 deletions .travis/travis_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ set -x -e

if [[ "${FEDORA_CI}" == *"Y" ]];
then
# Prepare "source release" archive
./gradlew :postgresql:sourceDistribution -Prelease

# Copy file to packaging directory, so rpm_ci would use it rather that downloading it from release URL
cp pgjdbc/build/distributions/postgresql-*-src.tar.gz packaging/rpm

# Try to prevent "stdout: write error"
# WA is taken from https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959
python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
export PROJECT_VERSION=$(mvn -B -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[')
export PARENT_VERSION=$(mvn -B -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.parent.version | grep -v '\[')
export CHECK_PARENT_VERSION=$(mvn help:evaluate -Dexpression=project.parent.version -q -DforceStdout -f pgjdbc/pom.xml)
# just make sure that pom.xml has the same value as pgjdbc/pom.xml
test "$PARENT_VERSION" = "$CHECK_PARENT_VERSION"
export PROJECT_VERSION=$(grep pgjdbc.version gradle.properties | cut -d "=" -f2-)
# Removal of PARENT_VERSION requires rebuild of praiskup/copr-and-jdbc-ci Docker image
export PARENT_VERSION=unused_but_passed_to_make_script_inside_docker_happy

exec ./packaging/rpm_ci
fi
Expand Down
47 changes: 11 additions & 36 deletions packaging/rpm/postgresql-jdbc.spec.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@

%global section devel
%global source_path pgjdbc/src/main/java/org/postgresql
%global parent_ver GENERATED
%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
Expand All @@ -49,25 +44,24 @@ Release: GENERATED
License: BSD
URL: http://jdbc.postgresql.org/

Source0: https://github.com/pgjdbc/pgjdbc/archive/REL%{version}/pgjdbc-REL%{version}.tar.gz
# This archive contains the minimal set of files + pom.xml that can be used to build postgresql.jar
Source0: https://repo1.maven.org/maven2/org/postgresql/postgresql/%{version}/postgresql-%{version}-src.tar.gz
Provides: pgjdbc = %version-%release

# 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.
Source1: https://github.com/pgjdbc/pgjdbc-parent-poms/archive/REL%parent_ver/pgjdbc-parent-poms-REL%{parent_ver}.tar.gz

BuildArch: noarch
BuildRequires: java-devel >= 1.8
BuildRequires: maven-local
BuildRequires: java-comment-preprocessor
BuildRequires: maven-enforcer-plugin
BuildRequires: maven-plugin-bundle
BuildRequires: maven-plugin-build-helper
BuildRequires: classloader-leak-test-framework

BuildRequires: mvn(com.ongres.scram:client)
BuildRequires: mvn(org.apache.maven.plugins:maven-clean-plugin)
BuildRequires: mvn(org.apache.maven.surefire:surefire-junit-platform)
BuildRequires: mvn(org.junit.jupiter:junit-jupiter-api)
BuildRequires: mvn(org.junit.jupiter:junit-jupiter-engine)
BuildRequires: mvn(org.junit.jupiter:junit-jupiter-params)
BuildRequires: mvn(org.junit.vintage:junit-vintage-engine)

%if %runselftest
BuildRequires: postgresql-contrib
Expand All @@ -93,39 +87,18 @@ This package contains the API Documentation for %{name}.


%prep
%setup -c -q -a 1

mv pgjdbc-REL%version/* .
mv pgjdbc-parent-poms-REL%parent_ver pgjdbc-parent-poms
%setup -c -q

# remove any binary libs
find -name "*.jar" -or -name "*.class" | xargs rm -f

# Build parent POMs in the same Maven call.
%pom_xpath_inject pom:modules "<module>%parent_poms_builddir</module>"
%pom_xpath_inject pom:parent "<relativePath>pgjdbc-parent-poms/pgjdbc-versions</relativePath>"
%pom_xpath_set pom:relativePath ../pgjdbc-parent-poms/pgjdbc-core-parent pgjdbc
%pom_xpath_remove "pom:plugin[pom:artifactId = 'maven-shade-plugin']" pgjdbc
%pom_remove_plugin :karaf-maven-plugin pgjdbc
%pom_remove_plugin :properties-maven-plugin pgjdbc-parent-poms/pgjdbc-core-parent
%pom_remove_plugin :properties-maven-plugin pgjdbc-parent-poms/pgjdbc-versions

# compat symlink: requested by dtardon (libreoffice), reverts part of
# 0af97ce32de877 commit.
%mvn_file org.postgresql:postgresql %{name}/postgresql %{name} postgresql

# Parent POMs should not be installed.
%mvn_package ":*{parent,versions,prevjre}*" __noinstall

# For compat reasons, make Maven artifact available under older coordinates.
%mvn_alias org.postgresql:postgresql postgresql:postgresql

# 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
# Ideally we would run "sh update-translations.sh" here, but that results
# in inserting the build timestamp into the generated messages_*.class
Expand Down Expand Up @@ -159,7 +132,7 @@ EOF
opts="-f"
%endif

%mvn_build $opts -- %pgjdbc_mvn_options
%mvn_build $opts


%install
Expand All @@ -176,5 +149,7 @@ opts="-f"


%changelog
* Tue Mar 03 2020 Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
- Adapted to building from the source release
* Wed Nov 29 2017 Pavel Raiskup <praiskup@redhat.com> - 9.5.git
- no changelog in this spec file (upstream git)
80 changes: 80 additions & 0 deletions pgjdbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,89 @@ karaf {
}
}

// <editor-fold defaultstate="collapsed" desc="Source distribution for building pgjdbc with minimal features">
val sourceDistribution by tasks.registering(Tar::class) {
archiveClassifier.set("src")
archiveExtension.set("tar.gz")
compression = Compression.GZIP
includeEmptyDirs = false
from(rootDir) {
include("build.properties")
include("ssltest.properties")
include("LICENSE")
include("README.md")
}
into("src/main/resources") {
from("$rootDir/LICENSE")
}

val props = listOf(
"pgjdbc.version",
"junit4.version",
"junit5.version",
"classloader-leak-test-framework.version",
"com.ongres.scram.client.version"
).associate { propertyName ->
val value = project.findProperty(propertyName) as String
inputs.property(propertyName, project.findProperty(propertyName))
"%{$propertyName}" to value
}

from("reduced-pom.xml") {
rename { "pom.xml" }
filter {
it.replace(Regex("%\\{[^}]+\\}")) {
props[it.value] ?: throw GradleException("Unknown property in reduced-pom.xml: $it")
}
}
}
into("src/main/resources") {
from(tasks.jar.map {
zipTree(it.archiveFile).matching {
include("META-INF/MANIFEST.MF")
}
})
}
into("src/main") {
into("java") {
from(preprocessVersion)
}
from("src/main") {
exclude("checkstyle")
exclude("*/org/postgresql/osgi/**")
exclude("*/org/postgresql/sspi/NTDSAPI.java")
exclude("*/org/postgresql/sspi/NTDSAPIWrapper.java")
exclude("*/org/postgresql/sspi/SSPIClient.java")
}
}
into("src/test") {
from("src/test") {
exclude("*/org/postgresql/test/osgi/**")
exclude("**/*Suite*")
exclude("*/org/postgresql/test/sspi/*.java")
exclude("*/org/postgresql/replication/**")
}
}
into("certdir") {
from("$rootDir/certdir") {
include("good*")
include("bad*")
include("Makefile")
include("README.md")
from("server") {
include("root*")
include("server*")
include("pg_hba.conf")
}
}
}
}
// </editor-fold>

val extraMavenPublications by configurations.getting

(artifacts) {
extraMavenPublications(sourceDistribution)
extraMavenPublications(osgiJar) {
classifier = ""
}
Expand Down
132 changes: 132 additions & 0 deletions pgjdbc/reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2019, PostgreSQL Global Development Group
~ See the LICENSE file in the project root for more information.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<packaging>jar</packaging>
<name>PostgreSQL JDBC Driver - JDBC 4.2</name>
<version>%{pgjdbc.version}</version>
<description>Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database</description>
<url>https://github.com/pgjdbc/pgjdbc</url>

<licenses>
<license>
<name>BSD-2-Clause</name>
<url>https://jdbc.postgresql.org/about/license.html</url>
</license>
</licenses>

<organization>
<name>PostgreSQL Global Development Group</name>
<url>https://jdbc.postgresql.org/</url>
</organization>

<properties>
<!-- Require JDK 1.8 or later -->
<javac.target>1.8</javac.target>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${encoding}</project.resources.sourceEncoding>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-jar-plugin.version>2.6</maven-jar-plugin.version>
<maven-javadoc-plugin.version>3.0.1</maven-javadoc-plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>com.ongres.scram</groupId>
<artifactId>client</artifactId>
<version>%{com.ongres.scram.client.version}</version>
</dependency>
<dependency>
<groupId>se.jiderhamn</groupId>
<artifactId>classloader-leak-test-framework</artifactId>
<version>%{classloader-leak-test-framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>%{junit4.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>%{junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>%{junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>%{junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>%{junit5.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${javac.target}</source>
<target>${javac.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>-Xmx1536m</argLine>
<systemPropertyVariables>
<build.properties.relative.path>.</build.properties.relative.path>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 46f0474

Please sign in to comment.