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

Resolve Gradle Configuration Caching Issues When Executing AsciidoctorTask #1

Open
wants to merge 16 commits into
base: development-4.x
Choose a base branch
from

Conversation

tylerbertrand
Copy link
Owner

@tylerbertrand tylerbertrand commented Jun 19, 2024

Fixes the Gradle configuration caching issues originating from this project when executing org.asciidoctor.gradle.jvm.AsciidoctorTask. There are some remaining issues, but those are caused by the grolifant library.

The configuration caching issues in this project were primarily tasks referencing types incompatible with configuration caching. The references to these types were mostly held by AsciidoctorJExtension, which AbstractAsciidoctorTask held a reference to. To resolve this, the individual properties of AsciidoctorJExtension were moved directly to AbstractAsciidoctorTask in a configuration cache-compatible way. No input annotations were added to these properties to maintain parity with the current task behavior. The property values are wired from the extension to the task properties in AbstractAsciidoctorTask's constructor. In such cases where providers are used and referencing AsciidoctorJExtension is required, an @Internal getter is used to access the AsciidoctorJExtension instance. This @Internal getter prevents Gradle from attempting to serialize AsciidoctorJExtension to the configuration cache.

One behavioral change is that AbstractAsciidoctorTask no longer has the ability to write back to AsciidoctorJExtension since the reference from the task to the extension was removed. The methods that allowed this were updated to write to the properties that now reside in the task. As it stands I'm not sure what the full impact of that change is. Additionally, since this reference was removed, some methods were copied from AsciidoctorJExtension to AbstractAsciidoctorTask where needed. This should probably be done in a better way than just copying the methods, but I would like to get input first since this changes the relationship between the extension and the task.

The remaining configuration caching issues are shown in the following report
image

@tylerbertrand tylerbertrand changed the base branch from master to development-4.x June 20, 2024 19:05
@tylerbertrand tylerbertrand changed the title Tb/configuration caching Resolve Gradle Configuration Caching Issues When Executing AsciidoctorTask Jun 20, 2024
@tylerbertrand tylerbertrand force-pushed the tb/configuration-caching branch from 2d63794 to bc07f63 Compare June 20, 2024 19:24
Shorten too-long lines

Replace opt.isPresent() with opt.present

Remove unnecessary getters

Replace call to getAsciidoctorJExtension() with asciidoctorJExtension

Remove unnecessary package reference

Correct instance ordering
@tylerbertrand tylerbertrand force-pushed the tb/configuration-caching branch from a756f4a to 47262ef Compare June 20, 2024 21:13
@@ -750,26 +807,19 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask<AsciidoctorJvmExe
}
}

// TODO: Try to do this without a detached configuration
private FileCollection jrubyLessConfiguration(List<Dependency> deps) {
Copy link

@cdsap cdsap Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just FYI, in a recent conversation with the BT team, they mentioned:

detached configurations are probably not what you want. "detached" means that almost everything that 
comes from project state is separate.  We were going to deprecate detached configurations from extending
 project configurations,

Copy link

@runningcode runningcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking great, just some minor questions!

@@ -719,19 +776,19 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask<AsciidoctorJvmExe
if (deps.empty && closurePaths.empty) {
projectOperations.fsOperations.emptyFileCollection()
} else if (closurePaths.empty) {
jrubyLessConfiguration(deps)
jrubyLessDependenciesProvider.get()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to pass deps to this?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deps doesn't need to be passed in here as it has been moved to within the provider

private final Property<FileCollection> jvmClasspath
private final List<Provider<File>> gemJarProviders = []

protected final MapProperty<String, Object> optionsProperty = project.objects.mapProperty(String, Object)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these protected instead of private?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had run into some unknown property exception issues that I thought were resolved by this, but after testing now, it works just fine with them private, so I've made that change.

this.asciidoctorj = extensions.create(AsciidoctorJExtension.NAME, AsciidoctorJExtension, this)

def asciidoctorj = extensions.create(AsciidoctorJExtension.NAME, AsciidoctorJExtension, this)
this.optionsProperty.set(asciidoctorj.options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we setting default values here? what does this block do?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, setting default values

…actAsciidoctorTask to be private

There is no reason for them to be protected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants