Skip to content

Add external reader support in pkl-gradle #1067

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

HT154
Copy link
Contributor

@HT154 HT154 commented May 11, 2025

No description provided.

@HT154 HT154 force-pushed the gradle-external-readers branch from 498201d to fc0567e Compare May 11, 2025 06:19
@HT154 HT154 force-pushed the gradle-external-readers branch from fc0567e to a18074d Compare May 12, 2025 20:35
@bioball
Copy link
Member

bioball commented May 12, 2025

@HT154 can we add some test coverage for this?

I think this would involve moving TestExternalReaderProcess to pkl-commons-test, and adding a corresponding test to org.pkl.gradle.EvaluatorsTest.

Hint: the Groovy syntax for maps is [key: value].
External readers would look something like:

externalModuleReaders = ["foo": new org.pkl.gradle.ExternalReader("bar")]

@HT154 HT154 force-pushed the gradle-external-readers branch 4 times, most recently from 6e43b16 to e6b911e Compare May 19, 2025 02:35
@HT154 HT154 force-pushed the gradle-external-readers branch from e6b911e to f6d3224 Compare May 19, 2025 02:51
import java.util.List;
import org.pkl.core.util.Nullable;

public record ExternalReader(String executable, @Nullable List<String> arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a material difference between null arguments and empty list of arguments? Because if not, I would recommend not marking this as nullable and instead use an empty list.

Comment on lines +148 to +154
@Nested
@Optional
public abstract MapProperty<String, ExternalReader> getExternalModuleReaders();

@Nested
@Optional
public abstract MapProperty<String, ExternalReader> getExternalResourceReaders();
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be marked as @Input properties, not @Nested. The @Nested annotation in Gradle is used to make Gradle process values of a map property as beans. All @Nested properties are treated as @Input, so it will work as is, but semantically values of this map are just data carriers without any annotations which do not require further processing, so I think that @Input would be more appropriate here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @netvl! Do you know of any documentation that covers these subtleties? I wasn't able to find anything when I searched.

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