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

Add support for JDK 10 in both Maven and Gradle #691

Merged
merged 13 commits into from
May 31, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

language: java
jdk:
- oraclejdk9
- oraclejdk10

addons:
apt:
packages:
- oracle-java9-installer

services:
- docker

Expand Down Expand Up @@ -45,5 +40,5 @@ script:
- docker ps -a

##Test for JDBC Specification 43 & 42 and submit coverage report.
- mvn test -B -Pbuild41 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC43
- mvn test -B -Pbuild43 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC43
- mvn test -B -Pbuild42 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC42
5 changes: 2 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ init:
- cmd: net start MSSQL$%SQL_Instance%

environment:
JAVA_HOME: C:\Program Files\Java\jdk9
JAVA_HOME: C:\Program Files\Java\jdk10
mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=%SQL_Instance%;databaseName=master;username=sa;password=Password12!;

matrix:
- SQL_Instance: SQL2008R2SP2
- SQL_Instance: SQL2016
- SQL_Instance: SQL2017

install:
- ps: Write-Host 'Installing JCE with powershell'
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ allprojects {

if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile == "build43")){

jreVersion = "jre9"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change commenting on line 5 to java 10

jreVersion = "jre10"
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'

sourceCompatibility = 9
targetCompatibility = 9
sourceCompatibility = 10
targetCompatibility = 10
}

if((hasProperty('buildProfile') && buildProfile == "build42")) {
Expand Down
122 changes: 62 additions & 60 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<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>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.5.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
<description>
Microsoft JDBC Driver for SQL Server.
</description>
<url>https://github.com/Microsoft/mssql-jdbc</url>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>

<organization>
<name>Microsoft Corporation</name>
</organization>

<developers>
<developer>
<organization>Microsoft</organization>
<organizationUrl>http://www.microsoft.com</organizationUrl>
</developer>
</developers>

<scm>
<url>https://github.com/Microsoft/mssql-jdbc</url>
</scm>
Expand All @@ -41,22 +42,22 @@
<junit.platform.version>1.2.0</junit.platform.version>
<junit.jupiter.version>5.2.0</junit.jupiter.version>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.0.0</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.5.0</version>
<optional>true</optional>
</dependency>

<!-- dependencies for running tests -->
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -157,14 +158,14 @@
</plugins>
</build>
</profile>

<profile>
<id>build43</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</activation>
<build>
<finalName>${project.artifactId}-${project.version}.jre9-preview</finalName>
<finalName>${project.artifactId}-${project.version}.jre10-preview</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -173,8 +174,8 @@
<excludes>
<exclude>**/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java</exclude>
</excludes>
<source>9</source>
<target>9</target>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -219,7 +220,7 @@
</includes>
</testResource>
</testResources>

<plugins>

<plugin>
Expand All @@ -235,13 +236,14 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<version>0.8.1</version>
<executions>
<execution>
<id>pre-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
Expand All @@ -256,46 +258,46 @@
</executions>
</plugin>
<!-- Create OSGI Headers -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>com.microsoft.sqlserver.jdbc,microsoft.sql</Export-Package>
<Import-Package>!microsoft.sql,*</Import-Package>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>com.microsoft.sqlserver.jdbc,microsoft.sql</Export-Package>
<Import-Package>!microsoft.sql,*</Import-Package>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnError>true</failOnError>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird place to have a return

<configuration>
<failOnError>true</failOnError>
</configuration>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, why is this config sandwiched by newline.

<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -307,7 +309,7 @@
<excludeTags>${skipTestTag}</excludeTags>
</properties>
</configuration>

<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
Expand All @@ -326,9 +328,9 @@
<outputFile>outdated-dependencies.txt</outputFile>
<rulesUri>file:///${session.executionRootDirectory}/maven-version-rules.xml</rulesUri>
</configuration>
</plugin>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Microsoft JDBC Driver for SQL Server
*
* Copyright(c) Microsoft Corporation All rights reserved.
*
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package com.microsoft.sqlserver.jdbc.connection;

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;

import com.microsoft.sqlserver.jdbc.SQLServerConnection;
import com.microsoft.sqlserver.jdbc.SQLServerConnection43;
import com.microsoft.sqlserver.testframework.AbstractTest;

/**
* Test ConnectionWrapper43Test class
*
*/
@RunWith(JUnitPlatform.class)
public class ConnectionWrapper43Test extends AbstractTest {
static Connection connection = null;
double javaVersion = Double.parseDouble(System.getProperty("java.specification.version"));
static int major;
static int minor;

/**
* Tests creation of SQLServerConnection43Test object
*
* @throws SQLException
*/
@Test
public void SQLServerConnection43Test() throws SQLException {
try {
if (1.8d <= javaVersion && 4 == major && 2 == minor) {
assertTrue(connection instanceof SQLServerConnection);
}
else {
assertTrue(connection instanceof SQLServerConnection43);
}
}
finally {
if (null != connection) {
connection.close();
}
}
}

@BeforeAll
private static void setupConnection() throws SQLException {
connection = DriverManager.getConnection(connectionString);

DatabaseMetaData metadata = connection.getMetaData();
major = metadata.getJDBCMajorVersion();
minor = metadata.getJDBCMinorVersion();
}

@AfterAll
private static void terminateVariation() throws SQLException {
if (null != connection) {
connection.close();
}
}

}