diff --git a/build.gradle b/build.gradle index 1cf786b..ac6aa29 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ repositories { dependencies { implementation gradleApi() implementation localGroovy() - implementation(group: 'kr.motd.maven', name: 'sphinx-maven-plugin', version: '2.7.0') { + implementation(group: 'kr.motd.maven', name: 'sphinx-maven-plugin', version: '2.9.0') { exclude group: 'org.apache.maven.shared', module: 'maven-filtering' exclude group: 'org.apache.maven.reporting', module: 'maven-reporting-api' exclude group: 'org.apache.maven.reporting', module: 'maven-reporting-impl' diff --git a/gradle.properties b/gradle.properties index 0e31bff..5fbe8ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=kr.motd.gradle name=sphinx-gradle-plugin -version=2.8.1-SNAPSHOT +version=2.9.0-SNAPSHOT diff --git a/src/main/groovy/kr/motd/gradle/sphinx/gradle/SphinxTask.groovy b/src/main/groovy/kr/motd/gradle/sphinx/gradle/SphinxTask.groovy index 1c25116..6adbe6f 100644 --- a/src/main/groovy/kr/motd/gradle/sphinx/gradle/SphinxTask.groovy +++ b/src/main/groovy/kr/motd/gradle/sphinx/gradle/SphinxTask.groovy @@ -30,6 +30,7 @@ class SphinxTask extends DefaultTask { def warningsAsErrors = { false } def skip = { false } def useDoctreeCache = { false } + def useMakeMode = { false } private static def unwrap(Object o) { if (o instanceof Callable) { @@ -55,7 +56,9 @@ class SphinxTask extends DefaultTask { @InputDirectory @PathSensitive(PathSensitivity.RELATIVE) File getBinaryCacheDir() { - return project.file(binaryCacheDir).getCanonicalFile() + def binaryCacheDir = project.file(this.binaryCacheDir) + binaryCacheDir.mkdirs() + return binaryCacheDir.getCanonicalFile() } void setBinaryCacheDir(Object binaryCacheDir) { @@ -259,6 +262,19 @@ class SphinxTask extends DefaultTask { setUseDoctreeCache(useDoctreeCache) } + @Input + boolean getUseMakeMode() { + (useMakeMode instanceof Boolean ? useMakeMode : useMakeMode()).asBoolean() + } + + void setUseMakeMode(Object useMakeMode) { + this.useMakeMode = useMakeMode + } + + void useMakeMode(Object useMakeMode) { + setUseMakeMode(useMakeMode) + } + @Input boolean getSkip() { (skip instanceof Boolean ? skip : skip()).asBoolean() @@ -296,6 +312,9 @@ class SphinxTask extends DefaultTask { private List getSphinxRunnerCmdLine() { List args = [] + args.add(getUseMakeMode() ? '-M' : '-b') + args.add(getBuilder()) + if (getVerbose()) { args.add('-v') } else { @@ -328,9 +347,6 @@ class SphinxTask extends DefaultTask { args.add('-n') - args.add('-b') - args.add(getBuilder()) - args.add(getSourceDirectory().getPath()) args.add(getOutputDirectory().getPath()) diff --git a/src/site/sphinx/conf.py b/src/site/sphinx/conf.py index 63ea4c0..0c4012d 100644 --- a/src/site/sphinx/conf.py +++ b/src/site/sphinx/conf.py @@ -21,8 +21,8 @@ project = u'sphinx-gradle-plugin' copyright = u'2017, Trustin Lee et al' -version = '2.8' -release = '2.8.0' +version = '2.9' +release = '2.9.0' # General options needs_sphinx = '1.0' diff --git a/src/site/sphinx/configuration.rst b/src/site/sphinx/configuration.rst index 4a5b813..6107da5 100644 --- a/src/site/sphinx/configuration.rst +++ b/src/site/sphinx/configuration.rst @@ -23,6 +23,7 @@ Parameter Description ``skip`` Whether Sphinx execution should be skipped. ``false`` ``useDoctreeCache`` Whether doctree cache should be used. ``false`` ``doctreeCacheDirectory`` The directory containing Sphinx doctree cache. Used only when ``useDoctreeCache`` is ``true`` ``${project.buildDir}/site/.doctrees`` +``useMakeMode`` Whether Sphinx should use 'make mode' (``-M`` option) instead of 'build mode' (``-b`` option). ``false`` ========================= ================================================================================================= ======================================== Sample Documentation Config diff --git a/src/test/groovy/kr/motd/gradle/sphinx/SphinxTaskTest.groovy b/src/test/groovy/kr/motd/gradle/sphinx/SphinxTaskTest.groovy index 1d98961..9cc48d4 100644 --- a/src/test/groovy/kr/motd/gradle/sphinx/SphinxTaskTest.groovy +++ b/src/test/groovy/kr/motd/gradle/sphinx/SphinxTaskTest.groovy @@ -35,12 +35,14 @@ class SphinxTaskTest { assert !task.warningsAsErrors assert !task.useDoctreeCache assert task.doctreeCacheDirectory == null + assert !task.useMakeMode } @Test void testOverriddenProperties() { task.sourceDirectory "${project.projectDir}/src/my/sphinx" task.outputDirectory "${project.buildDir}/my/sphinx" + task.binaryCacheDir "${project.buildDir}/my/cache" task.builder 'mo' task.tags 'foo', 'bar' task.verbose false @@ -49,11 +51,15 @@ class SphinxTaskTest { task.skip true task.warningsAsErrors true task.useDoctreeCache true + task.useMakeMode true - assert "${task.getSourceDirectory()}" == + assert "${task.sourceDirectory}" == "${project.projectDir}${File.separator}src${File.separator}my${File.separator}sphinx" - assert "${task.getOutputDirectory()}" == + assert "${task.outputDirectory}" == "${project.buildDir}${File.separator}my${File.separator}sphinx" + assert "${task.binaryCacheDir}" == + "${project.buildDir}${File.separator}my${File.separator}cache" + assert task.binaryCacheDir.isDirectory() assert task.builder == 'mo' assert task.tags == [ "foo", "bar" ] @@ -65,6 +71,7 @@ class SphinxTaskTest { assert task.useDoctreeCache assert "${task.doctreeCacheDirectory}" == "${project.buildDir}${File.separator}site${File.separator}.doctrees" + assert task.useMakeMode task.doctreeCacheDirectory "${project.buildDir}/my/doctree-cache" assert task.doctreeCacheDirectory.isDirectory()