Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f34cd6

Browse files
committed
gradle kotlin DSL migration
1 parent 76ba799 commit 1f34cd6

8 files changed

+428
-13
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Maven
66
target/
7+
build
8+
.gradle
79
pom.xml.tag
810
pom.xml.releaseBackup
911
pom.xml.versionsBackup
@@ -18,3 +20,4 @@ buildNumber.properties
1820

1921
#Exclude CoverageHTMLReporter resources as they are managed by maven
2022
src/main/resources/CoverageHTMLReporter/
23+
/gradle.properties

.travis.yml

+17-13
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ env:
1212
- DOCKER_CFG=$HOME/.docker
1313
- DOCKER_REPO="utplsqlv3/oracledb"
1414
- CACHE_DIR=$HOME/.cache
15-
- MAVEN_HOME=/usr/local/maven
16-
- MAVEN_CFG=$HOME/.m2
1715
- DB_URL="127.0.0.1:1521:XE"
1816
- DB_USER=app
1917
- DB_PASS=app
@@ -33,30 +31,27 @@ env:
3331
- UTPLSQL_VERSION="develop"
3432
UTPLSQL_FILE="utPLSQL"
3533

34+
before_cache:
35+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
36+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
3637
cache:
3738
directories:
39+
- $HOME/.gradle/caches/
40+
- $HOME/.gradle/wrapper/
3841
- $DOCKER_CFG
3942
- $CACHE_DIR
40-
- $MAVEN_CFG
4143

4244
install:
43-
- bash .travis/maven_cfg.sh
4445
- bash .travis/start_db.sh
4546
- bash .travis/install_utplsql.sh
4647
- bash .travis/install_demo_project.sh
4748

48-
before_script:
49-
- cp .travis/settings.xml $MAVEN_CFG/settings.xml
50-
5149
script:
52-
- mvn verify -B
53-
54-
before_deploy:
55-
- if [ ! -z "$TRAVIS_TAG" ]; then VERSION=$(tr -d "/v/" <<<$TRAVIS_TAG); mvn org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=${VERSION}; fi
50+
- ./gradlew clean build -PtravisBuildNumber=$TRAVIS_BUILD_NUMBER
5651

5752
deploy:
5853
- provider: script
59-
script: mvn clean deploy -DskipTests=true -B -U -DtravisBuildNumber=$TRAVIS_BUILD_NUMBER
54+
script: ./gradlew clean uploadArchives -PtravisBuildNumber=$TRAVIS_BUILD_NUMBER
6055
skip_cleanup: true
6156
on:
6257
repository: utPLSQL/utPLSQL-java-api
@@ -65,14 +60,23 @@ deploy:
6560
condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$"
6661

6762
- provider: script
68-
script: mvn clean deploy -DskipTests=true -B -U -DtravisBuildNumber=$TRAVIS_BUILD_NUMBER
63+
script: ./gradlew clean uploadArchives -PtravisBuildNumber=$TRAVIS_BUILD_NUMBER
6964
skip_cleanup: true
7065
on:
7166
repository: utPLSQL/utPLSQL-java-api
7267
branch: develop
7368
# Use only first job "#xxx.1" to publish artifacts
7469
condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$"
7570

71+
- provider: script
72+
script: ./gradlew clean uploadArchives -PtravisBuildNumber=$TRAVIS_BUILD_NUMBER
73+
skip_cleanup: true
74+
on:
75+
repository: utPLSQL/utPLSQL-java-api
76+
branch: gradle-dsl-migration
77+
# Use only first job "#xxx.1" to publish artifacts
78+
condition: "${TRAVIS_JOB_NUMBER} =~ \\.1$"
79+
7680
notifications:
7781
slack:
7882
rooms:

