-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathbuild.gradle
295 lines (260 loc) · 9.63 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
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Gradle plugin project to get you started.
* For more details take a look at the Writing Custom Plugins chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.6.3/userguide/custom_plugins.html
*/
plugins {
// Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins
id 'idea'
id 'jacoco'
id 'maven-publish'
id 'java-gradle-plugin'
id 'org.sonarqube' version '5.1.0.4882'
id 'com.gradle.plugin-publish' version '1.3.0'
id 'com.github.sherter.google-java-format' version '0.9'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'org.owasp.dependencycheck' version '11.1.0'
}
ext {
bcRepo = 'https://github.com/bancolombia/scaffold-clean-architecture'
bcPluginName = 'Scaffold Clean Architecture Bancolombia'
bcPluginDescription = 'Gradle plugin to create a clean application in Java that already works, It follows our best practices!'
}
group 'co.com.bancolombia.cleanArchitecture'
version System.getProperty('version')
repositories {
mavenCentral()
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
test {
maxParallelForks = 2
useJUnitPlatform()
}
if (project.hasProperty('signing.keyId')) { // publish as library in maven central
apply plugin: 'signing'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = bcPluginName
description = bcPluginDescription
url = bcRepo
licenses {
license {
name = "APACHE LICENSE, VERSION 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0"
distribution = "repo"
}
}
developers {
developer {
id = "santitigaga"
name = "Santiago Garcia Gil"
email = "[email protected]"
}
developer {
id = "juancgalvis"
name = "Juan Carlos Galvis"
email = "[email protected]"
}
}
scm {
url = bcRepo
}
}
}
}
}
nexusPublishing {
repositories {
sonatype() {
group = "com.github.bancolombia"
}
}
}
signing {
sign(publishing.publications.mavenJava)
}
java {
withJavadocJar()
withSourcesJar()
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
javadoc.failOnError = false
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
def signingTasks = tasks.withType(Sign)
signingTasks.forEach { project.logger.lifecycle('task sign: ' + it.name) }
tasks.withType(PublishToMavenRepository).configureEach { task ->
project.logger.lifecycle('task publish: ' + task.name)
if (task.name == 'publishMavenJavaPublicationToSonatypeRepository') {
project.logger.lifecycle('Applied to ' + task.name)
task.mustRunAfter('signMavenJavaPublication')
task.mustRunAfter('signPluginMavenPublication')
} else {
task.enabled = false
}
}
} else { // publish as plugin in gradle and github
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/bancolombia/scaffold-clean-architecture")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
gradlePlugin {
// Define the plugin
website = 'https://github.com/bancolombia/scaffold-clean-architecture'
vcsUrl = 'https://github.com/bancolombia/scaffold-clean-architecture'
plugins {
cleanArchitecture {
id = 'co.com.bancolombia.cleanArchitecture'
displayName = bcPluginName
description = bcPluginDescription
implementationClass = 'co.com.bancolombia.PluginClean'
tags.set(['scaffold', 'cleanArchitecture', 'Bancolombia', 'OpenSource'])
}
}
}
// Add a source set for the functional test suite
sourceSets {
functionalTest {
}
}
gradlePlugin.testSourceSets(sourceSets.functionalTest)
configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation)
// Add a task to run the functional tests
tasks.register('functionalTest', Test) {
description = 'Runs functional tests.'
group = 'verification'
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}
check {
// Run the functional tests as part of `check`
dependsOn(tasks.functionalTest)
}
}
dependencies {
api 'com.github.spullara.mustache.java:compiler:0.9.14'
api 'com.fasterxml.jackson.core:jackson-databind:2.18.1'
api 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.1'
api 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.1'
api 'commons-io:commons-io:2.17.0'
api gradleApi()
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1'
implementation 'org.reflections:reflections:0.10.2'
// swagger generators
implementation('io.swagger.codegen.v3:swagger-codegen-generators:1.0.54') {
exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
}
constraints { // for previous swagger dependency
implementation('commons-codec:commons-codec:1.17.1') {
because "This version closes a security vulnerability"
}
}
implementation 'com.googlecode.lambdaj:lambdaj:2.3.3'
implementation 'com.google.googlejavaformat:google-java-format:1.24.0'
testImplementation gradleTestKit()
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.3'
compileOnly 'org.projectlombok:lombok:1.18.36'
annotationProcessor 'org.projectlombok:lombok:1.18.36'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
}
jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.setRequired true
xml.setOutputLocation layout.buildDirectory.file("reports/jacoco/report.xml")
html.setRequired true
csv.setRequired false
}
}
sonar {
properties {
property "sonar.organization", "grupo-bancolombia"
property "sonar.projectKey", "bancolombia_scaffold-clean-architecture"
property "sonar.host.url", "https://sonarcloud.io/"
property "sonar.sources", "."
property "sonar.java.binaries", "build/classes"
property "sonar.junit.reportPaths", "build/test-results/test"
property "sonar.java-coveragePlugin", "jacoco"
property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/report.xml"
property "sonar.test", "src/test/java"
property "sonar.exclusions", "docs/**,.github/**,src/functionalTest/**,src/test/**/*Test.java,**/**models**,src/test/**/TestUtils.java,src/test/**/*Provider.java,**/**exceptions**,**/examples-ca/**,src/test/**/AnUpdate*.java,**/LocalTasks.java"
property "sonar.sourceEncoding", "UTF-8"
}
}
googleJavaFormat {
toolVersion = "1.7"
exclude '**/examples-ca/**'
exclude '**/UtilsTest.java'
}
dependencyCheck {
format = 'JSON'
failOnError = false
}
////////////////////////////////////////////////////////////////////////
//
// Google Java Format pre-commit hook installation
// Semantic Commit Hook installation
//
//
tasks.register('copyPreCommit', Copy) {
from 'config/hooks/pre-commit'
into '.git/hooks'
fileMode 0777
}
tasks.register('downloadCommitMessage') {
def f = new File('.git/hooks/commit-msg.sample2')
if (!f.exists()) {
new URL('https://raw.githubusercontent.com/hazcod/semantic-commit-hook/master/commit-msg').withInputStream {
i -> f.withOutputStream { it << i }
}
}
}
tasks.register('fileModeCommitMessage', Copy) {
dependsOn 'downloadCommitMessage', 'copyPreCommit'
from '.git/hooks/commit-msg.sample2'
into '.git/hooks/'
rename 'commit-msg.sample2', 'commit-msg'
fileMode 0777
}
tasks.register('installGitHooks') {
dependsOn 'copyPreCommit', 'downloadCommitMessage', 'fileModeCommitMessage'
doLast {
println 'GitHooks installed!'
}
}
tasks.named('wrapper') {
gradleVersion = '8.11'
}
tasks.register('ci-updater', JavaExec) {
// Replace com.example.MainClass with the fully qualified name of your main class
mainClass = 'co.com.bancolombia.utils.offline.LocalTasks'
classpath = sourceSets.main.runtimeClasspath
// Add any additional JVM arguments if needed
// jvmArgs = ['-Xmx512m']
}