Skip to content

Commit

Permalink
Use Kotlin Script for Gradle instead of Groovy (JetBrains#513)
Browse files Browse the repository at this point in the history
* Use build.gradle.kts, rework modules and few more fixes to gradle
* Fix dialect tests, add buildSrc and rework directories structure

* Update to kosogor 1.0.2.
Update wrapper to 5.2.1.
Fix userOrg and vcsUrl in publishing

* Gradle: Remove unneeded default_dialect
  • Loading branch information
TanVD authored and Tapac committed Mar 15, 2019
1 parent 29fdc23 commit 06dd75d
Show file tree
Hide file tree
Showing 88 changed files with 254 additions and 250 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
.idea
.gradle
out
build
classes
out/test/resources
142 changes: 0 additions & 142 deletions build.gradle

This file was deleted.

12 changes: 12 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
kotlin("jvm") version "1.3.21" apply true
id("tanvd.kosogor") version "1.0.2" apply true
}

subprojects {
apply(plugin = "tanvd.kosogor")
}

repositories {
jcenter()
}
File renamed without changes.
18 changes: 18 additions & 0 deletions buildScripts/docker/docker-compose-oracle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.1'

services:
oracle:
container_name: oracleDB
image: sath89/oracle-12c:latest
ports:
- "1521"
environment:
WEB_CONSOLE: "true"
DBCA_TOTAL_MEMORY: 1024
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/u01/app/oracle/product/12.1.0/xe/bin
USE_UTF8_IF_CHARSET_EMPTY: "true"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/apex"]
interval: 1m
timeout: 10s
retries: 3
11 changes: 11 additions & 0 deletions buildScripts/docker/docker-compose-sqlserver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.1'

services:
sqlserver:
container_name: SQLServer
image: microsoft/mssql-server-linux:latest
ports:
- "1433"
environment:
ACCEPT_EULA: Y
SA_PASSWORD: "yourStrong(!)Password"
13 changes: 13 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repositories {
jcenter()
}

dependencies {
gradleApi()
compile("com.avast.gradle", "gradle-docker-compose-plugin", "0.9.1")
}

plugins {
`kotlin-dsl` apply true
id("tanvd.kosogor") version "1.0.1" apply true
}
3 changes: 3 additions & 0 deletions buildSrc/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.jvmargs=-Dfile.encoding=UTF-8
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Accessors.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@file:Suppress("FunctionName")

package org.jetbrains.exposed.gradle

import com.avast.gradle.dockercompose.ComposeExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByName

private inline fun <reified T : Any> Project.extByName(name: String): T = extensions.getByName<T>(name)

fun Project._dockerCompose(configure: ComposeExtension.() -> Unit) = extByName<ComposeExtension>("dockerCompose").apply(configure)
val Project._dockerCompose
get() = extByName<ComposeExtension>("dockerCompose")

fun Project.applyPluginSafely(id: String) {
if (!plugins.hasPlugin(id)) {
apply(plugin = id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.jetbrains.exposed.gradle

import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.create
import java.io.File
import java.time.Duration

fun Project.setupDialectTest(dialect: String) {
applyPluginSafely("com.avast.gradle.docker-compose")
val dialectTest = tasks.create("exposedDialectTestWithDocker", Test::class) {
group = "verification"
systemProperties["exposed.test.dialects"] = dialect

doFirst {
_dockerCompose {
val containerInfo = servicesInfos[dialect]!!
systemProperty("exposed.test.$dialect.host", containerInfo.host)
systemProperty("exposed.test.oracle.port", containerInfo.ports[1521] ?: -1)
systemProperty("exposed.test.sqlserver.port", containerInfo.ports[1433] ?: -1)
systemProperty("exposed.test.mariadb.port", containerInfo.ports[3306] ?: -1)
}
}
}

_dockerCompose.isRequiredBy(dialectTest)

_dockerCompose {
useComposeFiles = listOf(File(project.rootProject.projectDir, "buildScripts/docker/docker-compose-$dialect.yml").absolutePath)
captureContainersOutput = true
removeVolumes = true
environment["COMPOSE_CONVERT_WINDOWS_PATHS"] = true
waitForHealthyStateTimeout = Duration.ofMinutes(60)
}

}
18 changes: 0 additions & 18 deletions docker-compose-oracle.yml

This file was deleted.

11 changes: 0 additions & 11 deletions docker-compose-sqlserver.yml

This file was deleted.

65 changes: 65 additions & 0 deletions exposed/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.exposed.gradle.setupDialectTest
import tanvd.kosogor.proxy.publishJar

plugins {
kotlin("jvm") apply true
}

repositories {
jcenter()
}

dependencies {
api(kotlin("stdlib"))
api(kotlin("reflect"))
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.0.1")
api("joda-time", "joda-time", "2.9.9")
api("org.slf4j", "slf4j-api", "1.7.25")
implementation("com.h2database", "h2", "1.4.197")

testImplementation(kotlin("test-junit"))
testImplementation("org.slf4j", "slf4j-log4j12", "1.7.25")
testImplementation("log4j", "log4j", "1.2.17")
testImplementation("junit", "junit", "4.12")
testImplementation("org.hamcrest", "hamcrest-library", "1.3")
testImplementation("com.h2database", "h2", "1.4.197")

testImplementation("mysql", "mysql-connector-java", "5.1.46")
testImplementation("mysql", "mysql-connector-mxj", "5.0.12")
testImplementation("org.mariadb.jdbc", "mariadb-java-client", "2.3.0")
testImplementation("org.postgresql", "postgresql", "42.2.2.jre6")
testImplementation("com.opentable.components", "otj-pg-embedded", "0.12.0")
testImplementation("org.xerial", "sqlite-jdbc", "3.23.1")
testImplementation("com.oracle", "ojdbc6", "12.1.0.1-atlassian-hosted")
testImplementation("com.microsoft.sqlserver", "mssql-jdbc", "6.4.0.jre7")
}

publishJar {
publication {
artifactId = "exposed"
}

bintray {
repository = "exposed"
info {
githubRepo = "https://github.com/JetBrains/Exposed.git"
vcsUrl = "https://github.com/JetBrains/Exposed.git"
userOrg = "kotlin"
license = "Apache-2.0"
}
}
}

tasks.withType(Test::class.java) {
jvmArgs = listOf("-XX:MaxPermSize=256m")
testLogging {
events.addAll(listOf(TestLogEvent.PASSED, TestLogEvent.FAILED, TestLogEvent.SKIPPED))
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
}
}

val dialect: String by project
setupDialectTest(dialect)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.dao
package org.jetbrains.exposed.sql.tests.demo.dao

import org.jetbrains.exposed.dao.EntityID
import org.jetbrains.exposed.dao.IntEntity
Expand Down
Loading

0 comments on commit 06dd75d

Please sign in to comment.