Skip to content

Commit

Permalink
Mark gemPath as internal input property
Browse files Browse the repository at this point in the history
  • Loading branch information
erichaagdev committed May 18, 2023
1 parent 4e238b9 commit fde8dbc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ package org.asciidoctor.gradle.jvm

import org.asciidoctor.gradle.internal.FunctionalSpecification
import org.asciidoctor.gradle.testfixtures.CachingTest
import spock.lang.Issue

import static org.asciidoctor.gradle.testfixtures.AsciidoctorjTestVersions.SERIES_20
import static org.asciidoctor.gradle.testfixtures.JRubyTestVersions.AJ20_ABSOLUTE_MINIMUM
import static org.asciidoctor.gradle.testfixtures.JRubyTestVersions.AJ20_SAFE_MAXIMUM

/** AsciidoctorTaskCachingFunctionalSpec
*
* @author Eric Haag
* @author Gary Hale
*/
class AsciidoctorTaskCachingFunctionalSpec extends FunctionalSpecification implements CachingTest {
Expand Down Expand Up @@ -65,6 +67,37 @@ class AsciidoctorTaskCachingFunctionalSpec extends FunctionalSpecification imple
fileInRelocatedDirectory(DOCBOOK_OUTPUT_FILE).exists()
}

@Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/671')
void "asciidoctor task is cacheable and relocatable when gemPaths is configured"() {
given:
getBuildFile("""
asciidoctorj {
gemPaths 'gems1', 'gems2'
}
asciidoctor {
sourceDir 'src/docs/asciidoc'
outputOptions {
backends 'html5', 'docbook'
}
}
""")

when:
assertDefaultTaskExecutes()

then:
outputFile.exists()

when:
assertDefaultTaskIsCachedAndRelocatable()

then:
outputFile.exists()
outputFileInRelocatedDirectory.exists()
}

void "Asciidoctor task is cached when only output directory is changed"() {
given:
getBuildFile("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ class AbstractAsciidoctorTask extends AbstractAsciidoctorBaseTask {
([asciidoctorj.configuration] + asConfigurations(project, asciidocConfigurations)).toSet()
}

/**
* Additional locations to consider when GEMs are loaded by AsciidoctorJ or JRuby.
*
* @return The additional GEM locations.
*
* @since 4.0
*/
@Internal
String getGemPath() {
asciidoctorj.asGemPath()
}

@SuppressWarnings('UnnecessaryGetter')
@TaskAction
void processAsciidocSources() {
Expand Down Expand Up @@ -357,9 +369,6 @@ class AbstractAsciidoctorTask extends AbstractAsciidoctorBaseTask {
this.worker = we
this.asciidoctorj = extensions.create(AsciidoctorJExtension.NAME, AsciidoctorJExtension, this)

addInputProperty 'gemPath', { AsciidoctorJExtension aj -> aj.asGemPath() }
.curry(this.asciidoctorj)

addInputProperty 'required-ruby-modules', { AsciidoctorJExtension aj -> aj.requires }
.curry(this.asciidoctorj)

Expand Down Expand Up @@ -502,10 +511,6 @@ class AbstractAsciidoctorTask extends AbstractAsciidoctorBaseTask {
}
}

private String getGemPath() {
asciidoctorj.asGemPath()
}

private Map<String, ExecutorConfiguration> runWithWorkers(
final File workingSourceDir,
final Set<File> sourceFiles,
Expand Down

0 comments on commit fde8dbc

Please sign in to comment.