-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
223 lines (191 loc) · 5.67 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/**
* To deploy to local maven repository, run:
* ./gradlew publishToMavenLocal
*
* To release to Sonatype's central nexus, run:
* ./gradlew clean publish -Prelease_to_central
*
* To release to gradle plugin portal run:
* ./gradlew clean publishPlugins
*/
plugins {
id "com.gradle.plugin-publish" version "0.15.0"
id "org.sonarqube" version "2.6"
id "java-gradle-plugin"
}
apply plugin: 'java'
apply plugin: 'signing'
apply plugin: 'project-report'
apply plugin: 'maven-publish'
apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco'
// Artifact settings
project.group = 'org.zeroturnaround'
project.version = '1.2.1-SNAPSHOT'
project.ext.name = 'JRebel Gradle plugin'
project.ext.description = 'JRebel Gradle plugin'
project.ext.vcs = 'https://github.com/zeroturnaround/gradle-jrebel-plugin'
project.ext.website = 'https://jrebel.com'
// Compiler settings (Gradle 2.0 requires Java 6+)
targetCompatibility = "1.8"
sourceCompatibility = "1.8"
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
configurations {
deployerJars
published.extendsFrom archives, signatures
}
// Write the plugin's classpath to a file to share with the tests
task createClasspathManifest {
def outputDir = file("$buildDir/$name")
inputs.files sourceSets.main.runtimeClasspath
outputs.dir outputDir
doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
}
}
// add version of the plugin into MANIFEST.MF to add it into generated rebel.xml files
jar {
manifest {
attributes("Implementation-Version":project.version)
}
}
javadoc {
options.addBooleanOption('Xdoclint:none', true)
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// === Dependency management
dependencies {
compileOnly gradleApi()
implementation 'commons-lang:commons-lang:2.6'
testImplementation gradleTestKit()
testImplementation 'junit:junit:4.13.1'
testImplementation 'xmlunit:xmlunit:1.6'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'commons-io:commons-io:2.15.0'
deployerJars 'org.apache.maven.wagon:wagon-webdav-jackrabbit:2.12'
testRuntimeOnly files(createClasspathManifest)
}
repositories {
mavenCentral()
}
// =========================== TESTING ===========================
// Run tests before installing the artifact
jar.dependsOn(test)
// =========================== PUBLISHING ===========================
java {
withSourcesJar()
withJavadocJar()
}
pluginBundle {
website = project.ext.website
vcsUrl = project.ext.vcs
description = project.ext.description
tags = ['JRebel', 'rebel.xml', 'ZeroTurnaround']
plugins {
jrebel {
id = 'org.zeroturnaround.gradle.jrebel'
displayName = 'Gradle JRebel Plugin'
}
}
}
gradlePlugin {
plugins {
jrebel {
id = 'org.zeroturnaround.gradle.jrebel'
implementationClass = 'org.zeroturnaround.jrebel.gradle.RebelPlugin'
}
}
}
// Required data for maven central
def pomFile = {
name = project.ext.name
description = project.ext.description
url = project.ext.website
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'jrebel_support'
name = 'JRebel Support'
email = '[email protected]'
}
}
inceptionYear = '2011'
scm {
url = 'https://github.com/zeroturnaround/gradle-jrebel-plugin'
connection = 'scm:git:[email protected]:zeroturnaround/gradle-jrebel-plugin.git'
developerConnection = 'scm:git:[email protected]:zeroturnaround/gradle-jrebel-plugin.git'
}
}
publishing {
publications {
pluginMaven(MavenPublication) { // publication name is defined by java-gradle-plugin
pom pomFile
}
}
repositories {
maven {
// Use sonatype central
if (project.hasProperty("release_to_central")) {
if (project.version.endsWith("-SNAPSHOT")) {
name = 'sonatypeNexusSnapshots'
url = 'https://oss.sonatype.org/content/repositories/snapshots'
} else {
name = 'sonatypeNexusStaging'
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
}
}
// Use zeroturnaround public repo
else {
if (project.version.endsWith("-SNAPSHOT")) {
name = 'zeroturnaroundNexusSnapshots'
url = 'https://repos.zeroturnaround.com/nexus/content/repositories/zt-public-snapshots/'
} else {
name = 'zeroturnaroundNexusReleases'
url = 'https://repos.zeroturnaround.com/nexus/content/repositories/zt-public-releases/'
}
}
// name+"Username" and name+"Password" are looked up as credential properties
credentials(PasswordCredentials)
}
}
}
afterEvaluate {
publishing {
publications {
// Created by java-gradle-plugin very late, can't be configured above
jrebelPluginMarkerMaven(MavenPublication) {
pom pomFile
}
}
}
tasks.withType(PublishToMavenRepository) {
// Releases can be published to plugin portal, don't need the marker nonsense (gradle could have designed plugin id as group:id so no redirection or conventions needed)
onlyIf {
project.version.endsWith("-SNAPSHOT") || publication != publishing.publications.jrebelPluginMarkerMaven
}
}
}
signing {
required {
gradle.taskGraph.hasTask(publish) || gradle.taskGraph.hasTask(publishPlugins)
}
sign publishing.publications.pluginMaven
}
// java-gradle-plugin creates name+"PluginMarkerMaven" in afterEvaluate
afterEvaluate {
signing {
sign publishing.publications.jrebelPluginMarkerMaven
}
}