build.gradle 4.18 KB
Newer Older
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
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
plugins {
    id 'org.asciidoctor.jvm.convert' version '3.0.0-alpha.3'
    id 'org.asciidoctor.jvm.revealjs' version '3.0.0-alpha.3'
}

repositories {
    jcenter()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
    maven {
    	url 'http://rubygems-proxy.torquebox.org/releases'
    }
}

dependencies {
    asciidoctorGems 'rubygems:asciidoctor-revealjs:2.0.0' 
}

asciidoctor {
	sourceDir 'asciidoc'
    sources {
        include '*.adoc'
    }
    outputDir file('build/docs/asciidoc')
	resources {
		from('asciidoc') {
	    	include '**/*.png'
	 	}
		into '.'
	}
    logDocuments = true
}

asciidoctorj {
	modules {
       // diagram.use() 
       diagram.version '1.5.16' 
    }
    // useIntermediateWorkDir = true
    attributes toc: 'left',
42
    	'source-highlighter': 'highlightjs'
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

    /*	
	extensions {
        block_macro (name: 'tweet') { parent, target, attributes ->
            String content = """<div class="tweet" data-src="https://twitter.com/${target}/status/${attributes.get('1')}"></div>"""
            config.remove 'content_model'
            createBlock(parent, "pass", [content], [:], config)
        }
    }
    */	
}

asciidoctorRevealJs {

    sourceDir 'revealjs'
    sources {
        include '*.adoc'
    }
    outputDir file('build/docs/revealjs')
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
62 63
	resources {
		from('revealjs') {
64
	    	include 'images/**'
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
65 66 67 68
	    	include '**/*.css'
	 	}
		into '.'
	}
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82

    attributes 'sourceDir': 'revealjs',
    	'imagesDir': 'revealjs',
        'icons':'font',
        'iconfont-name': 'fontawesome-4.5.0'

    revealjsOptions {
        controls = true
        slideNumber = true
        progressBar = true
        pushToHistory = true
        overviewMode = true
        touchMode = true
        backgroundTransition = 'convex' //none , fade, slide, convex, concave, zoom
83
        theme = 'white' //'black', 'beige' , 'league', 'night', 'serif', 'simple', 'sky', 'solarized'
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
84 85 86
    }

	plugins 'rajgoel/chart/Chart.min.js'
87 88 89
	//plugins 'IainAndrew/footer-reveal/footer-reveal.min.js'
	
	
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
90 91 92
}

revealjs {
93
	version '2.0.0' //  why not '3.8.0' 
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
94 95 96 97 98 99 100 101 102 103 104 105 106
	templateGitHub {
   		organisation = 'hakimel'
    	repository = 'reveal.js'
    	tag = '3.8.0'
  	}
}

revealjsPlugins {
    github 'rajgoel', {
        organisation = 'rajgoel'
        repository = 'reveal.js-plugins'
        branch = 'master'
    }
107 108 109 110 111 112
    
    /*github 'IainAndrew', {
        organisation = 'IainAndrew'
        repository = 'footer-reveal'
        branch = 'master'
    }*/
Hallvard Trætteberg's avatar
Hallvard Trætteberg committed
113 114
}

115 116
import org.apache.tools.ant.taskdefs.condition.Os

117 118
def dockerAvailable; 

119 120 121 122
task checkDocker {
 	doLast{
 	 	def result = 1
	    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
123 124 125 126 127 128
	    	println "windows os"
	      result = exec{
	          def command = "/c docker --version"
	          ignoreExitValue = true
	          executable "cmd" args command
	      }
129
	    } else { 
130 131 132 133 134 135 136 137
	  		//we assume linux/mac with bash if not having windows - 
	  		//more fine tuned testing can be done if needed
        println "linux / unix os"
        result = exec{
            def command = "command -v docker"
            ignoreExitValue = true
            executable "bash" args "-l", "-c", command
        }
138
	    }
139
	    
140
	    if(result.getExitValue()==0){
141 142 143 144 145
            println "docker available"
            dockerAvailable = true
    	} else {
        	print "no docker available"
        	dockerAvailable = false
146 147 148 149
    	}
    }
}

150
task pdfSlides {
151
	doLast{
152 153
	if (dockerAvailable){
	    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
154 155 156 157 158 159 160 161 162 163 164
	       def result = exec{
	       		workingDir = '.'
	          ignoreExitValue = true
	          commandLine 'cmd','/c','pdfslides.bat'
	      } 
	      
	      if(result.getExitValue()==0){
            println "export successful"
	    	} else {
	        	print "export to pdf failed"
	    	}
165
	    } else {
166 167 168 169 170 171 172 173 174 175 176
	    	def result = exec{
            def command = "pdfslides.sh"
            ignoreExitValue = true
            executable "bash" args "-l", "-c", command
        }
        
	    	if(result.getExitValue()==0){
            println "export successful"
	    	} else {
	        	print "export to pdf failed"
	    	}
177 178 179 180 181
	    	println "run linux / unix script"
	    }
    } else {
    	println "docker is not available on this machine"
    }
182
   }
183
}
184

185 186
build.dependsOn 'asciidoctorRevealJs'
pdfSlides.dependsOn 'checkDocker'