forked from mockito/mockito
/
java-publication.gradle
114 lines (99 loc) · 3.6 KB
/
java-publication.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
group = 'org.mockito'
plugins.withId("java") {
//Sources/javadoc artifacts required by Maven module publications
def licenseSpec = copySpec {
from project.rootDir
include "LICENSE"
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
with licenseSpec
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from tasks.javadoc
with licenseSpec
}
artifacts {
archives sourcesJar
archives javadocJar
}
jar {
with licenseSpec
}
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
//Gradle Maven publishing plugin configuration (https://docs.gradle.org/current/userguide/publishing_maven.html)
apply plugin: "maven-publish"
publishing {
publications {
javaLibrary(MavenPublication) {
plugins.withId("java") {
from components.java
artifact sourcesJar
artifact javadocJar
}
plugins.withId("java-platform") {
from components.javaPlatform
}
artifactId = project.archivesBaseName
pom {
name = artifactId
description = project.description
plugins.withId("java") {
//Gradle does not write 'jar' packaging to the pom (unlike other packaging types).
//This is OK because 'jar' is implicit/default:
// https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#minimal-pom
packaging = project.tasks.jar.extension
}
url = "https://github.com/mockito/mockito"
licenses {
license {
name = 'The MIT License'
url = 'https://github.com/mockito/mockito/blob/main/LICENSE'
distribution = 'repo'
}
}
developers {
['mockitoguy:Szczepan Faber', 'bric3:Brice Dutheil', 'raphw:Rafael Winterhalter',
'TimvdLippe:Tim van der Lippe'].each { devData ->
developer {
def devInfo = devData.split(':')
id = devInfo[0]
name = devInfo[1]
url = 'https://github.com/' + devInfo[0]
roles = ["Core developer"]
}
}
}
scm {
url = 'https://github.com/mockito/mockito.git'
}
issueManagement {
url = 'https://github.com/mockito/mockito/issues'
system = 'GitHub issues'
}
ciManagement {
url = 'https://github.com/mockito/mockito/actions'
system = 'GH Actions'
}
}
}
}
//useful for testing - running "publish" will create artifacts/pom in a local dir
repositories { maven { url = "$buildDir/repo" } }
}
plugins.withId("java") {
//fleshes out problems with Maven pom generation when building
tasks.build.dependsOn("publishJavaLibraryPublicationToMavenLocal")
}
apply plugin: 'signing' //https://docs.gradle.org/current/userguide/signing_plugin.html
signing {
if (System.getenv('PGP_KEY')) {
useInMemoryPgpKeys(System.getenv('PGP_KEY'), System.getenv('PGP_PWD'))
sign publishing.publications.javaLibrary
}
}