Skip to content

Commit 64ff025

Browse files
Update build process with doc publishing (googleapis#13)
* Update build process with doc publishing * Add template and update .gitignore
1 parent 66eab39 commit 64ff025

4 files changed

Lines changed: 53 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
bin
33
build
44
.gradle
5+
tmp_gh-pages
56

67
# Eclipse
78
.apt_generated

build.gradle

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ apply plugin: 'com.github.sherter.google-java-format'
2424

2525
group = "com.google.api"
2626
archivesBaseName = "api-common"
27-
version = "0.1.0"
27+
28+
project.version = new File("version.txt").text.trim()
2829

2930
sourceCompatibility = 1.7
3031
targetCompatibility = 1.7
@@ -69,6 +70,10 @@ dependencies {
6970
libraries.commons
7071
}
7172

73+
clean.doFirst {
74+
delete 'tmp_gh-pages/'
75+
}
76+
7277
jacocoTestReport {
7378
reports {
7479
xml.enabled true
@@ -264,3 +269,47 @@ tasks.verifyGoogleJavaFormat {
264269
exclude 'build/**'
265270
}
266271
test.dependsOn verifyGoogleJavaFormat
272+
273+
// Release
274+
// =======
275+
276+
task checkOutGhPages {
277+
if (!new File('tmp_gh-pages').exists()) {
278+
exec {
279+
commandLine 'git', 'clone', '--branch', 'gh-pages',
280+
'--single-branch', 'https://github.com/googleapis/api-common-java/', 'tmp_gh-pages'
281+
}
282+
}
283+
}
284+
285+
task copyFilesToGhPages {
286+
dependsOn 'checkOutGhPages'
287+
dependsOn 'javadoc'
288+
doLast {
289+
def newSiteDirPath = 'tmp_gh-pages/' + project.version + '/apidocs/'
290+
new File(newSiteDirPath).mkdirs()
291+
copy {
292+
from 'build/docs/javadoc'
293+
into newSiteDirPath
294+
}
295+
copy {
296+
from 'README.md'
297+
into 'tmp_gh-pages'
298+
rename { filename -> filename.replace 'README', 'index' }
299+
}
300+
}
301+
}
302+
303+
task createApiDocsRedirect {
304+
dependsOn 'copyFilesToGhPages'
305+
doLast {
306+
def template = new File('templates/apidocs_index.html.template').text
307+
def outputContent = template.replace('{{siteVersion}}', project.version)
308+
new File('tmp_gh-pages/apidocs/index.html').write(outputContent)
309+
}
310+
}
311+
312+
// Regenerates the gh-pages branch under tmp_gh-pages, which must be committed separately
313+
task updateDocsWithCurrentVersion {
314+
dependsOn 'createApiDocsRedirect'
315+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<html><head><meta http-equiv="refresh" content="0; URL='http://googleapis.github.io/api-common-java/{{siteVersion}}/apidocs/'" /></head><body></body></html>

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.1-SNAPSHOT

0 commit comments

Comments
 (0)