-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
145 lines (124 loc) · 4.94 KB
/
build.gradle
File metadata and controls
145 lines (124 loc) · 4.94 KB
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
import java.nio.charset.StandardCharsets
import java.text.SimpleDateFormat
import com.github.spotbugs.snom.Effort
import org.apache.commons.configuration2.FileBasedConfiguration
import org.apache.commons.configuration2.PropertiesConfiguration
import proguard.gradle.ProGuardTask
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath 'com.gradleup.shadow:shadow-gradle-plugin:9.4.1'
classpath 'org.apache.commons:commons-configuration2:2.13.0'
classpath 'com.guardsquare:proguard-gradle:7.9.0'
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.4.8'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:7.2.3.7755'
}
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'com.gradleup.shadow'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'idea'
apply plugin: 'com.github.spotbugs'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
tasks.withType(JavaCompile) {
options.release = 21
}
ext {
privkeyid = '99'
privkeyfile = "$rootDir/config/priv_key"
pubkeyfile = "$rootDir/config/pub_key"
mxtfile = project.layout.buildDirectory.dir("${rootProject.name}-${project.name}-v${getConfigValueForKey("module_build")}.mxt")
outjar = project.layout.buildDirectory.dir("proguard-${rootProject.name}-v${getConfigValueForKey("module_build")}.jar")
}
repositories {
mavenCentral()
flatDir dirs: "$rootDir/lib"
}
jar {
archiveBaseName.set(rootProject.name)
manifest {
attributes ((java.util.jar.Attributes.Name.IMPLEMENTATION_TITLE.toString()): getConfigValueForKey("module_name"),
(java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION.toString()): getConfigValueForKey("module_build"),
(java.util.jar.Attributes.Name.IMPLEMENTATION_VENDOR.toString()): getConfigValueForKey("vendor"),
'Built-By': System.getProperty('user.name'),
'Built-Date': getCurrentTimestamp(),
'Created-By': System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')')
}
}
tasks.named('shadowJar').configure {
archiveBaseName.set(rootProject.name)
from 'NOTICE'
from 'LICENSE'
exclude 'META-INF/**/*'
dependencies {
include project(':core')
include dependency('org.apache.commons:commons-configuration2:2.13.0')
include dependency('org.apache.commons:commons-lang3:3.20.0')
include dependency('org.apache.commons:commons-text:1.15.0')
include dependency('commons-io:commons-io:2.21.0')
include dependency('org.slf4j:slf4j-api:2.0.17')
include dependency('org.slf4j:slf4j-nop:2.0.17')
}
relocate 'org.apache.commons.io', 'com.moneydance.modules.features.importlist.org.apache.commons.io'
relocate 'org.apache.commons.lang3', 'com.moneydance.modules.features.importlist.org.apache.commons.lang3'
relocate 'org.apache.commons.text', 'com.moneydance.modules.features.importlist.org.apache.commons.text'
relocate 'org.apache.commons.configuration2', 'com.moneydance.modules.features.importlist.org.apache.commons.configuration2'
}
tasks.register('proguard', ProGuardTask) {
dependsOn 'shadowJar'
injars shadowJar.archiveFile.get().asFile
outjars outjar.get().asFile
configuration 'config/proguard.cfg'
}
tasks.named('proguard').configure {
doLast {
outjar.get().asFile.renameTo(file(mxtfile))
}
}
checkstyle {
toolVersion = '10.25.0'
}
pmd {
consoleOutput = true
toolVersion = "7.19.0"
ruleSets = []
ruleSetFiles = files("$rootDir/config/pmd-ruleSet.xml")
}
tasks.withType(Pmd) {
enabled = it.name.endsWith('Main')
}
spotbugs {
toolVersion = "4.9.3"
effort = Effort.valueOf('MAX')
excludeFilter = file("$rootDir/config/spotbugs-exclude.xml")
}
jacoco {
toolVersion = "0.8.13"
}
sonar {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "my-flow"
}
}
}
String getCurrentTimestamp() {
Date today = new Date()
SimpleDateFormat df = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss')
return df.format(today)
}
String getConfigValueForKey(String key) {
file("${project(':core').projectDir}/src/main/resources/com/moneydance/modules/features/importlist/meta_info.dict").withInputStream {
final FileBasedConfiguration config = new PropertiesConfiguration();
config.read(new InputStreamReader(it, StandardCharsets.UTF_8))
return config.getString("\"" + key + "\"").replaceAll("^\"|\"\$", "");
}
}