-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
324 lines (259 loc) · 10.3 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
// los recursos se deben agregar en /src/main/resources/META-INF/resources/frontend/...
// https://vaadin.com/blog/vaadin-10-and-static-resources
plugins {
id 'java'
id 'org.gretty' version '3.0.1'
id 'net.researchgate.release' version '2.8.1'
id 'nu.studer.credentials' version '1.0.7'
id 'io.codearte.nexus-staging' version '0.21.1'
}
apply plugin: 'maven'
apply plugin: 'signing'
def sonatypeUser = credentials.sonatypeUser
def sonatypePassword = credentials.sonatypePassword
def vaadinVersion = "23.3.14"
description = rootProject.name
// ejecutar: gradle idea
// para que inicialize el proyecto y baje los javadocs.
apply plugin: 'idea'
idea{
module{
downloadJavadoc=true
}
}
// desactivo la generación de javadoc en los proyectos que tengan la tarea
javadoc.enabled = true
println "***************************************************************"
println "SISTEMA: " + name
println "VERSION: " + version
println "***************************************************************"
import java.text.SimpleDateFormat
def getCurrentTimestamp ()
{
Date today = new Date ()
SimpleDateFormat df = new SimpleDateFormat ("dd/MM/yyyy hh:mm:ss")
return df.format (today)
}
println getCurrentTimestamp()
println "---------------------------------------------------------------"
// incrementar automáticamente el buildNumber
task autoBuildNumber {
doFirst {
File propertiesFile = new File('gradle.properties')
def lines = propertiesFile.readLines()
PrintWriter printWriter = new PrintWriter(propertiesFile)
String versionNumber = ""
lines.each {String line ->
if (line.startsWith("version") ){
versionNumber = line.tokenize("=")[1]
String[] versionParts = versionNumber.tokenize(".")
// recalcular el build
versionNumber = versionParts[0]+\
'.'+versionParts[1]+\
'.'+versionParts[2]+
'.'+( versionParts.length==4 ? (versionParts[3].toInteger()+1).toString():"1")
line = "version="+versionNumber
// println line
}
printWriter.println(line)
}
printWriter.close()
}
}
// saltar autoBuildNumber
// agregar esta tarea para que no se incremente el valor.
task sabn{}
task createMavenPom {
doLast {
println"creando el POM..."
mkdir("build/resources/main/META-INF/maven/$project.group/$project.archivesBaseName")
pom {}.writeTo("build/resources/main/META-INF/maven/$project.group/$project.archivesBaseName/pom.xml")
file("build/resources/main/META-INF/maven/$project.group/$project.archivesBaseName/pom.properties").text = """\
version=$project.version
groupId=$project.group
artifactId=$project.archivesBaseName
""".stripIndent()
}
}
// agregar la dependencia solo si no se trata de un release
if (! (project.gradle.startParameter.taskNames.join(",").toLowerCase().contains("release")
|| project.gradle.startParameter.taskNames.join(",").toLowerCase().contains("sabn"))
) {
build.dependsOn autoBuildNumber
}
build.dependsOn createMavenPom
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
url "https://mvnrepository.com/artifact/com.vaadin/vaadin"
}
}
dependencies {
compile("com.vaadin:vaadin-core:${vaadinVersion}")
}
test {
testLogging {
// Make sure output from
// standard out or error is shown
// in Gradle output.
showStandardStreams = true
// Or we use events method:
// events 'standard_out', 'standard_error'
// Or set property events:
// events = ['standard_out', 'standard_error']
// Instead of string values we can
// use enum values:
// events org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_OUT,
// org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_ERROR,
}
}
jar {
manifest {
attributes(
"Manifest-Version": "1.0",
"Vaadin-Package-Version": "1",
"Vaadin-Addon": artifactId+"-"+version+".jar",
"Implementation-Vendor": "MarceloDRe",
"Implementation-Title": "$title",
"Implementation-Version": "$version"
)
}
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
//===============================================================================
// Vaadin Directory stuff
//===============================================================================
ext.copyFile = {String srcF, String destF ->
File src = new File(srcF)
File dest = new File(destF)
if (src.isFile()) {
dest << src.bytes
} else {
throw new Exception("el archivo "+srcF+" no existe!")
}
}
task createVaadinDirectoryRelease(type: Zip) {
if (project.gradle.startParameter.taskNames.join(",").toLowerCase().contains("createvaadindirectoryrelease")) {
group = 'Welcome'
description = 'Crear un paquete para subir a Vaadin Directory'
BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
print "Ingrese la versión a utilizar (Version actual: ${version}): "
def targetVersion = br.readLine()
if (!targetVersion) {
targetVersion = version
}
println "preparando el paquete..."
String VAADINDIRECTORY = "toVaadinDirectory"
String vaadinDistDir = VAADINDIRECTORY+"/dist"
File toVaadinDirectory = new File(VAADINDIRECTORY)
File fVaadinDistDir = new File(vaadinDistDir)
File vdMetaInf = new File(vaadinDistDir+"/META-INF")
// borrar cualquier referencia previa
if (toVaadinDirectory.isDirectory()) {
toVaadinDirectory.deleteDir()
}
// crear el directorio
toVaadinDirectory.mkdir()
fVaadinDistDir.mkdir()
vdMetaInf.mkdir()
// crear el manifest
println "creando el manifest..."
File vdManifest = new File(vaadinDistDir+"/META-INF/MANIFEST.MF")
vdManifest.write("Manifest-Version: 1.0\n")
vdManifest << "Vaadin-Package-Version: 1\n"
vdManifest << "Vaadin-Addon: bubbledialog-"+targetVersion+".jar\n"
vdManifest << "Implementation-Vendor: MarceloDRe \n"
vdManifest << "Implementation-Title: BubbleDialog component for Vaadin Flow 14.+\n"
vdManifest << "Implementation-Version: "+targetVersion+"\n"
// copiar los archivos al directorio
// requiere jar, sourceJar y javadoc y le readme.md
println "copiando los archivos..."
copyFile("build/libs/"+project.name+"-"+targetVersion+".jar", vaadinDistDir+"/"+project.name+"-"+targetVersion+".jar")
copyFile("build/libs/"+project.name+"-"+targetVersion+"-sources.jar", vaadinDistDir+"/"+project.name+"-"+targetVersion+"-sources.jar")
copyFile("build/libs/"+project.name+"-"+targetVersion+"-javadoc.jar", vaadinDistDir+"/"+project.name+"-"+targetVersion+"-javadoc.jar")
copyFile("./README.md", vaadinDistDir+"/README.md")
println "comprimiendo..."
// crear el zip para subir
// parámetros específicos del task Zip
archiveName = project.name+"-"+targetVersion+".zip"
destinationDir = file(VAADINDIRECTORY)
from vaadinDistDir
println "finalizado."
}
}
// de acuerdo a la guía de
// http://central.sonatype.org/pages/gradle.html
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
//required { gradle.taskGraph.hasTask("uploadArchives")}
// ext."signing.keyId"= credentials.gpgKeyId
// ext."signing.password"= credentials.gpgKeyPassword
// ext."signing.secretKeyRingFile" = credentials.gpgKeyRingFile
// println ext."signing.keyId"
sign(configurations.archives)
}
nexusStaging {
packageGroup = "com.github.mdre" //optional if packageGroup == project.getGroup()
// stagingProfileId = "yourStagingProfileId" //when not defined will be got from server using "packageGroup"
}
//sube a nexus
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: "$sonatypeURLRelease") {
authentication(userName: credentials.sonatypeUser, password: credentials.sonatypePassword)
}
snapshotRepository(url: "$sonatypeURLSnapshot") {
authentication(userName: credentials.sonatypeUser, password: credentials.sonatypePassword)
}
pom.groupId = 'com.github.mdre'
pom.artifactId = 'bubbledialog'
pom.project {
name 'BubbleDialog component for Vaadin Flow 13.+'
packaging 'jar'
// optionally artifactId can be defined here
description 'BubbleDialog for Vaadin Flow 13.+.'
url 'https://github.com/mdre/bubbledialog'
scm {
connection 'scm:git:git://github.com/mdre/bubbledialog.git'
developerConnection 'scm:git:ssh://github.com/mdre/bubbledialog.git'
url 'https://github.com/mdre/bubbledialog'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'mdre'
name 'Marcelo D. RE'
email '[email protected]'
}
}
}
}
}
}
createReleaseTag.dependsOn ':uploadArchives'