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
+ }
0 commit comments