-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
80 lines (65 loc) · 2.33 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
group 'com.thirdparty'
apply plugin: 'java'
apply plugin: 'idea'
ext {
versionRegex = '(\\d+)(\\.\\d+)*'
jacksonVersion = "2.8.4"
scanDir = "$buildDir/scan"
fixedZipFileName = 'fixed_sample_scan.zip'
}
// plugin version, note the version must match versionRegex.
version = '1.0'
if (!project.hasProperty('release')) {
// Gradle has been run without option -Prelease - auto increment plugin version
def time = System.currentTimeMillis().intdiv(1000)
def hours = time.intdiv(3600)
version = String.format('%s.%d', version, hours)
}
repositories {
mavenCentral()
}
configurations {
implementationExport
implementation.extendsFrom (implementationExport)
}
dependencies {
// dependencies provided by plugin runtime
implementation 'com.fortify.plugin:plugin-api:1.0.1.1'
implementation 'org.slf4j:slf4j-api:1.7.21'
// plugin specific dependencies
implementationExport(group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "$jacksonVersion") { transitive = false }
implementationExport(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "$jacksonVersion") { transitive = false }
implementationExport(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "$jacksonVersion") { transitive = false }
}
jar {
doFirst {
// check if version matches requirements
if (!project.version.matches(versionRegex)) {
throw new InvalidUserDataException("Plugin version '$version' does not match '$versionRegex'")
}
}
// replace version placeholders in plugin.xml
filesMatching('plugin.xml') {
filter {
it.replaceAll('<!--VERSION-->.*?<!--/VERSION-->', project.version)
}
}
// include files from implementationExport dependencies
from { configurations.implementationExport.collect { it.isDirectory() ? it : zipTree(it).matching { exclude 'META-INF/*' } } }
}
task deleteFixedScan {
doLast {
delete "$scanDir/$fixedZipFileName"
}
}
task createScanDir {
doFirst {
mkdir "$scanDir"
}
}
task (genFixedScan, dependsOn: [classes, createScanDir, deleteFixedScan], type: JavaExec) {
main = 'com.thirdparty.ScanGenerator'
classpath = sourceSets.main.runtimeClasspath
args 'fixed', "$scanDir/$fixedZipFileName"
}
build.dependsOn genFixedScan