-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathbuild.gradle
More file actions
144 lines (129 loc) · 4.42 KB
/
Copy pathbuild.gradle
File metadata and controls
144 lines (129 loc) · 4.42 KB
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
plugins {
id 'base'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id "com.github.ben-manes.versions" version "0.54.0"
id "com.gorylenko.gradle-git-properties" version "4.0.1" apply false
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
// ./gradlew dependencyUpdates
allprojects {
group = 'org.sitemesh'
repositories { mavenCentral() }
}
subprojects {
// Aggregator projects (e.g. :examples) exist only to group child projects
// by directory convention and get no build conventions of their own.
if (!buildFile.exists()) {
return
}
// Examples are runnable demos, not published artifacts — especially now
// that their project names (:examples:struts etc.) are too generic to be
// Maven coordinates under org.sitemesh.
boolean isExample = path.startsWith(':examples:')
apply plugin: 'java-library'
if (!isExample) {
apply plugin: 'maven-publish'
apply plugin: 'signing'
}
apply plugin: 'com.gorylenko.gradle-git-properties'
java {
toolchain { languageVersion = JavaLanguageVersion.of(17) }
withSourcesJar()
withJavadocJar()
}
// Stamp the version into the jar manifest so Package.getImplementationVersion()
// resolves at runtime (used by the "SiteMesh <version> initialized" startup log).
tasks.named('jar') {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Specification-Title': project.name,
'Specification-Version': project.version
)
}
}
// gradle-git-properties 4.x emits git.properties into a generated resources
// source dir that sourcesJar also reads. Declare the dependency Gradle 9
// requires, and keep the generated file out of the published -sources.jar
// (it still ships in the runtime jar via processResources, as before).
tasks.named('sourcesJar') {
dependsOn 'generateGitProperties'
exclude 'git.properties'
}
if (isExample) {
return
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = project.name
description = 'SiteMesh 3 – HTML decoration and layout framework'
url = 'https://github.com/sitemesh/sitemesh3'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0'
distribution = 'repo'
}
}
scm {
url = 'https://github.com/sitemesh/sitemesh3'
connection = 'scm:git:https://github.com/sitemesh/sitemesh3.git'
developerConnection = 'scm:git:ssh://git@github.com/sitemesh/sitemesh3.git'
}
developers {
developer {
id = 'sitemesh'
name = 'SiteMesh Contributors'
url = 'https://github.com/sitemesh'
}
}
}
}
}
}
signing {
def key = findProperty('signing.key') as String
def pass = findProperty('signing.password') as String
if (key && pass) {
useInMemoryPgpKeys(key, pass)
sign publishing.publications
}
}
}
// The maven-publish/signing/nexus-publish stack is not configuration-cache
// compatible; declaring the incompatibility makes publish builds skip the
// cache instead of failing.
allprojects {
tasks.configureEach { task ->
if (task instanceof org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
|| task instanceof org.gradle.api.publish.maven.tasks.GenerateMavenPom
|| task instanceof org.gradle.plugins.signing.Sign
|| task.class.name.startsWith('io.github.gradlenexus')) {
task.notCompatibleWithConfigurationCache('publishing plugins do not support the configuration cache')
}
}
}
nexusPublishing {
packageGroup.set('org.sitemesh')
repositories {
sonatype {
nexusUrl.set(uri('https://ossrh-staging-api.central.sonatype.com/service/local/'))
snapshotRepositoryUrl.set(uri('https://central.sonatype.com/repository/maven-snapshots/'))
username.set(providers.gradleProperty('sonatypeUsername'))
password.set(providers.gradleProperty('sonatypePassword'))
}
}
}