备注:
   次文档参考github 例子
 
1.环境准备
node npm (yarn) java  KindleGen
备注: 具体的安装可以参考网上相关文档,KindleGen 下载地址:https://www.amazon.com/gp/feature.html?docId=1000765211
2. 代码&&运行
a. git clone code
git clone https://github.com/mraible/infoq-mini-book.git
修改build.sh 中 KindleGen 位置比如我的在 /opt/kind/kindlegen
b. build
./build.sh //epub html
./generate-pdf.sh pdf
3. 构建结果
build
└── asciidoc
├── epub3
│ └── images
└── html5
└── images
4. 效果
 
5. 代码结构解析
备注: 主要说明asciidoc 代码
src/docs 主要是文档以及需要的图片资源 └── asciidoc
├── chapters
├── images
└── styles
├── epub
│   └── fonts
└── pdf
└── fonts
build.gradle gradle 构建 task buildscript {
repositories {
jcenter()
} dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
classpath 'com.bluepapa32:gradle-watch-plugin:0.1.5'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.7'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16'
classpath 'org.jruby:jruby-complete:9.1.12.0'
}
} apply plugin: 'java'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.bluepapa32.watch' version = '4.1.0-SNAPSHOT' asciidoctorj {
version = '1.5.6'
} import org.asciidoctor.gradle.AsciidoctorTask def attrs = ['sourcedir' : '../../../main/webapp',
'source-highlighter': 'coderay',
'epub3-stylesdir' : './styles/epub',
// NOTE don't include leading ./ because it messes up paths in the epub files
'imagesdir' : 'images',
'toc' : 'left',
'icons' : 'font',
'sectanchors' : '',
'idprefix' : '',
'idseparator' : '-'] tasks.withType(AsciidoctorTask) { task ->
attributes attrs
sources {
include 'index.adoc'
}
} task html(type: AsciidoctorTask, description: 'Generates single page HTML') {
backends 'html5'
} // NOTE please use ./generate-pdf.sh instead of this task for now
task prepress(type: AsciidoctorTask, description: 'Generates PDF for prepress printing') {
attributes attrs + ['media' : 'prepress', 'pdfmarks': '', 'pdf-theme': 'infoq-prepress']
attrs.remove('source-highlighter')
requires file('src/main/ruby/asciidoctor-pdf-extensions.rb')
backends 'pdf'
outputDir "$buildDir/asciidoc/pdf-prepress"
separateOutputDirs false
} // NOTE please use ./generate-pdf.sh screen instead of this task for now
task pdf(type: AsciidoctorTask, description: 'Generates PDF') {
attributes attrs + ['pdfmarks': '']
requires file('src/main/ruby/asciidoctor-pdf-extensions.rb')
backends 'pdf'
} task epub(type: AsciidoctorTask, description: 'Generates EPUB3') {
backends 'epub3'
} task mobi(type: AsciidoctorTask, description: 'Generates MOBI') {
backends 'epub3'
attrs.put('ebook-format', 'kf8')
attributes attrs
} pdf.shouldRunAfter html
epub.shouldRunAfter pdf //task all(dependsOn: ['html', 'pdf', 'epub', 'mobi'])
task all(dependsOn: ['html', 'epub', 'mobi']) defaultTasks 'all' watch {
asciidoc {
files fileTree(dir: 'src/docs/asciidoc', include: '**/*.adoc')
tasks 'asciidoctor'
}
}
6. 参考资料
https://www.amazon.com/gp/feature.html?docId=1000765211
http://asciidoctor.org/docs/asciidoctor-gradle-plugin/
https://github.com/asciidoctor/asciidoctor-maven-plugin
 
 
 
 

