Skip to content
Permalink
Browse files
chore: re-add pgjdbc-jre6 build (#1787)
  • Loading branch information
vlsi committed May 28, 2020
1 parent 332b071 commit d224acd095c1697f3503c8fbf73f7b22828b5720
Showing 8 changed files with 135 additions and 4 deletions.
@@ -28,5 +28,4 @@ dependency-reduced-pom.xml
buildNumber.properties

# Ignore folders used to build binaries for old Java
/pgjdbc-jre6
/eclipsebin/
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2020, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/

import aQute.bnd.gradle.Bundle
import aQute.bnd.gradle.BundleTaskConvention
import com.github.vlsi.gradle.dsl.configureEach
import com.github.vlsi.gradle.properties.dsl.props
import org.postgresql.buildtools.JavaCommentPreprocessorTask

plugins {
`java-library`
id("com.github.vlsi.ide")
id("com.github.vlsi.gradle-extensions")
id("biz.aQute.bnd.builder") apply false
}

buildscript {
repositories {
// E.g. for biz.aQute.bnd.builder which is not published to Gradle Plugin Portal
mavenCentral()
}
}

val java6home by props("")

val String.v: String get() = rootProject.extra["$this.version"] as String

dependencies {
implementation(platform(project(":bom")))
implementation("com.github.dblock.waffle:waffle-jna:${"waffle-jna-jre7".v}")
implementation("org.osgi:org.osgi.core")
implementation("org.osgi:org.osgi.enterprise")
}

configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
}

if (java6home.isNotBlank()) {
tasks.configureEach<JavaCompile> {
options.forkOptions.executable = "$java6home/bin/java"
}
} else if (JavaVersion.current() in JavaVersion.VERSION_1_10..JavaVersion.VERSION_11) {
tasks.configureEach<JavaCompile> {
options.compilerArgs.addAll(listOf("--release", "6"))
}
}

val preprocessMain by tasks.registering(JavaCommentPreprocessorTask::class) {
baseDir.set(project(":postgresql").projectDir)
sourceFolders.addAll("src/main/java", "src/main/version")
}

val preprocessTest by tasks.registering(JavaCommentPreprocessorTask::class) {
baseDir.set(project(":postgresql").projectDir)
sourceFolders.add("src/test/java")
}

ide {
generatedJavaSources(
preprocessMain,
preprocessMain.get().outputDirectory.get().asFile,
sourceSets.main
)
generatedJavaSources(
preprocessTest,
preprocessTest.get().outputDirectory.get().asFile,
sourceSets.test
)
}

tasks.test {
// JUnit 5 requires Java 1.8+, so the tests can't be executed with Java 1.6 :-/
enabled = false
}

tasks.compileTestJava {
// JUnit 5 requires Java 1.8+, so the tests can't be executed with Java 1.6 :-/
enabled = false
}

tasks.configureEach<JavaCommentPreprocessorTask> {
excludedPatterns.addAll("**/jre7/", "**/jdbc41/")
excludedPatterns.addAll("**/jre8/", "**/jdbc42/")
}

val osgiJar by tasks.registering(Bundle::class) {
archiveClassifier.set("osgi")
from(tasks.jar.map { zipTree(it.archiveFile) })
withConvention(BundleTaskConvention::class) {
bnd(
"""
-exportcontents: !org.postgresql.shaded.*, org.postgresql.*
-removeheaders: Created-By
Bundle-Descriptiona: Java JDBC driver for PostgreSQL database
Bundle-DocURL: https://jdbc.postgresql.org/
Bundle-Vendor: PostgreSQL Global Development Group
Import-Package: javax.sql, javax.transaction.xa, javax.naming, javax.security.sasl;resolution:=optional, *;resolution:=optional
Bundle-Activator: org.postgresql.osgi.PGBundleActivator
Bundle-SymbolicName: org.postgresql.jdbc
Bundle-Name: PostgreSQL JDBC Driver
Bundle-Copyright: Copyright (c) 2003-2020, PostgreSQL Global Development Group
Require-Capability: osgi.ee;filter:="(&(|(osgi.ee=J2SE)(osgi.ee=JavaSE))(version>=1.6))"
Provide-Capability: osgi.service;effective:=active;objectClass=org.osgi.service.jdbc.DataSourceFactory
"""
)
}
}

val extraMavenPublications by configurations.getting

(artifacts) {
extraMavenPublications(osgiJar) {
classifier = ""
}
}
@@ -0,0 +1,3 @@
# There's no point in verifying preprocessed sources
skipCheckstyle=true
jdbc.specification.version=4.0
@@ -86,6 +86,10 @@ if (java7home.isNotBlank()) {
tasks.configureEach<JavaCompile> {
options.forkOptions.executable = "$java7home/bin/java"
}
} else if (JavaVersion.current() >= JavaVersion.VERSION_1_10) {
tasks.configureEach<JavaCompile> {
options.compilerArgs.addAll(listOf("--release", "7"))
}
}

tasks.test {
@@ -694,10 +694,10 @@ public static SQLFeatureNotSupportedException notImplemented(Class<?> callClass,

//#if mvn.project.property.postgresql.jdbc.spec >= "JDBC4.1"
@Override
//#endif
public java.util.logging.Logger getParentLogger() {
return PARENT_LOGGER;
}
//#endif

public static SharedTimer getSharedTimer() {
return SHARED_TIMER;
@@ -1520,10 +1520,11 @@ public void setMaxResultBuffer(String maxResultBuffer) {
}

//#if mvn.project.property.postgresql.jdbc.spec >= "JDBC4.1"
@Override
//#endif
public java.util.logging.Logger getParentLogger() {
return Logger.getLogger("org.postgresql");
}
//#endif

/*
* Alias methods below, these are to help with ease-of-use with other database tools / frameworks
@@ -397,7 +397,7 @@ public TimestampUtils getTimestampUtils() {
/**
* The current type mappings.
*/
protected Map<String, Class<?>> typemap = new HashMap<>();
protected Map<String, Class<?>> typemap = new HashMap<String, Class<?>>();

@Override
public Statement createStatement() throws SQLException {
@@ -56,6 +56,11 @@ fun property(name: String) =
// If you face "project :postgresql-jre7 is not found" issues when reimport
// you might need to remove items like :postgresql-jre7:preprocessMain from .idea/workspace.xml

if (property("pgjdbc.skip.jre6")?.ifBlank { "true" }?.toBoolean() != true) {
include("postgresql-jre6")
project(":postgresql-jre6").projectDir = file("pgjdbc-jre6")
}

if (property("pgjdbc.skip.jre7")?.ifBlank { "true" }?.toBoolean() != true) {
include("postgresql-jre7")
project(":postgresql-jre7").projectDir = file("pgjdbc-jre7")

0 comments on commit d224acd

Please sign in to comment.