Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate build scripts to Gradle #1627

Merged
merged 4 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 44 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
root = true

[*]
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
indent_style = space

[{*.sh,gradlew}]
end_of_line = lf

[{*.bat,*.cmd}]
end_of_line = crlf

[*.md]
# Trailing whitespace is important in Markdown (they distinguish a new line from a new paragraph)
trim_trailing_whitespace = false

[{*.kts,*.kt}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_name_count_to_use_star_import = 99
ij_kotlin_name_count_to_use_star_import_for_members = 99
ij_java_use_single_class_imports = true
max_line_length = 100
ij_any_wrap_long_lines = true

[*.java]
indent_style = space
# Doc: https://youtrack.jetbrains.com/issue/IDEA-170643#focus=streamItem-27-3708697.0-0
# $ means "static"
ij_java_imports_layout = $*,|,org.postgresql.**,|,*,|,java.**,|,javax.**
indent_size = 2
continuation_indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
tab_width = 2
max_line_length = 100
ij_any_spaces_around_additive_operators = true
ij_any_spaces_around_assignment_operators = true
ij_any_spaces_around_bitwise_operators = true
ij_any_spaces_around_equality_operators = true
ij_any_spaces_around_lambda_arrow = true
ij_any_spaces_around_logical_operators = true
ij_any_spaces_around_multiplicative_operators = true
ij_any_spaces_around_relational_operators = true
ij_any_spaces_around_shift_operators = true
ij_continuation_indent_size = 4
ij_java_if_brace_force = always
ij_java_indent_case_from_switch = false
ij_java_line_comment_add_space = true
ij_java_space_after_colon = true
ij_java_space_before_colon = true
ij_java_ternary_operation_signs_on_next_line = true
ij_java_use_single_class_imports = true
ij_java_wrap_long_lines = true
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
*.xml text
*.yaml text
*.yml text
*.bat text eol=crlf
/CHANGELOG.md merge=union
/contributors.json merge=union
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
# GitHub Actions does not support Docker, PostgreSQL server on Windows, macOS :(

jobs:
ubuntu-latest:
name: 'Ubuntu, PG latest (JDK 8)'
runs-on: ubuntu-latest
# Service must be started after checkout, because we want to use git-stored files for initialization
# of the Docker container. So we start it with and explicit docker ... command
# services:
# postgres:
# image: postgres:latest
# env:
# POSTGRES_USER: postgres
# # Empty password
# # POSTGRES_PASSWORD: postgres
# POSTGRES_DB: postgres
# ports:
# - 5432:5432
# volumes:
# - /home/runner/work/pgjdbc/pgjdbc/.travis:/scripts/.travis
# # needed because the postgres container does not provide a healthcheck
# options: >-
# --name db
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
steps:
- uses: actions/checkout@master
with:
fetch-depth: 50
- name: Start PostgreSQL
working-directory: docker
run: docker-compose up -d && docker-compose logs
- name: 'Set up JDK 8'
uses: actions/setup-java@v1
with:
java-version: 8
- name: 'Test'
run: |
echo enable_ssl_tests=true > ssltest.local.properties
# '-PincludeTestTags=!org.postgresql.test.SlowTests'
./gradlew --no-parallel --no-daemon -PskipReplicationTests -Pport=${{ job.services.postgres.ports['5432'] }} test
# test javadoc -Pport=${{ job.services.postgres.ports['5432'] }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.classpath
.gradle
.settings
.project
.checkstyle
Expand All @@ -16,6 +17,8 @@ nbproject
*-dist.zip
*.po.~*~
target/
build/
*/build/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
Expand All @@ -26,5 +29,4 @@ buildNumber.properties

# Ignore folders used to build binaries for old Java
/pgjdbc-jre6
/pgjdbc-jre7
/eclipsebin/
Empty file added .ratignore
Empty file.
48 changes: 17 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ before_install:
script:
# make sure previous build artifacts are not used for subsequent builds
- rm -rf $HOME/.m2/repository/org/postgresql || true
- test -d "${JDK6_HOME}" || export JDK6_HOME=$(jdk_switcher home openjdk6)
- test -d "${JDK7_HOME}" || export JDK7_HOME=$(jdk_switcher home openjdk7)
- test -d "${JDK8_HOME}" || export JDK8_HOME=$(jdk_switcher home oraclejdk8)
- test -d "${JDK9_HOME}" || export JDK9_HOME=$(jdk_switcher home oraclejdk9)
- test -d "${JDK9_HOME}" || export JDK9_HOME=$(jdk_switcher home oraclejdk8) # JDK9 missing on precise, fallback to JDK8
- envsubst < toolchains.xml > ~/.m2/toolchains.xml
- test ${JDK} -eq 9 || jdk_switcher use oraclejdk8 # Run Maven with Java 8, build with Toolchains.
- test -z "${ZULU_JDK}" || export TRAVIS_JDK_VERSION=zulujdk${ZULU_JDK} # trick codecov to use correct jdk version
- if [[ $TRAVIS_BRANCH == release/* ]]; then .travis/travis_release.sh; else ./.travis/travis_build.sh; fi
Expand All @@ -68,17 +66,21 @@ script:
#- mv $HOME/.m2/repository/org/postgresql /tmp/cache-trick/

before_cache:
# No sense in caching current build artifacts
- rm -rf $HOME/.m2/repository/org/postgresql
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
# No sense in caching current build artifacts
- rm -rf $HOME/.m2/repository/org/postgresql

# Skip default "mvn install" issued by Travis
# Root project cannot be compiled with older JDKs, so it makes sense to just skip the step
install: true

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.m2/repository
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
Expand All @@ -89,7 +91,7 @@ matrix:
- stage: test
jdk: oraclejdk8
env: RUN_CHECKSTYLE=true
script: mvn checkstyle:check
script: ./gradlew autostyleCheck checkstyleAll
- env:
- FEDORA_CI=Y
services:
Expand All @@ -100,9 +102,9 @@ matrix:
addons:
postgresql: "10"
env:
- PG_VERSION=10
- JDK=12
- TZ=America/New_York # flips between −05:00 and −04:00
- PG_VERSION=10
- JDK=12
- TZ=America/New_York # flips between −05:00 and −04:00
- jdk: openjdk-ea
sudo: required
addons:
Expand Down Expand Up @@ -140,9 +142,10 @@ matrix:
addons:
postgresql: "10"
env:
- PG_VERSION=10
- JDK=11
- TZ=America/New_York # flips between −05:00 and −04:00
- PG_VERSION=10
- JDK=11
- TZ=America/New_York # flips between −05:00 and −04:00
- SLOW_TESTS=Y
- jdk: oraclejdk9
addons:
postgresql: "9.6"
Expand All @@ -160,6 +163,7 @@ matrix:
- TEST_CLIENTS=Y
- TZ=Pacific/Chatham # flips between +12:45 and +13:45
- JDK=8
- SLOW_TESTS=Y
- jdk: oraclejdk8
sudo: required
addons:
Expand Down Expand Up @@ -209,6 +213,8 @@ matrix:
- MCENTRAL=Y
- COVERAGE=Y
- TZ=UTC
# Java 1.6 is no longer supported
# Do we need to test PostgreSQL 9.1?
- jdk: openjdk7
sudo: required
addons:
Expand Down Expand Up @@ -249,26 +255,6 @@ matrix:
- PG_VERSION=9.4
- NO_WAFFLE_NO_OSGI=Y
- JDK=8
- stage: release
jdk: oraclejdk8
env:
- PG_VERSION=9.6
- stage: release_prev
jdk: openjdk7
sudo: required
addons:
postgresql: "9.2"
env:
- PG_VERSION=9.2
- ZULU_JDK=7
- stage: release_prev
jdk: openjdk7
sudo: required
addons:
postgresql: "9.1"
env:
- PG_VERSION=9.1
- ZULU_JDK=6

# Deploy snapshots to Maven Central
after_success:
Expand Down
71 changes: 36 additions & 35 deletions .travis/travis_build.sh
Original file line number Diff line number Diff line change
@@ -1,82 +1,83 @@
#!/usr/bin/env bash
set -x -e

if [[ "${FEDORA_CI}" == *"Y" ]];
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

# Build project
MVN_ARGS="clean package -B -V $MVN_CUSTOM_ARGS"
# TODO: run SlowTests as well
GRADLE_ARGS="--no-daemon -PskipAutostyle -PskipCheckstyle build $MVN_CUSTOM_ARGS"
MVN_PROFILES="release"

if [[ "${NO_WAFFLE_NO_OSGI}" == *"Y"* ]];
if [[ $REPLICATION != "Y" ]];
then
GRADLE_ARGS="$GRADLE_ARGS -PskipReplicationTests"
fi

if [[ $SLOW_TESTS != "Y" ]];
then
MVN_ARGS="$MVN_ARGS -DwaffleEnabled=false -DosgiEnabled=false -DexcludePackageNames=org.postgresql.osgi:org.postgresql.sspi"
GRADLE_ARGS="$GRADLE_ARGS -PincludeTestTags=!org.postgresql.test.SlowTests"
fi

if [[ "x${QUERY_MODE}" == *"x"* ]];
if [[ $QUERY_MODE != "" ]];
then
MVN_ARGS="$MVN_ARGS -DpreferQueryMode=$QUERY_MODE"
GRADLE_ARGS="$GRADLE_ARGS -DpreferQueryMode=$QUERY_MODE"
fi

if [[ "${COVERAGE}" == *"Y"* ]];
if [[ $COVERAGE == "Y" ]];
then
MVN_PROFILES="$MVN_PROFILES,coverage"
GRADLE_ARGS="$GRADLE_ARGS jacocoReport"
fi

if [[ "${JDK}" == *"9"* ]];
if [[ $JDK == "9" ]];
then
export MAVEN_SKIP_RC=true
MVN_ARGS="$MVN_ARGS -Dcurrent.jdk=1.9 -Djavac.target=1.9"
GRADLE_ARGS="$GRADLE_ARGS -Dcurrent.jdk=1.9 -Djavac.target=1.9"
fi

if [[ "$JDOC" == *"Y"* ]];
if [[ $JDOC == "Y" ]];
then
# Build javadocs for Java 8 only
mvn ${MVN_ARGS} -P ${MVN_PROFILES},release-artifacts
elif [[ "${TRAVIS_JDK_VERSION}" == *"jdk6"* ]];
then
git clone --depth=50 https://github.com/pgjdbc/pgjdbc-jre6.git pgjdbc-jre6
cd pgjdbc-jre6
mvn ${MVN_ARGS} -P ${MVN_PROFILES},skip-unzip-jdk
elif [[ "${TRAVIS_JDK_VERSION}" == *"jdk7"* ]];
then
git clone --depth=50 https://github.com/pgjdbc/pgjdbc-jre7.git pgjdbc-jre7
cd pgjdbc-jre7
mvn ${MVN_ARGS} -P ${MVN_PROFILES},skip-unzip-jdk
./gradlew $GRADLE_ARGS javadoc
# We can't execute tests with Java 1.7 yet :(
#elif [[ "${TRAVIS_JDK_VERSION}" == *"jdk7"* ]];
#then
else
mvn ${MVN_ARGS} -P ${MVN_PROFILES}
./gradlew $GRADLE_ARGS
fi

if [[ "${COVERAGE}" == "Y" ]];
if [[ $COVERAGE == "Y" ]];
then
pip install --user codecov
codecov
fi

# Run Scala-based and Clojure-based tests
if [[ "${TEST_CLIENTS}" == *"Y" ]];
if [[ $TEST_CLIENTS == "Y" ]];
then
# Pgjdbc should be in "local maven repository" so the clients can use it. Mvn commands above just package it.
mvn -DskipTests install
# Pgjdbc should be in "local maven repository" so the clients can use it
./gradlew publishToMavenLocal -Ppgjdbc.version=1.0.0-dev-master -PskipJavadoc

mkdir -p $HOME/.sbt/launchers/0.13.12
curl -L -o $HOME/.sbt/launchers/0.13.12/sbt-launch.jar http://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.12/sbt-launch.jar

PROJECT_VERSION=$(mvn -B -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[')

cd test-anorm-sbt
sed -i "s/\"org.postgresql\" % \"postgresql\" % \"[^\"]*\"/\"org.postgresql\" % \"postgresql\" % \"${PROJECT_VERSION}\"/" build.sbt
sed -i "s/\"org.postgresql\" % \"postgresql\" % \"[^\"]*\"/\"org.postgresql\" % \"postgresql\" % \"1.0.0-dev-master-SNAPSHOT\"/" build.sbt
sbt test

cd ..
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- fix: Always use `.` as decimal separator in PGInterval [PR 1705](https://github.com/pgjdbc/pgjdbc/pull/1705)
- fix: allow DatabaseMetaData.getColumns to describe an unset scale [PR 1716](https://github.com/pgjdbc/pgjdbc/pull/1716)

### Changed
- Build system update from Maven to Gradle [PR 1627](https://github.com/pgjdbc/pgjdbc/pull/1627)

### Added
- docker-compose image for creating test databases (see `docker` folder)

## [42.2.10] (2020-01-30)
### Changed
- (!) Regression: remove receiving EOF from backend after cancel [PR 1641](https://github.com/pgjdbc/pgjdbc/pull/1252). The regression is that the subsequent query might receive the cancel signal.
Expand Down