Skip to content

Commit

Permalink
Correct empty directory behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
ysb33r committed Dec 31, 2022
1 parent 6e39326 commit a15fdef
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
6 changes: 5 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ The {doctitle} is the official means of using {asciidoctor-url}[Asciidoctor] to
Documentation:: We are migrating our documentation to the new Asciidoctor Antora-based site when it is ready. In the meantime you can read a snapshot of the new documentation at {asciidoctor-development-docs}{github-branch}

ifdef::env-github[]
Structure:: `master` now represents the code for the latest 3.x release of these plugins. Development for for 4.x is against the link:https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/development-4.x[{github-branch}] branch. PRs are preferably taking against this branch. The 2.x & 1.5.x series of the plugin is now in maintenance only mode. PRs for that should be raised against the respective link:https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/maintenance-2.x[maintenance-2.x] and https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/maintenance-1.5[maintenance-1.5] branches.
Structure:: `master` now represents the code for the latest 3.x release of these plugins.
Development for 4.x is against the link:https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/development-4.x[{github-branch}] branch.
PRs are preferably taking against this branch.
The 2.x & 1.5.x series of the plugin is now in maintenance only mode.
PRs for that should be raised against the respective link:https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/maintenance-2.x[maintenance-2.x] and https://github.com/asciidoctor/asciidoctor-gradle-plugin/tree/maintenance-1.5[maintenance-1.5] branches.
endif::[]

Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ import java.util.concurrent.Callable
import static org.asciidoctor.gradle.base.AsciidoctorUtils.UNDERSCORE_LED_FILES
import static org.asciidoctor.gradle.base.AsciidoctorUtils.createDirectoryProperty
import static org.asciidoctor.gradle.base.AsciidoctorUtils.executeDelegatingClosure
import static org.asciidoctor.gradle.base.AsciidoctorUtils.getSourceFileTree
import static org.asciidoctor.gradle.base.AsciidoctorUtils.mapToDirectoryProvider
import static org.gradle.api.tasks.PathSensitivity.RELATIVE
import static org.ysb33r.grolifant.api.v4.FileUtils.filesFromCopySpec
import static org.ysb33r.grolifant.api.core.TaskInputFileOptions.IGNORE_EMPTY_DIRECTORIES

/** Abstract base task for Asciidoctor that can be shared between AsciidoctorJ and Asciidoctor.js.
*
Expand Down Expand Up @@ -636,12 +635,15 @@ abstract class AbstractAsciidoctorBaseTask extends DefaultTask {
protected AbstractAsciidoctorBaseTask() {
super()
this.projectOperations = ProjectOperations.find(project)
inputs.files { filesFromCopySpec(getResourceCopySpec(Optional.empty())) }
.withPathSensitivity(RELATIVE)
.ignoreEmptyDirectories()
projectOperations.tasks.inputFiles(
inputs,
{ projectOperations.fsOperations.resolveFilesFromCopySpec(getResourceCopySpec(Optional.empty())) },
RELATIVE,
IGNORE_EMPTY_DIRECTORIES
)
this.srcDir = createDirectoryProperty(project)
this.outDir = createDirectoryProperty(project)
this.defaultRevNumber = projectOperations.projectTools.versionProvider.orElse(Project.DEFAULT_VERSION)
this.defaultRevNumber = projectOperations.projectTools.versionProvider.orElse(Project.DEFAULT_VERSION)
}

@Nested
Expand Down Expand Up @@ -775,7 +777,7 @@ abstract class AbstractAsciidoctorBaseTask extends DefaultTask {
*/
protected Map<String, Object> getTaskSpecificDefaultAttributes(File workingSourceDir) {
Map<String, Object> attrs = [
includedir : (Object) workingSourceDir.absolutePath
includedir: (Object) workingSourceDir.absolutePath
// 'gradle-project-name': (Object) project.name
]

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bintray_dryRun = false
cglibVersion = 3.3.0
jsoupVersion = 1.13.1
spockVersion = 1.3-groovy-2.5
grolifantVersion = 2.0.0-alpha.5
grolifantVersion = 2.0.0-alpha.6
jacocoVersion = 0.8.6
jrubyGradleVersion = 2.0.2
codenarcVersion = 1.3
Expand Down
2 changes: 2 additions & 0 deletions jvm-pdf/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ configurePlugin 'org.asciidoctor.jvm.pdf',
'Simplifies conversion of asciidoc documents to PDF',
['asciidoctorj', 'pdf']


gradleTest.gradleArguments '-s'
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ asciidoctorPdf {
"""
when:
getGradleRunner([DEFAULT_TASK])
getGradleRunner([DEFAULT_TASK, '-s'])
.withGradleVersion(gradleVersion)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import org.gradle.workers.WorkerExecutor

import javax.inject.Inject

import static org.ysb33r.grolifant.api.core.TaskInputFileOptions.IGNORE_EMPTY_DIRECTORIES
import static org.ysb33r.grolifant.api.core.TaskInputFileOptions.OPTIONAL

/** Asciidoctor task that is specialises in PDF conversion.
*
* @author Schalk W. Cronjé
Expand All @@ -53,6 +56,12 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask {

configuredOutputOptions.backends = ['pdf']
copyNoResources()
projectOperations.tasks.inputFiles(
inputs,
{ -> fontDirs },
PathSensitivity.RELATIVE,
IGNORE_EMPTY_DIRECTORIES, OPTIONAL
)
}

/** @Deprecated Use{@link #getFontsDirs()} instead
Expand Down Expand Up @@ -91,12 +100,9 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask {
*
* @return Directories for the pdf fonts
* */
@InputFiles
@IgnoreEmptyDirectories
@PathSensitive(PathSensitivity.RELATIVE)
@Optional
@Internal
FileCollection getFontsDirs() {
this.project.files(this.fontDirs)
projectOperations.fsOperations.files(this.fontDirs)
}

/** Specify a directory or directories where to load custom fonts from.
Expand Down Expand Up @@ -162,7 +168,7 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask {
if (GradleVersion.current() <= LAST_GRADLE_WITH_CLASSPATH_LEAKAGE) {
if (inProcess != AbstractAsciidoctorTask.JAVA_EXEC) {
logger.warn 'This version of Gradle leaks snakeyaml on to worker classpaths which breaks ' +
'PDF processing. Switching to JAVA_EXEC instead.'
'PDF processing. Switching to JAVA_EXEC instead.'
}
AbstractAsciidoctorTask.JAVA_EXEC
} else {
Expand Down
6 changes: 3 additions & 3 deletions module-versions.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# By convention keep everything lowercase

# asciidoctorj-extension
asciidoctorj=2.5.5
asciidoctorj=2.5.7
asciidoctorj.groovydsl=2.0.2
asciidoctorj.diagram=2.0.5
asciidoctorj.pdf=2.1.6
asciidoctorj.diagram=2.2.3
asciidoctorj.pdf=2.3.4
asciidoctorj.epub=1.5.1
asciidoctorj.leanpub=2.0-alpha.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.gradle.util.GradleVersion
@CompileStatic
class GradleTestVersions {
public final static String MIN_VERSION = '6.0.1'
public final static String MAX_VERSION = '7.5.1'
public final static String MAX_VERSION = '7.6'

static String latestMinimumOrThis(final String ver) {
[GradleVersion.version(MIN_VERSION), GradleVersion.version(ver)].max().version
Expand Down

0 comments on commit a15fdef

Please sign in to comment.