gradle asciidoc 使用的更多相关文章

  1. Gradle环境下导出Swagger为PDF

    更多精彩博文,欢迎访问我的个人博客 说明 我个人是一直使用Swagger作为接口文档的说明的.但是由于在一些情况下,接口文档说明需要以文件的形式交付出去,如果再重新写一份文档难免有些麻烦.于是在网上看 ...

  2. 在gradle中构建java项目

    目录 简介 构建java项目的两大插件 管理依赖 编译代码 管理resource 打包和发布 生成javadoc 简介 之前的文章我们讲到了gradle的基本使用,使用gradle的最终目的就是为了构 ...

  3. Gradle配置APK自动签名完整流程

    转载请注明出处:http://www.cnblogs.com/LT5505/p/6256683.html 一.生成签名 1.命令行生成签名,输入命令keytool -genkey -v -keysto ...

  4. gradle学习笔记(1)

    1. 安装     (1) 下载最新gradle压缩包,解压到某处.地址是:Gradle web site:     (2) 添加环境变量:             1) 变量名:GRADLE_HOM ...

  5. Gradle 实现 Android 多渠道定制化打包

    Gradle 实现 Android 多渠道定制化打包 版权声明:本文为博主原创文章,未经博主允许不得转载. 最近在项目中遇到需要实现 Apk 多渠道.定制化打包, Google .百度查找了一些资料, ...

  6. 解决 Could not find com.android.tools.build:gradle 问题

    今天拉同事最新的代码,编译时老是报如下错误: Error:Could not find com.android.tools.build:gradle:2.2.0.Searched in the fol ...

  7. React Native Android gradle下载慢问题解决

    很多人会遇到 初次运行 react-native run android的时候 gradle下载极慢,甚至会失败的问题 如下图 实际上这个问题好解决的 首先 把对应版本的gradle下载到本地任意一个 ...

  8. Android studio使用gradle动态构建APP(不同的包,不同的icon、label)

    最近有个需求,需要做两个功能相似的APP,大部分代码是一样的,只是界面不一样,以前要维护两套代码,比较麻烦,最近在网上找资料,发现可以用gradle使用同一套代码构建两个APP.下面介绍使用方法: 首 ...

  9. 对Maven、gradle、svn、spring 3.0 fragment、git的想法

    1.Maven Maven可以构建项目,采用pom方式配置主项目和其他需要引用的项目.同时可结合spring3.0的新特性web  fragment. 从现实出发,特别是对于管理不到位,程序员整体素质 ...

随机推荐

  1. 重新学习MySQL数据库5:根据MySQL索引原理进行分析与优化

    重新学习MySQL数据库5:根据MySQL索引原理进行分析与优化 一:Mysql原理与慢查询 MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能 ...

  2. HDU 3397 线段树区间修改

    Sequence operation Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  3. C#/JAVA 程序员转GO/GOLANG程序员笔记大全(DAY 04)

    -------------------- interface 接口 // 定义: type IHumaner interface { SayHi() // 接口中只能是方法声明,没有实现,没有数据字段 ...

  4. c++复习要点

    自增和自减运算符有前缀和后缀两种形式,都会改变对象,所以不能对常量对象操作. 前缀形式返回改变后的对象,返回*this. 后缀形式返回改变之前的值,所以必须创建一个代表这个值的独立对象并返回它,是通过 ...

  5. 到底啥是平台,到底啥是中台?李鬼太多,不得不说(ZT)

    (1)哪些不是中台,而是应该叫平台 做开发,有所谓的三层技术架构:前端展示层.中间逻辑层.后端数据层.我们现在讲的中台不在这个维度上. 做开发,还有所谓的技术中间件.一开始我们没有中间件的概念,只有操 ...

  6. poj2195

    题解: 简单KM 把每一个男的和房子分离 代码: #include<cstdio> #include<cmath> #include<algorithm> #inc ...

  7. hdu 6058 Kanade's sum(模拟链表)

    Kanade's sum Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  8. JQuery iframe

    子页面获取父页面的元素 function colisetapTJ() { var tapid = $('div:contains("添加档案报送"):last', window.p ...

  9. 关于block和inline元素的float

    CSS float 浮动属性 本篇主要介绍float属性:定义元素朝哪个方向浮动. 目录 1. 页面布局方式:介绍文档流.浮动层以及float属性. 2. float:left :介绍float为 l ...

  10. Linux sed命令操作 删除文件每一行的前k个字符、在文本的行尾或行首添加字符

    删除文件每一行的前k个字符 $ cat tmp.txt # 删除每行第一个字符 $ sed 's/.//' tmp.txt # 删除每行前两个字符 $ sed 's/..//' tmp.txt # 删 ...