From bcb9ddcc3764ead27e713d4da25dcb9c42fab425 Mon Sep 17 00:00:00 2001 From: Tyler Bertrand Date: Wed, 8 May 2024 10:59:16 -0500 Subject: [PATCH] Solve CC issues - still not rendering document --- .../gradle/jvm/AbstractAsciidoctorTask.groovy | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy index 05abe4c7..b9328330 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy @@ -57,6 +57,7 @@ import org.gradle.api.tasks.TaskProvider import org.gradle.api.tasks.bundling.Jar import org.gradle.process.JavaForkOptions import org.gradle.workers.WorkerExecutor +import org.jcodings.util.Hash import org.ysb33r.grolifant.api.core.LegacyLevel import org.ysb33r.grolifant.api.core.jvm.ExecutionMode import org.ysb33r.grolifant.api.core.jvm.JavaForkOptionsWithEnvProvider @@ -66,6 +67,7 @@ import org.ysb33r.grolifant.api.remote.worker.WorkerAppExecutorFactory import java.util.function.Function import java.util.regex.Pattern +import java.util.stream.Collectors import static org.asciidoctor.gradle.base.AsciidoctorUtils.getClassLocation import static org.asciidoctor.gradle.base.internal.AsciidoctorAttributes.evaluateProviders @@ -109,16 +111,40 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask jvmClasspath private final List> gemJarProviders = [] - private final MapProperty optionsProperty = project.objects.mapProperty(String, Object) - private final MapProperty attributesProperty = project.objects.mapProperty(String, Object) - private final ListProperty attributeProviderProperty = project.objects.listProperty(AsciidoctorAttributeProvider) + protected final MapProperty optionsProperty = project.objects.mapProperty(String, Object) + protected final MapProperty attributesProperty = project.objects.mapProperty(String, Object) + public final ListProperty attributeProviderProperty = project.objects.listProperty(AsciidoctorAttributeProvider) @Classpath - private FileCollection configurationsFileCollection - private final ListProperty fatalWarningsProperty = project.objects.listProperty(Pattern) - private final ListProperty requiresProperty = project.objects.listProperty(String) - private final Property logLevelProperty = project.objects.property(LogLevel) - private final Property safeModeProperty = project.objects.property(SafeMode) - private final ListProperty docExtensionsProperty = project.objects.listProperty(Object) + protected FileCollection configurationsFileCollection + protected final ListProperty fatalWarningsProperty = project.objects.listProperty(Pattern) + protected final ListProperty requiresProperty = project.objects.listProperty(String) + protected final Property logLevelProperty = project.objects.property(LogLevel) + protected final Property safeModeProperty = project.objects.property(SafeMode) + protected final ListProperty docExtensionsProperty = project.objects.listProperty(Object) + + @Internal + private AsciidoctorJExtension getAsciidoctorJExtension() { + extensions.getByName(AsciidoctorJExtension.NAME) as AsciidoctorJExtension + } + + private final Provider jrubyLessDependenciesProvider = project.provider { + List deps = this.docExtensionsProperty.get().findAll { + it instanceof Dependency + } as List + Configuration cfg = detachedConfigurationCreator.apply(deps) + getAsciidoctorJExtension().loadJRubyResolutionStrategy(cfg) + } + + private final Provider>> attributesByLangProvider = project.provider { + def attributesByLang = new HashMap>() + languagesAsOptionals.each { lang -> + if (lang.isPresent()) { + attributesByLang.put(lang.get(), getAsciidoctorJExtension().getAttributesForLang(lang.get())) + } + } + attributesByLang + } as Provider>> + @Delegate private final DefaultAsciidoctorFileOperations asciidoctorTaskFileOperations @@ -303,7 +329,8 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask getReportableConfigurations() { - ([asciidoctorj.configuration] + projectOperations.configurations.asConfigurations(asciidocConfigurations)) + (/*[asciidoctorj.configuration] +*/ projectOperations.configurations.asConfigurations(asciidocConfigurations)) .toSet() } @@ -512,7 +539,7 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask, Configuration> inputs.files(asciidoctorj.configuration) - inputs.files { gemJarProviders }.withPathSensitivity(RELATIVE) +// inputs.files { gemJarProviders }.withPathSensitivity(RELATIVE) inputs.property 'backends', { -> backends() } inputs.property 'asciidoctorj-version', { -> asciidoctorj.version } inputs.property 'jruby-version', { -> asciidoctorj.jrubyVersion ?: '' } @@ -751,11 +778,11 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask deps) { - Configuration cfg = detachedConfigurationCreator.apply(deps) - asciidoctorj.loadJRubyResolutionStrategy(cfg) - cfg - } +// private FileCollection jrubyLessConfiguration(List deps) { +// Configuration cfg = detachedConfigurationCreator.apply(deps) +// asciidoctorj.loadJRubyResolutionStrategy(cfg) +// cfg +// } private Map preparePreserialisedAttributes(final File workingSourceDir, Optional lang) { prepareAttributes( projectOperations.stringTools, attributes, - (lang.present ? asciidoctorj.getAttributesForLang(lang.get()) : [:]), + (lang.present ? attributesByLangProvider.get().getOrDefault(lang.get(), [:]) : [:]), // THIS IS NULL getTaskSpecificDefaultAttributes(workingSourceDir) as Map, attributeProviders, lang