-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
297 lines (245 loc) · 8.69 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
plugins {
id 'java-library'
// https://plugins.gradle.org/plugin/net.researchgate.release
// id 'net.researchgate.release' version '2.8.1'
// https://plugins.gradle.org/plugin/nu.studer.credentials
id 'nu.studer.credentials' version '2.1'
// https://plugins.gradle.org/plugin/io.codearte.nexus-staging
// id 'io.codearte.nexus-staging' version '0.30.0'
//https://github.com/gradle-nexus/publish-plugin/
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id 'maven-publish'
id 'signing'
}
//OrientDB version to use:
ext.arcadeDbVersion = '21.10.1'
// ejecutar: gradle idea
// para que inicialize el proyecto y baje los javadocs.
apply plugin: 'idea'
idea{
module {
downloadJavadoc=true
}
}
def info() {
println "***************************************************************"
println " SYSTEM: " + name
println "VERSION: " + version
println " JAVA: " + System.getProperty('java.home')
println "***************************************************************"
}
compileJava {
// options.compilerArgs << '-Xlint:deprecation'
// options.compilerArgs << '-Xlint:unchecked'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
// Para hace el deploy en Sonatype
// 1. Hacer el commit a github desde NB
// 2. Ejecutar: gradle release
// 3. ir a: https://oss.sonatype.org/#stagingRepositories
// buscar el repositorio y hacer clic en "Close"
// 4. Una vez cerrado hacer click en "Release"
//Para guardar el usuario y contraseña en forma segura hacer:
//gradle addCredentials -PcredentialsKey=nexusUser -PcredentialsValue=XXXXX
//gradle addCredentials -PcredentialsKey=nexusPassword -PcredentialsValue=YYYYY
//o para hacerlo más seguro:
//gradle addCredentials -PcredentialsKey=nexusUser -PcredentialsValue=XXXXX -PcredentialsPassphrase=zzzzzzzz
//gradle addCredentials -PcredentialsKey=nexusPassword -PcredentialsValue=YYYYY -PcredentialsPassphrase=zzzzzzzz
//def nexusUser = credentials.nexusUser
//def nexusPassword = credentials.nexusPassword
def sonatypeUser = credentials.sonatypeUser
def sonatypePassword = credentials.sonatypePassword
// incrementar automáticamente el buildNumber
task autoBuildNumber {
doFirst {
File propertiesFile = new File('gradle.properties')
def lines = propertiesFile.readLines()
PrintWriter printWriter = new PrintWriter(propertiesFile)
lines.each {String line ->
if (line.startsWith("version") ){
String 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()
}
}
// agregar la dependencia solo si no se trata de un release
if (! project.gradle.startParameter.taskNames.join(",").toLowerCase().contains("release") ) {
build.dependsOn autoBuildNumber
}
build.doLast {
info()
}
// seteo carpeta de fuentes para sonar
//sonarqube {
// properties {
// property "sonar.sources", "src/main"
// }
//}
// desactivo la generación de javadoc en los proyectos que tengan la tarea
javadoc.enabled = true
repositories {
// maven {
// url "$sonatypeURLRelease"
//
// credentials {
// username = "$sonatypeUser"
// password = "$sonatypePassword"
// }
// }
mavenLocal()
mavenCentral()
}
dependencies {
implementation "cglib:cglib:3.3.0"
implementation "com.github.mdre:odbogm-agent:1.1.+"
api "com.arcadedb:arcadedb-engine:${arcadeDbVersion}"
//api "com.orientechnologies:orientdb-core:${orientDbVersion}:sources"
testImplementation "junit:junit:[4,)"
testImplementation "org.easymock:easymock:4.0.2"
}
//task to find the path of the ogm agent automatically:
task findAgentPath {
configurations.runtimeClasspath.files.each {
if (it.getName().contains('odbogm-agent')) {
project.ext.setProperty('odbogmAgentPath', it.toString())
}
}
}
test {
dependsOn findAgentPath
jvmArgs '-Djdk.attach.allowAttachSelf=true', '-DridBag.embeddedToSbtreeBonsaiThreshold=-1'
jvmArgs += "-javaagent:${project.odbogmAgentPath}"
outputs.upToDateWhen { false }
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(
// 'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
// 'Premain-Class':'net.odbogm.agent.TransparentDirtyDetectorAgent',
// 'Agent-Class':'net.odbogm.agent.TransparentDirtyDetectorAgent',
// 'Can-Redefine-Classes':true,
// 'Can-Retransform-Classes':true
// )
// }
//}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
// manifest {
// attributes(
// 'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
// 'Premain-Class':'net.odbogm.agent.TransparentDirtyDetectorAgent',
// 'Agent-Class':'net.odbogm.agent.TransparentDirtyDetectorAgent',
// 'Can-Redefine-Classes':true,
// 'Can-Retransform-Classes':true
// )
// }
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
// de acuerdo a la guía de
// http://central.sonatype.org/pages/gradle.html
java {
withJavadocJar()
withSourcesJar()
}
nexusPublishing {
repositories {
sonatype()
}
}
publishing {
publications {
mavenJava(MavenPublication) {
//artifactId = 'my-library'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Java Object to ArcadeDB Graph Mapper'
packaging = 'jar'
// optionally artifactId can be defined here
description = 'ABOGM let you store/retrieve objects in a ArcadeDB graph structure in a clear and simple way.'
url = 'https://github.com/mdre/adbogm'
// properties = [
// myProp: "value",
// "prop.with.dots": "anotherValue"
// ]
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]'
}
}
scm {
connection = 'scm:git:git://github.com/mdre/adbogm.git'
developerConnection = 'scm:git:ssh://github.com/mdre/adbogm.git'
url = 'https://github.com/mdre/adbogm'
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
task runFile(dependsOn: 'classes',type:JavaExec) {
if (project.hasProperty('mainClass')) {
main = mainClass
classpath = sourceSets.main.runtimeClasspath
standardOutput = System.out
errorOutput = System.err
}
}
task debug(dependsOn: 'classes',type:JavaExec) {
if (project.hasProperty('mainClass')) {
main = mainClass
classpath = sourceSets.main.runtimeClasspath
standardOutput = System.out
errorOutput = System.err
debug true
}
}