forked from tlberglund/gradle-liquibase-plugin
-
Notifications
You must be signed in to change notification settings - Fork 60
/
build.gradle
186 lines (164 loc) · 6.87 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!groovy
// The above triggers groovy syntax highlighting in vim
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.gradle.publish:plugin-publish-plugin:${gradlePublishPluginVersion}"
}
}
// Apply the Plugin Publish plugin to make plugin publication possible. The Plugin Publish plugin
// will in turn auto-apply the Gradle Plugin Development Plugin (java-gradle-plugin) and the Maven
// Publish plugin (maven-publish).
apply plugin: "com.gradle.plugin-publish"
apply plugin: "groovy"
apply plugin: "signing"
apply plugin: "idea"
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = "org.liquibase"
archivesBaseName = "liquibase-gradle-plugin"
version = liquibaseGradlePluginVersion
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
if ( isReleaseVersion ) {
println "using staging"
ext.mavenCentralUploadUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
println "using snapshot"
ext.mavenCentralUploadUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compileOnly localGroovy()
compileOnly gradleApi()
compileOnly "org.codehaus.groovy:groovy:${groovyVersion}"
compileOnly "org.liquibase:liquibase-core:${liquibaseCoreVersion}"
// implementation "org.liquibase:liquibase-standard:${liquibaseCoreVersion}"
testImplementation "org.liquibase:liquibase-core:${liquibaseCoreVersion}"
testImplementation "junit:junit:${junitVersion}"
}
task sourceJar(type: Jar) {
description = "An archive of the source code for Maven Central"
classifier = "sources"
from sourceSets.main.allSource
}
task groovydocJar(type: Jar, dependsOn: groovydoc) {
description = "An archive of the GroovyDocs for Maven Central"
classifier = "javadoc"
from groovydoc
}
// Configure the plugin. Note that the ID must match it's Gradle Plugin Portal id.
// This will screw up Maven publishing, but we'll fix that later.
gradlePlugin {
website = "https://github.com/liquibase/liquibase-gradle-plugin"
vcsUrl = "https://github.com/liquibase/liquibase-gradle-plugin.git"
plugins {
liquibasePlugin {
id = "org.liquibase.gradle"
displayName = "Gradle Liquibase Plugin"
description = "A Gradle plugin for running the Liquibase database upgrade tool."
implementationClass = "org.liquibase.gradle.LiquibasePlugin"
tags.set(["liquibase", "database"])
}
}
}
// Configure the maven-publish plugin
publishing {
publications {
liquibasePlugin(MavenPublication) {
from components.java
// artifact groovydocJar
// artifact sourceJar
pom {
name = "Gradle Liquibase Plugin"
description = "A Gradle plugin for running the Liquibase database upgrade tool."
url = "https://github.com/liquibase/liquibase-gradle-plugin"
packaging = "jar"
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "stevesaliman"
name = "Steven C. Saliman"
email = "support@saliman.net"
}
}
scm {
connection = "scm:https://liquibase@github.com/liquibase/liquibase-gradle-plugin"
developerConnection = "scm:git@github.com:liquibase/liquibase-gradle-plugin.git"
url = "https://github.com/liquibase/liquibase-gradle-plugin"
}
}
}
}
repositories {
maven {
url = mavenCentralUploadUrl
// We only need to mess with credentials if we're publishing...
if ( gradle.startParameter.taskNames.contains("publish") ) {
// Use Java's console to read from the console (no good for a CI environment)
def console = System.console()
console.printf "\n\nWe have to upload some things in this build...\n\n"
if ( !project.hasProperty("mavenCentralUsername") ) {
def mavenCentralUsername = console.readLine("Maven Central Username: ")
allprojects { ext."mavenCentralUsername" = mavenCentralUsername }
}
if ( !project.hasProperty("mavenCentralPassword") ) {
def mavenCentralPassword = console.readLine("Maven Central Password: ")
allprojects { ext."mavenCentralPassword" = mavenCentralPassword }
}
credentials {
username mavenCentralUsername
password mavenCentralPassword
}
}
}
}
}
signing {
sign publishing.publications.liquibasePlugin
}
// When we're ready to go, there are a couple of things we'll need to do before we execute anything.
gradle.taskGraph.whenReady { taskGraph ->
// This is a rather nasty little hack. When we apply java-gradle-plugin, It creates some
// maven-publish tasks that conflict with the manual configuration - it tries to publish a
// org.liquibase.gradle artifact, which is wrong. The quick and very dirty solution is to
// disable those tasks.
// Comment this to publish to Gradle, Uncomment for Maven Central
taskGraph.allTasks.findAll { it.name ==~ /.*MavenPublication.*/ }*.enabled = false
// Only *require* signing if we are uploading a release version. If we do need to sign, make
// sure we've got the properties we need to do the signing.
if ( isReleaseVersion && taskGraph.hasTask(":publish") ) {
// Use Java's console to read from the console (no good for a CI environment)
def console = System.console()
console.printf "\n\nWe have to sign some things in this build...\n\n"
if ( !project.hasProperty("signing.keyId") ) {
def id = console.readLine("PGP Public Key Id: ")
allprojects { ext."signing.keyId" = id }
}
if ( !project.hasProperty("signing.secretKeyRingFile") ) {
def file = console.readLine("PGP Secret Key Ring File (absolute path): ")
allprojects { ext."signing.secretKeyRingFile" = file }
}
if ( !project.hasProperty("signing.password") ) {
def password = console.readPassword("PGP Private Key Password: ")
allprojects { ext."signing.password" = password }
}
console.printf "\nThanks.\n\n"
} else {
tasks.withType(org.gradle.plugins.signing.Sign).all {
it.enabled = false
}
}
}