buildscript { repositories { mavenLocal() maven { url = "https://repo.grails.org/grails/core" } } dependencies { classpath "org.grails:grails-docs:3.2.7" } } import groovy.json.* apply plugin:'base' def GRAILS_GUIDES_GROUP = 'X - Grails Guides' def commonGithubOrg = 'grails' def commonGithubSlug = 'grails-guides' def commonBranch = 'master' task prepareResources { group = GRAILS_GUIDES_GROUP description = 'Downloads grails-guides repository master branch and unzip it to build folder' doLast { ant.mkdir(dir:buildDir) ant.get(src:"https://github.com/${commonGithubOrg}/${commonGithubSlug}/archive/${commonBranch}.zip", dest:"${buildDir}/resources.zip") ant.unzip(src:"${buildDir}/resources.zip", dest:"${buildDir}/resources") } } task copyLocalGuideImgResources(type: Copy) { group = GRAILS_GUIDES_GROUP description = 'Copy local image resources to build folder' onlyIf { new File('src/main/resources/img').exists() } mustRunAfter prepareResources from ('src/main/resources/img') { include '*.png' include '*.gif' include '*.jpg' include '*.svg' include '*.jpeg' } into "${buildDir}/resources/grails-guides-master/src/main/resources/img" } task publishGuide(type: grails.doc.gradle.PublishGuide) { group = GRAILS_GUIDES_GROUP description = 'Generate Guide' dependsOn prepareResources, copyLocalGuideImgResources def localResourcesDir = "${buildDir}/resources/${commonGithubSlug}-${commonBranch}" // def localResourcesDir = "../grails-guides/" // No language setting because we want the English guide to be // generated with a 'en' in the path, but the source is in 'en' // so that it's easy to track with git. targetDir = project.file("${buildDir}/docs") sourceRepo = "https://github.com/${githubSlug}/edit/$githubBranch/src/main/docs" sourceDir = new File(projectDir, "src/main/docs") propertiesFiles = [ new File(projectDir, "gradle.properties"), new File(projectDir, "complete/gradle.properties") ] asciidoc = true resourcesDir = project.file("${localResourcesDir}/src/main/resources") properties = [ 'safe':'UNSAFE', 'commondir':project.file("${localResourcesDir}/src/main/docs"), 'sourceDir':project.file('complete').absolutePath, 'javaee': 'https://docs.oracle.com/javaee/7/api/', 'javase': 'https://docs.oracle.com/javase/7/docs/api/', 'groovyapi': 'http://docs.groovy-lang.org/latest/html/gapi/', 'grailsapi': 'http://docs.grails.org/latest/api/', 'gormapi': 'http://gorm.grails.org/latest/api/', 'springapi': 'https://docs.spring.io/spring/docs/current/javadoc-api/' ] doLast { ant.move(file:"${project.buildDir}/docs/guide/single.html", tofile:"${project.buildDir}/docs/guide/index.html", overwrite:true) new File(project.buildDir, "docs/index.html").text = '''