1
1
plugins {
2
2
id ' java'
3
3
id ' jacoco'
4
+ id ' maven-publish'
5
+ id ' signing'
6
+ id ' nebula.release' version ' 13.0.0'
4
7
}
5
8
6
9
group ' org.contextmapper'
7
- version ' 1.0.0-SNAPSHOT'
8
10
9
11
sourceCompatibility = 1.8
10
12
11
13
repositories {
12
14
mavenCentral()
13
15
}
14
16
17
+ if (! project. hasProperty(' signing.secretKeyRingFile' )) {
18
+ project. ext. ' signing.secretKeyRingFile' = " ${ rootDir} /secret-key.gpg"
19
+ }
20
+
15
21
dependencies {
16
22
implementation ' org.reflections:reflections:0.9.11'
17
23
implementation ' org.springframework.boot:spring-boot-autoconfigure:2.2.0.RELEASE'
@@ -25,6 +31,119 @@ dependencies {
25
31
testRuntimeOnly group : ' org.junit.jupiter' , name : ' junit-jupiter-engine' , version : jUnitVersion
26
32
}
27
33
34
+ task sourcesJar (type : Jar ) {
35
+ from sourceSets. main. allJava
36
+ archiveClassifier = ' sources'
37
+ }
38
+
39
+ task javadocJar (type : Jar ) {
40
+ from javadoc
41
+ archiveClassifier = ' javadoc'
42
+ }
43
+
44
+ artifacts {
45
+ archives javadocJar, sourcesJar
46
+ }
47
+
48
+ signing {
49
+ sign configurations. archives
50
+ required { gradle. taskGraph. hasTask(" publishMavenJavaPublicationToMavenLocal" ) || gradle. taskGraph. hasTask(" publishMavenJavaPublicationToMavenRepository" ) }
51
+ }
52
+
53
+ publishing {
54
+ publications {
55
+ mavenJava(MavenPublication ) {
56
+ customizePom(pom)
57
+
58
+ artifactId = " ${ project.name} "
59
+ groupId = " ${ project.group} "
60
+ version = " ${ project.version} "
61
+ from components. java
62
+ artifact sourcesJar
63
+ artifact javadocJar
64
+
65
+ pom. withXml {
66
+ def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
67
+ writeTo(pomFile)
68
+ def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
69
+ artifact(pomAscFile) {
70
+ classifier = null
71
+ extension = ' pom.asc'
72
+ }
73
+ }
74
+
75
+ signArchives. signatures. each { signature ->
76
+ artifact(signature) {
77
+ def matcher = signature. file =~ / -(sources|javadoc)\. jar\. asc$/
78
+ if (matcher. find()) {
79
+ classifier = matcher. group(1 )
80
+ } else {
81
+ classifier = null
82
+ }
83
+ extension = signature. type
84
+ }
85
+ }
86
+ }
87
+ }
88
+ repositories {
89
+ maven {
90
+ def releasesRepoUrl = " ${ ossReleaseStagingRepository} "
91
+ def snapshotsRepoUrl = " ${ ossSnapshotRepository} "
92
+ url = project. version. toString(). endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
93
+
94
+ credentials {
95
+ username = System . getenv(' OSSRH_USERNAME' )
96
+ password = System . getenv(' OSSRH_PASSWORD' )
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ def customizePom (pom ) {
103
+ pom. withXml {
104
+ def root = asNode()
105
+
106
+ // eliminate test-scoped dependencies
107
+ root. dependencies. removeAll { dep ->
108
+ dep. scope == " test"
109
+ }
110
+
111
+ root. children(). last() + {
112
+ resolveStrategy = Closure . DELEGATE_FIRST
113
+
114
+ description ' A reverse engineering library to generate Context Mapper DSL (CML) models from existing source code.'
115
+ name ' Context Mapper DSL (CML) Discovery Library'
116
+ url ' https://github.com/ContextMapper/context-map-discovery'
117
+ organization {
118
+ name ' Context Mapper'
119
+ url ' https://contextmapper.org/'
120
+ }
121
+ issueManagement {
122
+ system ' GitHub'
123
+ url ' https://github.com/ContextMapper/context-map-discovery/issues'
124
+ }
125
+ licenses {
126
+ license {
127
+ name ' Apache License 2.0'
128
+ url ' https://github.com/ContextMapper/service-cutter-library/blob/master/LICENSE'
129
+ distribution ' repo'
130
+ }
131
+ }
132
+ scm {
133
+ url ' https://github.com/ContextMapper/context-map-discovery'
134
+ connection ' scm:git:git://github.com/ContextMapper/context-map-discovery.git'
135
+ developerConnection ' scm:git:ssh://git@github.com:ContextMapper/context-map-discovery.git'
136
+ }
137
+ developers {
138
+ developer {
139
+ name ' Stefan Kapferer'
140
+ email ' stefan@contextmapper.org'
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+
28
147
test {
29
148
useJUnitPlatform()
30
149
}
@@ -37,3 +156,15 @@ jacocoTestReport {
37
156
}
38
157
39
158
check. dependsOn jacocoTestReport
159
+
160
+ model {
161
+ tasks. generatePomFileForMavenJavaPublication {
162
+ destination = file(" $buildDir /generated-pom.xml" )
163
+ }
164
+ tasks. publishMavenJavaPublicationToMavenLocal {
165
+ dependsOn project. tasks. signArchives
166
+ }
167
+ tasks. publishMavenJavaPublicationToMavenRepository {
168
+ dependsOn project. tasks. signArchives
169
+ }
170
+ }
0 commit comments