build.gradle.kts

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import de.undercouch.gradle.tasks.download.Download
2+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
3+
4+
val deployerJars by configurations.creating
5+
6+
group = "org.utplsql"
7+
val mavenArtifactId = "java-api"
8+
version = "3.1.3-SNAPSHOT"
9+
10+
val coverageResourcesVersion = "1.0.1"
11+
val ojdbcVersion = "12.2.0.1"
12+
13+
plugins {
14+
`java-library`
15+
`maven-publish`
16+
maven
17+
id("de.undercouch.download") version "3.4.3"
18+
}
19+
20+
java {
21+
sourceCompatibility = JavaVersion.VERSION_1_8
22+
targetCompatibility = JavaVersion.VERSION_1_8
23+
}
24+
25+
// In this section you declare where to find the dependencies of your project
26+
repositories {
27+
maven {
28+
url = uri("https://www.oracle.com/content/secure/maven/content")
29+
credentials {
30+
// you may set this properties using gradle.properties file in the root of the project or in your GRADLE_HOME
31+
username = if (project.hasProperty("ORACLE_OTN_USER")) project.property("ORACLE_OTN_USER") as String? else System.getenv("ORACLE_OTN_USER")
32+
password = if (project.hasProperty("ORACLE_OTN_PASSWORD")) project.property("ORACLE_OTN_PASSWORD") as String? else System.getenv("ORACLE_OTN_PASSWORD")
33+
}
34+
}
35+
mavenCentral()
36+
}
37+
38+
dependencies {
39+
// This dependency is exported to consumers, that is to say found on their compile classpath.
40+
api("com.google.code.findbugs:jsr305:3.0.2")
41+
42+
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
43+
implementation("org.slf4j:slf4j-api:1.7.25")
44+
implementation("com.oracle.jdbc:ojdbc8:$ojdbcVersion") {
45+
exclude(group = "com.oracle.jdbc")
46+
}
47+
implementation("com.oracle.jdbc:orai18n:$ojdbcVersion")
48+
49+
// Use Jupiter test framework
50+
testImplementation("org.junit.jupiter:junit-jupiter:5.4.0")
51+
testImplementation("org.hamcrest:hamcrest:2.1")
52+
deployerJars("io.packagecloud.maven.wagon:maven-packagecloud-wagon:0.0.6")
53+
}
54+
55+
tasks {
56+
withType<Test> {
57+
doFirst {
58+
environment("DB_URL", System.getenv("DB_URL") ?: "localhost:1521/XE")
59+
environment("DB_USER", System.getenv("DB_USER") ?: "app")
60+
environment("DB_PASS", System.getenv("DB_PASS") ?: "app")
61+
}
62+
useJUnitPlatform()
63+
testLogging {
64+
events("passed", "skipped", "failed")
65+
exceptionFormat = TestExceptionFormat.FULL
66+
showStackTraces = true
67+
}
68+
}
69+
70+
val coverageResourcesDirectory = "${project.buildDir}/resources/main/CoverageHTMLReporter"
71+
val coverageResourcesZipDirectory = "${project.buildDir}/utPLSQL-coverage-html-$coverageResourcesVersion"
72+
val coverageResourcesZip = "$coverageResourcesZipDirectory.zip"
73+
74+
// download Coverage Resources from web
75+
val downloadResources = create<Download>("downloadCoverageResources") {
76+
src("https://codeload.github.com/utPLSQL/utPLSQL-coverage-html/zip/$coverageResourcesVersion")
77+
dest(File(coverageResourcesZip))
78+
}
79+
// Extract zip-archive to build
80+
val extractCoverageResources = create<Copy>("extractCoverageResources") {
81+
dependsOn(downloadResources)
82+
from(zipTree(coverageResourcesZip))
83+
into(buildDir)
84+
}
85+
// copy assets to sources
86+
val copyCoverageResourcesToSources = create<Copy>("copyCoverageResources") {
87+
dependsOn(extractCoverageResources)
88+
from("$coverageResourcesZipDirectory/assets")
89+
into(coverageResourcesDirectory)
90+
}
91+
92+
withType<ProcessResources> {
93+
dependsOn(copyCoverageResourcesToSources)
94+
95+
val properties = project.properties.toMutableMap()
96+
properties.putIfAbsent("travisBuildNumber", "local")
97+
expand(properties)
98+
}
99+
100+
withType<Jar> {
101+
dependsOn("generatePomFileForMavenPublication")
102+
manifest {
103+
attributes(
104+
"Built-By" to System.getProperty("user.name"),
105+
"Created-By" to "Gradle ${gradle.gradleVersion}",
106+
"Build-Jdk" to "${System.getProperty("os.name")} ${System.getProperty("os.arch")} ${System.getProperty("os.version")}"
107+
)
108+
}
109+
into("META-INF/maven/${project.group}/$mavenArtifactId") {
110+
from("$buildDir/publications/maven")
111+
rename(".*", "pom.xml")
112+
}
113+
114+
}
115+
116+
named<Upload>("uploadArchives") {
117+
repositories.withGroovyBuilder {
118+
"mavenDeployer" {
119+
setProperty("configuration", deployerJars)
120+
"repository"("url" to "packagecloud+https://packagecloud.io/utPLSQL/utPLSQL-java-api") {
121+
"authentication"("password" to System.getenv("PACKAGECLOUD_TOKEN"))
122+
}
123+
}
124+
}
125+
}
126+
}
127+
128+
publishing {
129+
publications {
130+
create<MavenPublication>("maven") {
131+
artifactId = mavenArtifactId
132+
pom {
133+
name.set("utPLSQL-java-api")
134+
url.set("https://github.com/utPLSQL/utPLSQL-java-api")
135+
licenses {
136+
license {
137+
name.set("The Apache License, Version 2.0")
138+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
139+
}
140+
}
141+
}
142+
from(components["java"])
143+
}
144+
}
145+
}

gradle/wrapper/gradle-wrapper.jar

53.1 KB
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)