Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
bin
build
.gradle
tmp_gh-pages

# Eclipse
.apt_generated
Expand Down
51 changes: 50 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ apply plugin: 'com.github.sherter.google-java-format'

group = "com.google.api"
archivesBaseName = "api-common"
version = "0.1.0"

project.version = new File("version.txt").text.trim()

sourceCompatibility = 1.7
targetCompatibility = 1.7
Expand Down Expand Up @@ -69,6 +70,10 @@ dependencies {
libraries.commons
}

clean.doFirst {
delete 'tmp_gh-pages/'
}

jacocoTestReport {
reports {
xml.enabled true
Expand Down Expand Up @@ -264,3 +269,47 @@ tasks.verifyGoogleJavaFormat {
exclude 'build/**'
}
test.dependsOn verifyGoogleJavaFormat

// Release
// =======

task checkOutGhPages {
if (!new File('tmp_gh-pages').exists()) {
exec {
commandLine 'git', 'clone', '--branch', 'gh-pages',
'--single-branch', 'https://github.com/googleapis/api-common-java/', 'tmp_gh-pages'
}
}
}

task copyFilesToGhPages {
dependsOn 'checkOutGhPages'
dependsOn 'javadoc'
doLast {
def newSiteDirPath = 'tmp_gh-pages/' + project.version + '/apidocs/'
new File(newSiteDirPath).mkdirs()
copy {
from 'build/docs/javadoc'
into newSiteDirPath
}
copy {
from 'README.md'
into 'tmp_gh-pages'
rename { filename -> filename.replace 'README', 'index' }
}
}
}

task createApiDocsRedirect {
dependsOn 'copyFilesToGhPages'
doLast {
def template = new File('templates/apidocs_index.html.template').text

This comment was marked as spam.

def outputContent = template.replace('{{siteVersion}}', project.version)
new File('tmp_gh-pages/apidocs/index.html').write(outputContent)
}
}

// Regenerates the gh-pages branch under tmp_gh-pages, which must be committed separately
task updateDocsWithCurrentVersion {
dependsOn 'createApiDocsRedirect'
}
1 change: 1 addition & 0 deletions templates/apidocs_index.html.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><head><meta http-equiv="refresh" content="0; URL='http://googleapis.github.io/api-common-java/{{siteVersion}}/apidocs/'" /></head><body></body></html>
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1-SNAPSHOT