-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.gradle
189 lines (170 loc) · 5.35 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
plugins {
id 'net.researchgate.release' version '3.0.0'
id 'com.gradle.plugin-publish' version '1.3.0'
id 'org.jreleaser' version '1.15.0'
}
apply from: 'gradle/integration-test.gradle'
// Plugin publishing configuration
def pluginDescription = 'Scan, evaluate and audit Gradle projects using Sonatype platforms'
def pluginUrl = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
gradlePlugin {
plugins {
scan {
id = 'org.sonatype.gradle.plugins.scan'
implementationClass = 'org.sonatype.gradle.plugins.scan.ScanPlugin'
displayName = project.name
description = pluginDescription
website = pluginUrl
vcsUrl = pluginUrl
tags.set(['sonatype', 'scan', 'dependencies', 'ossindex', 'iq server', 'lifecycle'])
System.setProperty('gradle.publish.key', System.getenv('GRADLE_PUBLISH_KEY') ?: '')
System.setProperty('gradle.publish.secret', System.getenv('GRADLE_PUBLISH_SECRET') ?: '')
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
if (JavaVersion.current() != targetCompatibility) {
throw new GradleException(
"The java version used ${JavaVersion.current()} is not the expected version ${project.targetCompatibility}.")
}
jar {
manifest {
attributes(
'Build-Timestamp' : new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZ"),
'Build-Revision' : project.version,
'Built-By' : 'Sonatype',
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
)
}
}
allprojects {
repositories {
mavenCentral()
}
}
ext {
nexusPlatformApiVersion='5.1.2-01'
ossIndexClientVersion='1.8.2'
logbackVersion='1.3.14'
commonsIoVersion='2.16.1'
junitVersion='4.13.2'
mockitoVersion='5.12.0'
assertJVersion='3.25.3'
}
dependencies {
implementation "com.sonatype.nexus:nexus-platform-api:$nexusPlatformApiVersion"
implementation "org.sonatype.ossindex:ossindex-service-client:$ossIndexClientVersion"
implementation "ch.qos.logback:logback-classic:$logbackVersion"
implementation "commons-io:commons-io:$commonsIoVersion"
testImplementation gradleTestKit()
testImplementation "junit:junit:$junitVersion"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
}
processResources {
filesMatching('com/sonatype/insight/client.properties') {
expand(project.properties)
}
}
test {
maxHeapSize = '512m'
}
publishing {
publications {
withType(MavenPublication) {
groupId = 'org.sonatype.gradle.plugins'
artifactId = project.name
version = project.version.toString()
pom {
name = project.name
description = pluginDescription
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
organization {
name = 'Sonatype'
url = 'https://www.sonatype.com'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin/issues'
}
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
connection = 'scm:git:git://github.com/sonatype-nexus-community/scan-gradle-plugin.git'
developerConnection = 'scm:git:ssh://[email protected]:sonatype-nexus-community/scan-gradle-plugin.git'
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
}
developers {
developer {
name = 'Guillermo Varela'
}
developer {
name = 'Usman Shaikh'
}
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
}
}
}
jreleaser {
project {
name = 'scan-gradle-plugin'
description = pluginDescription
website = pluginUrl
}
signing {
active = 'ALWAYS'
armored = true
def publicKey = System.getenv('JRELEASER_GPG_PUBLIC_KEY')?.decodeBase64() ?
new String(System.getenv('JRELEASER_GPG_PUBLIC_KEY').decodeBase64()) : ''
def secretKey = System.getenv('JRELEASER_GPG_SECRET_KEY')?.decodeBase64() ?
new String(System.getenv('JRELEASER_GPG_SECRET_KEY').decodeBase64()) : ''
if (publicKey) {
System.setProperty('jreleaser.gpg.public.key', publicKey)
}
if (secretKey) {
System.setProperty('jreleaser.gpg.secret.key', secretKey)
}
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
verifyPom = false
stagingRepository('build/staging-deploy')
}
}
}
}
}
// Remove unwanted "scan" directory after publishing
tasks.register('cleanupUnwantedArtifacts') {
doLast {
def unwantedDir = file("build/staging-deploy/org/sonatype/gradle/plugins/scan")
if (unwantedDir.exists()) {
println "Removing unwanted directory: $unwantedDir"
delete unwantedDir
}
}
}
afterReleaseBuild.dependsOn publish
publish.finalizedBy cleanupUnwantedArtifacts
publish.finalizedBy publishPlugins