-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
161 lines (139 loc) · 5.48 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
buildscript {
repositories { mavenCentral() }
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.1'
}
}
plugins {
id 'groovy'
id 'eclipse'
id 'maven'
id 'signing'
id 'org.springframework.boot' version '1.5.2.RELEASE'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.1'
id 'com.github.hierynomus.license' version '0.14.0'
}
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
tasks.withType(GroovyCompile) { options.encoding = 'UTF-8' }
group = 'com.blackducksoftware.integration'
// Detect version
version = '2.2.0-SNAPSHOT'
apply from: 'airgap.gradle'
// BuildInfo - A json payload usable by detect for information from the build
JsonBuilder jsonBuilder = new JsonBuilder()
jsonBuilder { detect version }
final def buildConfigurationFile = new File("${projectDir}/src/main/resources/buildInfo.json")
buildConfigurationFile.delete()
buildConfigurationFile << jsonBuilder.toPrettyString()
// the override.snaphot property should be set to true for a CI build so
// that the version is omitted from a snapshot build artifact
if (version.contains('SNAPSHOT') && "true" == project.findProperty('override.snapshot')) {
version = 'latest-SNAPSHOT'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
build {
doLast {
def shellScriptTemplateFile = new File("${projectDir}/src/main/resources/hub-detect-sh")
def shellScriptContents = shellScriptTemplateFile.getText('UTF-8')
if (!version.contains('SNAPSHOT')) {
String latestReleaseVersion = 'DETECT_LATEST_RELEASE_VERSION=\\${DETECT_LATEST_RELEASE_VERSION:-' + "${version}" + '}\n'
shellScriptContents = shellScriptContents.replaceFirst("DETECT_LATEST_RELEASE_VERSION=\\S*\n", latestReleaseVersion)
shellScriptTemplateFile.delete()
shellScriptTemplateFile << shellScriptContents
}
def shellScriptFile = new File("${buildDir}/hub-detect.sh")
shellScriptFile.delete()
shellScriptFile << shellScriptContents
shellScriptFile.setExecutable(true)
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
compile 'com.blackducksoftware.integration:hub-common:18.3.0'
compile 'org.springframework.boot:spring-boot-starter'
compile 'org.apache.maven.shared:maven-invoker:3.0.0'
compile 'com.esotericsoftware.yamlbeans:yamlbeans:1.11'
compile 'com.moandjiezana.toml:toml4j:0.7.1'
compile 'org.codehaus.groovy:groovy-all:2.4.11'
compile 'org.freemarker:freemarker:2.3.26-incubating'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.2'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
springBoot { mainClass = 'com.blackducksoftware.integration.hub.detect.Application' }
jacocoTestReport {
reports { xml.enabled = true }
}
license {
header = file('HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ignoreFailures = true
includes (["**/*.groovy", "**/*.java"])
excludes ([
"/src/test/*.groovy",
"src/test/*.java"
])
}
tasks.licenseMain.dependsOn(licenseFormatMain)
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task customSigning(dependsOn: ['javadocJar', 'sourcesJar']) {
doLast {
File libDirectory = new File("${buildDir}/libs")
File[] jarFiles = libDirectory.listFiles(new FilenameFilter() {
@Override
boolean accept(File dir, String name) {
if (name.endsWith(".jar")) {
return true
}
return false
}
})
println "Signing Jar files"
signing.sign(jarFiles)
pom {
project {
name rootProject.name
description rootProject.description
url 'https://github.com/blackducksoftware/hub-detect'
packaging 'jar'
scm {
connection 'scm:git:git://github.com/blackducksoftware/hub-detect.git'
developerConnection 'scm:git:[email protected]:blackducksoftware/hub-detect.git'
url 'https://www.github.com/blackducksoftware/hub-detect'
}
licenses {
license {
name 'Apache License 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id 'blackduckoss'
name 'Black Duck OSS'
email '[email protected]'
organization 'Black Duck Software, Inc.'
organizationUrl 'http://www.blackducksoftware.com'
roles { role 'developer' }
timezone 'America/New_York'
}
}
}
}.writeTo("${buildDir}/poms/${rootProject.name}-${rootProject.version}.pom")
File pomFile = file("${buildDir}/poms/${rootProject.name}-${rootProject.version}.pom")
signing.sign(pomFile)
}
}