Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude secondary source elements by matching rather than subtraction #436

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import org.gradle.api.InvalidUserDataException
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.CopySpec
import org.gradle.api.file.FileTree
import org.gradle.api.file.FileTreeElement
import org.gradle.api.provider.Provider
import org.gradle.api.specs.Spec
import org.gradle.api.tasks.Console
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
Expand All @@ -38,6 +40,7 @@ import org.gradle.api.tasks.OutputDirectories
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.SkipWhenEmpty
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.api.tasks.util.PatternSet
import org.ysb33r.grolifant.api.FileUtils
import org.ysb33r.grolifant.api.StringUtils
Expand Down Expand Up @@ -672,9 +675,14 @@ abstract class AbstractAsciidoctorBaseTask extends DefaultTask {
* @return Source tree based upon configured pattern.
*/
protected FileTree getSecondarySourceFileTreeFrom(File dir) {
FileTree initialTree = project.fileTree(dir).
matching(this.secondarySourceDocumentPattern ?: defaultSecondarySourceDocumentPattern)
(initialTree - getSourceFileTreeFrom(dir)).asFileTree
FileTree doNotInclude = getSourceFileTreeFrom(dir)
project.fileTree(dir)
.matching(this.secondarySourceDocumentPattern ?: defaultSecondarySourceDocumentPattern)
.matching { PatternFilterable target ->
target.exclude({ FileTreeElement element ->
doNotInclude.contains(element.file)
} as Spec<FileTreeElement>)
}
}

/** The default PatternSet that will be used if {@code sources} was never called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AsciidoctorEpubTask extends AbstractAsciidoctorTask {
kindleGenExtension = project.extensions.getByType(KindleGenExtension)
sourceDir = 'src/docs/asciidocEpub'

// TODO: We are setting this curretnly to fix a problem in asciidoctor-epub GEM.
// TODO: We are setting this currently to fix a problem in asciidoctor-epub GEM.
useIntermediateWorkDir()
}

Expand Down