-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle
141 lines (120 loc) · 4.09 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
138
139
140
141
apply plugin: 'maven-publish'
apply from: 'config.gradle'
// ========== Auto Gen Variables ========== //
def baseArtifactId = "${rootProject.name.toLowerCase()}"
def artifactGroupId = "${groupTLD}.${groupName}"
def releaseDir = "${releasesRepoUrl}/${groupTLD}/${groupName}/${baseArtifactId}"
def vendorFileOutput = file("${releaseDir}/${pubVersion}/${rootProject.name}-${pubVersion}.json")
def vendorFileOutputLatest = file("${releaseDir}/${rootProject.name}-latest.json")
// ========== Building ========== //
task libraryBuild() {}
task sourcesJar(type: Jar, dependsOn: classes) {
group='building'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
group='building'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
libraryBuild.dependsOn build
publishing {
repositories {
maven {
name = "Local"
url = releasesRepoUrl
}
}
}
task cleanReleaseRepo(type: Delete) {
group = 'supercore'
delete releasesRepoUrl
delete releaseDir
}
// tasks.matching {it != cleanReleaseRepo}.all {it.dependsOn cleanReleaseRepo}
model {
publishing {
publications {
java(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
artifactId = "${baseArtifactId}"
groupId artifactGroupId
version pubVersion
}
}
}
}
// ========== Publishing ========== //
task generateVendorJson() {
description = "Generates the WPILib vendor JSON file"
group = "supercore"
outputs.file vendorFileOutput
inputs.file vendorFileInput
doLast {
println "Writing version ${pubVersion} to $vendorFileOutput"
if (vendorFileOutput.exists()) {
vendorFileOutput.delete()
}
def read = vendorFileInput.text.replace('${pubVersion}', pubVersion).replace('${baseArtifactId}', baseArtifactId).replace('${artifactGroupId}', artifactGroupId)
vendorFileOutput.write(read)
if (vendorFileOutputLatest.exists()) {
vendorFileOutputLatest.delete()
}
vendorFileOutputLatest.write(read)
}
}
task createWebFolders(type: Exec) {
group = 'supercore'
description = 'Creates index.html files to make releases navigatable.'
println "Creating web folders."
executable "bash"
args "-c","source create_webdir.sh"
}
tasks.register('publishSuperCORE') {
group = 'supercore'
description = 'Publishes all Maven publications to the listed Maven repository.'
dependsOn clean
dependsOn tasks.withType(PublishToMavenRepository).matching {
it.repository == publishing.repositories.Local
}
dependsOn tasks.generateVendorJson
finalizedBy tasks.createWebFolders
finalizedBy tasks.publishJavaDoc
}
tasks.register('cleanPublishSuperCORE') {
group = 'supercore'
description = 'Cleans releases and publishes all Maven publications to the listed Maven repository.'
dependsOn tasks.cleanReleaseRepo
dependsOn tasks.publishSuperCORE
}
tasks.register('cleanPublishSuperCORELocalDev') {
group = 'supercore'
description = 'Creates a local export of SuperCORE. Installable as vendor dep using http://127.0.0.1:5500/releases/com/frcteam3255/supercore/SuperCORE-latest.json'
vendorFileInput = file("src/generate/LocalSuperCORE.json")
dependsOn tasks.cleanReleaseRepo
group = 'supercore'
dependsOn clean
dependsOn tasks.withType(PublishToMavenRepository).matching {
it.repository == publishing.repositories.Local
}
dependsOn tasks.generateVendorJson
finalizedBy tasks.publishJavaDoc
}
task publishJavaDoc(){
group = 'supercore'
description ='Adds Java Docs to release.'
doLast {
println "Copying ${buildDir}/docs/javadoc into ${releaseDir}/${pubVersion}/"
copy {
from "${buildDir}/docs/javadoc"
into "${releaseDir}/${pubVersion}/javadoc"
}
copy {
from "${buildDir}/docs/javadoc"
into "${releaseDir}/javadoc-latest"
}
}
}