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

Gradle build script #54

Merged
merged 2 commits into from
Dec 1, 2016
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
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ What's coming next? We will look into adding a more comprehensive set of tests,
## Build
### Prerequisites
* Java 8
* [Ant](http://ant.apache.org/manual/install.html) (with [Ivy](https://ant.apache.org/ivy/download.cgi)) or [Maven](http://maven.apache.org/download.cgi)
* [Ant](http://ant.apache.org/manual/install.html) (with [Ivy](https://ant.apache.org/ivy/download.cgi)), [Maven](http://maven.apache.org/download.cgi) or [Gradle](https://gradle.org/gradle-download/)
* An instance of SQL Server or Azure SQL Database that you can connect to.

### Build the JAR files
The build automatically triggers a set of verification tests to run. For these tests to pass, you will first need to add an environment variable in your system called `mssql_jdbc_test_connection_properties` to provide the [correct connection properties](https://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) for your SQL Server or Azure SQL Database instance.

To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven. You can choose to build a JDBC 4.1 compliant jar file (for use with JRE 7) and/or a JDBC 4.2 compliant jar file (for use with JRE 8).
To build the jar files, you must use Java 8 with either Ant (with Ivy), Maven or Gradle. You can choose to build a JDBC 4.1 compliant jar file (for use with JRE 7) and/or a JDBC 4.2 compliant jar file (for use with JRE 8).

* Ant:
1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance.
Expand All @@ -38,10 +38,16 @@ To build the jar files, you must use Java 8 with either Ant (with Ivy) or Maven.

* Maven:
1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance.
2. Run one of the commands below to build a JDBC 4.1 compliant jar or JDBC 4.2 compliant jar in the \build directory.
2. Run one of the commands below to build a JDBC 4.1 compliant jar or JDBC 4.2 compliant jar in the \target directory.
* Run `mvn install -Pbuild41`. This creates JDBC 4.1 compliant jar in \target directory
* Run `mvn install -Pbuild42`. This creates JDBC 4.2 compliant jar in \target directory

* Gradle:
1. If you have not already done so, add the environment variable `mssql_jdbc_test_connection_properties` in your system with the connection properties for your SQL Server or SQL DB instance.
2. Run one of the commands below to build a JDBC 4.1 compliant jar or JDBC 4.2 compliant jar in the \build\libs directory.
* Run `gradle build -Pbuild=build41`. This creates JDBC 4.1 compliant jar in \build\libs directory
* Run `gradle build -Pbuild=build42`. This creates JDBC 4.2 compliant jar in \build\libs directory

### AppVeyor Build Status
[![Build status](https://ci.appveyor.com/api/projects/status/o6fjg16678ol64d3?svg=true)](https://ci.appveyor.com/project/Microsoft-JDBC/mssql-jdbc)

Expand Down
66 changes: 66 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apply plugin: 'java'

archivesBaseName = 'mssql-jdbc'
version = '6.1.0'

allprojects {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

tasks.withType(Test) {
systemProperty "file.encoding", "UTF-8"
}
}

def excludedFile = ''

if(build == "build41") {
jar.archiveName = "${archivesBaseName}-${version}.jre7.jar"
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java'

sourceCompatibility = 1.7
targetCompatibility = 1.7
}

if(build == "build42") {
jar.archiveName = "${archivesBaseName}-${version}.jre8.jar"
excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc41.java'

sourceCompatibility = 1.8
targetCompatibility = 1.8
}

jar {
manifest {
attributes 'Title': "Microsoft JDBC Driver ${version} for SQL Server",
'Version': version,
'Vendor': 'Microsoft Corporation'
}
}

sourceSets {
main {
java {
srcDirs 'src/main/java'
exclude excludedFile
}

resources {
srcDirs "$projectDir"
include 'META-INF/services/java.sql.Driver'
}
}
}

//Get dependencies from Maven central repository
repositories {
mavenCentral()
}

dependencies {
compile 'com.microsoft.azure:azure-keyvault:0.9.7',
'junit:junit:4.12'
}