11plugins {
22 id ' base' // Adds 'assemble', 'check', 'build', and 'clean' tasks.
3- id ' edu.ucar.unidata.site.jekyll'
43}
54
65// ////////////////////////////////////////////// Javadoc ////////////////////////////////////////////////
6+ apply from : " $rootDir /gradle/any/dependencies.gradle"
77apply from : " $rootDir /gradle/any/javadoc.gradle"
88apply from : " $rootDir /gradle/any/testing.gradle"
99
@@ -115,6 +115,65 @@ gradle.projectsEvaluated { // Several statements below rely upon all subproject
115115
116116apply from : " $rootDir /gradle/any/properties.gradle" // For Nexus credential properties.
117117
118+ String docTheme = " unidata-jekyll-docs:0.0.4"
119+
120+ boolean isGitHub = System . getenv(' GITHUB_ACTIONS' ) as boolean
121+ String imageBaseUrl = " docker.unidata.ucar.edu"
122+ if (isGitHub) {
123+ imageBaseUrl = " ghcr.io/unidata"
124+ }
125+
126+ String dockerImage = " ${ imageBaseUrl} /${ docTheme} "
127+ Provider<Directory > siteBuildDir = layout. buildDirectory. dir(" site" )
128+
129+ tasks. register(" buildJekyllSite" , Exec ) {
130+ group = " documentation"
131+ description = " Build the netCDF-Java documentation."
132+ ConfigurableFileTree buildDocInputs = fileTree(" ." )
133+ buildDocInputs. exclude(" build/" , " .gradle" , " .jekyll-cache" )
134+ inputs. files(buildDocInputs)
135+ outputs. dir(siteBuildDir)
136+ commandLine(" docker" , " run" , " --rm" ,
137+ " -e" , " SRC_DIR=/netcdf-java/docs/src/site" ,
138+ " -v" , " $rootDir :/netcdf-java" ,
139+ " -v" , " ./${ relativePath(siteBuildDir.get().toString())} :/site" ,
140+ dockerImage, " build" )
141+ }
142+
143+ class NullOutputStream extends OutputStream {
144+ @Override
145+ void write (int b ) throws IOException {}
146+ }
147+
148+ tasks. register(" serveJekyllSite" , Exec ) {
149+ group = " documentation"
150+ description = " Start a local server to live edit the netCDF-Java documentation."
151+ commandLine(" docker" , " run" , " --rm" , " -d" ,
152+ " --name" , " netcdf-java-docs-server" ,
153+ " -e" , " SRC_DIR=/netcdf-java/docs/src/site" ,
154+ " -v" , " $rootDir :/netcdf-java" ,
155+ " -p" , " 4005:4005" ,
156+ dockerImage, " serve" , " --livereload" )
157+ standardOutput = new NullOutputStream ()
158+ doLast {
159+ String msg = " NetCDF-Java documentation available at http://localhost:4005"
160+ String bannerBorder = new String (new char [msg. length() + 4 ]). replace(" \0 " , " #" );
161+ println ()
162+ println (bannerBorder)
163+ println (" # $msg #" )
164+ println (bannerBorder)
165+ println ()
166+ }
167+ }
168+
169+ tasks. register(" stopServe" , Exec ) {
170+ group = " documentation"
171+ description = " Stop the local server used while live editing the netCDF-Java documentation."
172+ commandLine(" docker" , " stop" , " netcdf-java-docs-server" )
173+ delete(" $projectDir /src/site/Gemfile" )
174+ delete(" $projectDir /src/site/Gemfile.lock" )
175+ }
176+
118177import edu.ucar.build.publishing.tasks.PublishToRawRepoTask
119178
120179tasks. withType(PublishToRawRepoTask ). all { // Common PublishToRawRepoTask config.
@@ -134,16 +193,14 @@ tasks.withType(PublishToRawRepoTask).all { // Common PublishToRawRepoTask confi
134193
135194tasks. register(' publishAsVersionedUserGuide' , PublishToRawRepoTask ) {
136195 description = ' Publish user guide (versioned) to Nexus under /major.minor/.'
137-
138- publishSrc = buildJekyllSite. destinationDirectory. get()
196+ publishSrc = siteBuildDir. get(). toString()
139197 destPath = " $project . docVersion /userguide/"
140198 dependsOn tasks. getByName(' buildJekyllSite' )
141199}
142200
143201tasks. register(' publishAsCurrentUserGuide' , PublishToRawRepoTask ) {
144202 description = ' Publish the user guide to Nexus under /current/.'
145-
146- publishSrc = buildJekyllSite. destinationDirectory. get()
203+ publishSrc = siteBuildDir. get(). toString()
147204 destPath = ' current/userguide/'
148205 dependsOn tasks. getByName(' buildJekyllSite' )
149206}
0 commit comments