The SourceElement concept comes from the newer native effort from Gradle core (way back) and is a very convenient way to isolate elements of sources for text fixtures. We used the same fixtures to create the source code for the samples as it's a general-purpose programmatic templating engine. The major drawback with the SourceElement API is the inability to edit the embedded source code easily. We wrote some custom logic a while back to generate the matching SourceElement for pre-defined directories. Although the idea is good, we must switch between three contexts: SourceElement, pre-defined directories and the build system itself. A better approach is to stay with the SourceElement when authoring the fixtures and optionally attach the element to a file/directory on disk. Then, we can leave the build system to perform the link and ensure the files/directories are accessible at runtime.
It simplifies everything with the following steps:
1- Author "test projects" to ensure the correctness of the source element required
2- Create the source element API layer (built however a developer wants)
3- Use the SourceElement as normal classes for our template needs
This work will unblock the better sample authoring story.
The
SourceElement
concept comes from the newer native effort from Gradle core (way back) and is a very convenient way to isolate elements of sources for text fixtures. We used the same fixtures to create the source code for the samples as it's a general-purpose programmatic templating engine. The major drawback with the SourceElement API is the inability to edit the embedded source code easily. We wrote some custom logic a while back to generate the matchingSourceElement
for pre-defined directories. Although the idea is good, we must switch between three contexts:SourceElement
, pre-defined directories and the build system itself. A better approach is to stay with theSourceElement
when authoring the fixtures and optionally attach the element to a file/directory on disk. Then, we can leave the build system to perform the link and ensure the files/directories are accessible at runtime.It simplifies everything with the following steps: 1- Author "test projects" to ensure the correctness of the source element required 2- Create the source element API layer (built however a developer wants) 3- Use the
SourceElement
as normal classes for our template needsThis work will unblock the better sample authoring story.