-
Notifications
You must be signed in to change notification settings - Fork 10
/
publish.gradle
137 lines (125 loc) · 4.2 KB
/
publish.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
// generate changelog after tag
project.ext.set('cg.sinceTag', 'v3.1.0')
// changelog.gradle
apply from: 'https://git.io/JqJiC'
distributions.main.contents {
it.from ('README.md', 'LICENSE.txt', 'CHANGELOG.md')
// version.txt is used by version command
it.from(projectDir) {
it.include 'version.txt'
}
it.exclude {
File file = it.file
String filename = file.getName()
/*
* there is a bug that occurs when running distribution tasks on Github CI
* where the distribution archive tries to add itself to archive
* @see https://github.com/cocolabs/pz-zdoc/issues/21
*/
if (filename.startsWith(archivesBaseName) && filename.endsWithAny('.zip', '.tar')) {
return true
}
if (!CI) {
// exclude Project Zomboid classes
if (file.toPath().startsWith(zomboidClassesDir.toPath())) {
return true
}
// exclude Project Zomboid libraries
if (file.toPath().startsWith(gameDir)) {
return true
}
}
return false
}
}
// generate changelog BEFORE creating distribution
[ 'assemble', 'assembleDist', 'installDist' ].forEach({
tasks.named(it).configure({it.dependsOn('generateChangelog')})
})
// run distribution archive tasks AFTER generating changelog
[ 'distTar', 'distZip' ].forEach({
tasks.named(it).configure({it.mustRunAfter('generateChangelog')})
})
def cleanScripts = tasks.register('cleanScripts', Delete.class) {
it.description('Delete build scripts directory.')
it.group('zomboid')
it.delete("$buildDir/scripts")
}
tasks.named('installDist').configure{
it.dependsOn(cleanScripts)
}
tasks.named('startScripts').configure {
it.setWindowsStartScriptGenerator(new ZWindowsStartScriptGenerator())
it.setUnixStartScriptGenerator(new ZUnixStartScriptGenerator())
// do not add provided files to classpath, they are not included in distribution
it.classpath -= configurations.zomboidImplementation
}
// include version information in jar
jar.from 'version.txt'
task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
java {
withJavadocJar()
withSourcesJar()
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
//noinspection GroovyAssignabilityCheck
mavenJava(MavenPublication) {
from components.java
pom {
name = 'ZomboidDoc'
description = 'ZomboidDoc is a Lua library compiler for Project Zomboid.'
url = 'https://github.com/cocolabs/pz-zdoc'
scm {
connection = 'scm:git:git://github.com/cocolabs/pz-zdoc.git'
developerConnection = 'scm:git:ssh://github.com:cocolabs/pz-zdoc.git'
url = 'https://github.com/cocolabs/pz-zdoc'
}
licenses {
license {
name = 'GNU General Public License v3.0'
url = 'https://www.gnu.org/licenses/gpl-3.0.en.html'
}
}
developers {
developer {
id = 'yooks'
name = 'Matthew Cain'
email = '[email protected]'
}
}
}
}
}
}
if (project.ext.has('signingKey') && project.ext.has('signingPassword'))
{
signing {
useInMemoryPgpKeys(signingKey, signingPassword)
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/"))
}
}
}
task publishToSonatypeAndCloseStagingRepository {
description 'Publish all publications to Nexus and close staging repository.'
group 'publishing'
dependsOn = [ 'publishToSonatype', 'closeSonatypeStagingRepository' ]
}