-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
158 lines (140 loc) · 4.38 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
import java.util.regex.Pattern
import org.gradle.util.internal.VersionNumber
plugins {
id 'me.qoomon.git-versioning' version "$gitVersioningPluginVersion"
id 'io.github.gradle-nexus.publish-plugin' version "$gradleNexusPublishPluginVersion"
}
group 'com.innogames'
version '0.0.0-SNAPSHOT'
def javaVersion = 11
def gitRepository = 'innogames/junit5-scenario-builder'
def setVersionFromGit() {
// Set project version based on git branch or tag using the git-versioning plugin.
// Version can also be explicitly defined. For example:
// gradle -Dgit.ref=$PROVIDED_REF
// gradle -Dgit.branch=$PROVIDED_BRANCH_NAME
// gradle -Dgit.tag=$PROVIDED_TAG_NAME
// (See also https://github.com/qoomon/gradle-git-versioning-plugin)
gitVersioning.apply {
refs {
branch('.+') {
describeTagPattern = Pattern.compile('v(?<version>.*)')
version = '${describe.tag.version:-0.0.0}-SNAPSHOT'
}
tag('v(?<version>.*)') {
version = '${ref.version}'
}
}
}
// Use the next minor version if the determined version is a SNAPSHOT version
VersionNumber current = VersionNumber.parse(project.version)
if (current.qualifier == 'SNAPSHOT') {
logger.info('Found SNAPSHOT version. Increase minor version')
def newVersion = new VersionNumber(current.major, current.minor + 1, 0, current.qualifier)
project.setVersion(newVersion.toString())
}
logger.info("-------------------------------------------")
logger.info("Current project version: ${project.version}")
logger.info("-------------------------------------------")
}
setVersionFromGit()
allprojects {
repositories {
mavenCentral()
}
}
def javaProjects = subprojects.findAll {
return it.name != 'projects'
}
configure(javaProjects) { project ->
group = rootProject.group
version = rootProject.version
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
withJavadocJar()
withSourcesJar()
}
test {
useJUnitPlatform()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
afterEvaluate {
pom {
name = project.name
description = project.description
url = "https://github.com/${gitRepository}"
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
name = 'Christian Blos'
email = 'christian.blos@innogames.com'
organization = 'InnoGames GmbH'
organizationUrl = 'https://www.innogames.com/'
}
}
scm {
connection = "scm:git:git://github.com/${gitRepository}.git"
developerConnection = "scm:git:ssh://github.com:${gitRepository}.git"
url = "https://github.com/${gitRepository}"
}
}
}
}
}
repositories {
maven {
def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
def signingKeyId = findProperty('signing.keyId')
if (signingKeyId) {
signing {
// Use ascii-armored key when SIGNING_KEY environment variable is set.
// If not, signing.secretKeyRingFile property should be present.
def signingKey = System.getenv('SIGNING_KEY')
if (signingKey) {
useInMemoryPgpKeys(signingKeyId, signingKey, findProperty('signing.password'))
}
sign publishing.publications.mavenJava
}
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = findProperty('ossrhUsername')
password = findProperty('ossrhPassword')
}
}
}
/**
* Updates the version mentioned in the docs. It will use the determined version based on the
* current git branch or tag. You can use a specific version via -Dgit.tag=version system prop.
* E.g. `gradle -Dgit.tag=v0.1.0 updateDocumentedVersion`
*/
tasks.register('updateDocumentedVersion') {
doFirst {
File docsFile = file('docs/getting-started.md')
docsFile.write(docsFile.getText()
.replaceAll('<version>[0-9a-zA-Z.-]+</version>', "<version>${project.version}</version>")
.replaceAll('(com.innogames:junit5-scenario-builder:)[0-9a-zA-Z.-]+', "\$1${project.version}"))
}
}