forked from ramonwirsch/protostuff-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
176 lines (152 loc) · 4.63 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
import java.time.Duration
plugins {
id "com.gradle.plugin-publish" version "0.14.0"
id "java-gradle-plugin"
id 'groovy'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version "1.1.0"
}
group = project.'meta.groupId'
version = project.'meta.version'
dependencies {
compile gradleApi()
compile group: 'io.protostuff', name: 'protostuff-compiler', version: '1.6.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
ext {
pluginId = group
description = project.'meta.description'
githubPath = project.'meta.githubPath'
vcsUrl = "https://github.com/$project.ext.githubPath"
displayName = project.'meta.name'
license = project.'meta.license'
licenseUrl = "$project.ext.vcsUrl/blob/master/LICENSE"
artifactId = project.'meta.artifact'
}
if (project.hasProperty('signing.secretKeyRingFile')) {
project.'signing.secretKeyRingFile' = project.'signing.secretKeyRingFile'
.replace('~', System.getProperty('user.home'))
}
repositories {
mavenCentral()
}
task sourceJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier.value 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier.value 'javadoc'
}
artifacts {
archives sourceJar
archives javadocJar
}
gradlePlugin {
plugins {
protostuffCompilerPlugin {
id = project.ext.pluginId
implementationClass = 'io.protostuff.gradle.ProtostuffCompilerPlugin'
}
}
}
pluginBundle {
website = project.ext.vcsUrl
vcsUrl = project.ext.vcsUrl
description = project.ext.description
tags = ['protostuff', 'protobuf']
plugins {
protostuffCompilerPlugin {
displayName = project.ext.displayName
}
}
}
publishing {
repositories {
mavenLocal()
}
publications {
pluginPublication(MavenPublication) {
groupId = project.group
artifactId = project.ext.artifactId
version = project.version
from components.java
artifact sourceJar
artifact javadocJar
}
}
}
signing {
required { project.hasProperty('signing.keyId') && project.hasProperty('signing.secretKeyRingFile') }
}
java.toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
project.afterEvaluate {
publishing.publications.each {
it.pom {
name = project.ext.displayName
description = project.ext.description
url = project.ext.vcsUrl
licenses {
license {
name = project.ext.license
url = project.ext.licenseUrl
}
}
developers {
developer {
id = 'denis-itskovich'
name = 'Denis Itskovich'
email = '[email protected]'
}
}
scm {
connection = "scm:git:git://github.com/${project.ext.githubPath}.git"
developerConnection = "scm:git:ssh://github.com/${project.ext.githubPath}.git"
url = project.ext.vcsUrl
}
}
project.signing.sign it
}
}
def isSnapshot = project.version.endsWith '-SNAPSHOT'
if (!isSnapshot &&
project.hasProperty('sonatype.username') &&
project.hasProperty('sonatype.password') &&
project.hasProperty('sonatype.baseUrl')) {
def sonatypeUser = project.'sonatype.username' as String
def sonatypePassword = project.'sonatype.password' as String
def sonatypeUrl = project.'sonatype.baseUrl' as String
publishing {
repositories {
maven {
url "$sonatypeUrl/service/local/staging/deploy/maven2/"
credentials {
username sonatypeUser
password sonatypePassword
}
}
}
}
project.nexusPublishing {
repositories {
it.sonatype { //only for users registered in Sonatype after 24 Feb 2021
nexusUrl = uri("$sonatypeUrl/service/local/")
snapshotRepositoryUrl = uri("$sonatypeUrl/content/repositories/snapshots/")
username = sonatypeUser
password = sonatypePassword
}
}
it.transitionCheckOptions {
it.maxRetries.value 120
it.delayBetween.value Duration.ofSeconds(10)
}
}
project.afterEvaluate {
project.tasks.create("publishAndRelease") {
dependsOn(project.publishToSonatype, project.closeAndReleaseSonatypeStagingRepository)
}
}
}