-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
168 lines (144 loc) · 4.72 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
plugins {
id "com.jfrog.artifactory" version "4.28.3" //artifactory support
id 'groovy' // groovy support
id 'java' // java support
id 'application' // creates a JVM executable
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
id 'pmd' // code check, working on source code
id 'com.github.spotbugs' version '5.0.7' // code check, working on byte code
id 'com.diffplug.spotless' version '6.7.0'// code format
id 'com.simonharrer.modernizer' version '2.1.0-1' // detect deprecated APIs
id 'com.github.onslip.gradle-one-jar' version '1.0.6' // pack a self contained jar
id 'jacoco' // java code coverage plugin
id "org.sonarqube" version "3.3" // sonarqube
}
ext {
//version (changing these should be considered thoroughly!)
hibernateVersion = '5.3.3.Final'
log4jVersion = '2.17.2'
picoliVersion = '4.6.3'
javaVersion = JavaVersion.VERSION_17
scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
mainClass = 'edu.ie3.tools.Main'
}
group = 'com.github.ie3-institute'
version = '0.4.6'
description = 'DWDWeatherTools'
defaultTasks 'build'
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
apply from: scriptsLocation + 'pmd.gradle'
apply from: scriptsLocation + 'spotbugs.gradle'
apply from: scriptsLocation + 'spotless.gradle'
apply from: scriptsLocation + 'modernizer.gradle'
apply from: scriptsLocation + 'checkJavaVersion.gradle'
apply from: scriptsLocation + 'fatJar.gradle'
apply from: scriptsLocation + 'tests.gradle'
apply from: scriptsLocation + 'jacoco.gradle' // jacoco java code coverage
apply from: scriptsLocation + 'sonarqube.gradle' // sonarqube config
repositories {
mavenCentral() //searches in bintray's repository 'jCenter', which contains Maven Central
maven { url 'https://jitpack.io' } // allows github repos as dependencies
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
dependencies {
//hibernate
implementation 'org.hibernate:hibernate-core:' + hibernateVersion
implementation 'org.hibernate:hibernate-ehcache:' + hibernateVersion
//JAXB (needed for hibernate, but not longer contained in JDK9+)
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'com.sun.xml.bind:jaxb-core:4.0.0'
implementation 'com.sun.xml.bind:jaxb-impl:4.0.0'
implementation 'javax.activation:activation:1.1.1'
//database
implementation 'org.postgresql:postgresql:42.3.6'
implementation 'javax.persistence:javax.persistence-api:2.2'
// logging
implementation "org.apache.logging.log4j:log4j-1.2-api:$log4jVersion" // log4j
implementation "org.apache.logging.log4j:log4j-core:$log4jVersion" // log4j
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'org.jetbrains:annotations:23.0.0'
annotationProcessor "info.picocli:picocli-codegen:$picoliVersion"
implementation "info.picocli:picocli:$picoliVersion"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
//tests
testImplementation 'junit:junit:4.+'
testImplementation 'org.testcontainers:postgresql:1.17.2'
}
wrapper {
gradleVersion = '7.2'
}
/* Maven publish - start */
task sourcesJar(type: Jar) {
getArchiveClassifier().set('sources')
from(sourceSets.main.allJava)
}
task javadocJar(type: Jar) {
getArchiveClassifier().set('javadoc')
from(javadoc.destinationDir)
}
if (project.hasProperty('user') && project.hasProperty('password')) {
artifactory {
contextUrl = "https://simona.ie3.e-technik.tu-dortmund.de/artifactory"
publish {
repository {
def releasesRepoUrl = 'libs-release-local'
def snapshotsRepoUrl = 'libs-snapshot-local'
repoKey = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
username = project.getProperty('user')
password = project.getProperty('password')
maven = true
}
defaults {
publications('mavenJava')
}
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'dwdtools'
from components.java
artifact sourcesJar
artifact javadocJar
artifact fatJar
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "$buildDir/repos/releases"
def snapshotsRepoUrl = "$buildDir/repos/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
/* Maven publish - end */
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainClassName = mainClass
}
jar {
manifest {
attributes(
'Main-Class': mainClass
)
}
}
run {
// Gradle uses an empty Input as default, leading to a non-blocking behaviour and thus an immediate shutdown
standardInput = System.in
}