Skip to content

KoDEx convention plugin#1765

Open
Jolanrensen wants to merge 3 commits intomasterfrom
kodex-convention-plugin
Open

KoDEx convention plugin#1765
Jolanrensen wants to merge 3 commits intomasterfrom
kodex-convention-plugin

Conversation

@Jolanrensen
Copy link
Collaborator

created dfbuild.kodex convention plugin, migrated :core and csv to use it

Helps #1661 and to a lesser extent #985,

@Jolanrensen Jolanrensen added the infrastructure GitHub actions, Gradle Scripts, Writerside, etc. label Mar 23, 2026
kodexConvention {
// we modified kotlin.sourceSets.(main|test); letting `dfbuild.kodex` know
// these will all be processed by KoDEx ánd end up in the final jar.
extraSourcesForKodex =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this needed here but not in csv module? What part of previous code corresponds to this logic?

Copy link
Collaborator Author

@Jolanrensen Jolanrensen Mar 23, 2026

Choose a reason for hiding this comment

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

since the convention plugin loads first, it doesn't pick up the additions of "generated-dataschema-accessors" to the kotlin main/test source sets. This is a problem, because it would mean they didn't end up in the final jars... (and csv does not have such an additional sourceset)

Maybe I could simplify the logic somewhat: Instead of "extra" sources, you're simply allowed to override the sourcesets used by KoDEx :) that would be similar to the extension notation of KoDEx we don't use yet (because I didn't get around to finishing it yet):

kodex {
    preprocess(mySourceSet) { ... }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

actually... maybe I can already use the kodex {} extension notation. It's just the jar creation that needs more work figuring out, but we can leave that as is

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

on second thought... this may need some consideration, as there are some sourcesets that do need to be handled by KoDEx but don't need to be in the final jar (like src/test) and the kodex {} notation doesn't support that kind of setup yet... Still, this convention plugin could be a good trial run for a design of that :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, it seems asking the sourcesets in afterEvaluate {} seems to get the most up-to-date version :D

@Jolanrensen Jolanrensen marked this pull request as draft March 23, 2026 20:32
@Jolanrensen Jolanrensen removed the request for review from AndreiKingsley March 23, 2026 20:33
@Jolanrensen
Copy link
Collaborator Author

Jolanrensen commented Mar 24, 2026

Following up on #1765 (comment):

I found out we had quite a difficult setup with how we processed our code:

generated code --------------> jars
                             /
source code --> KoDEx --> linter
              /       \
tests -------           not in jars

Not only is this difficult to understand, but it's also hard to maintain.

I simplified it as follows:

(main) generated code
                    \
(main) source code --> KoDEx ---> linter --> jars      (main)
                     /      \
(contextual) tests -           not in jars             (contextual)

In the new setup, both the generated code and source code form the "main" sourceset, which is exactly how the module forms it, all is processed by KoDEx, the results are linted, and the jars are created from that.

Besides this, we have a "contextual" sourceset, which by default includes the tests. This makes it so we can refer to tests from the main sourceset from KoDEx and include samples with @sample. However, this sourceset will not be included in any jars.

I was able to gather the "complete" sourcesets by getting the directories inside afterEvaluate {}, which makes any module-specific code run first before these parts of the convention plugin, and it makes any specific setup obsolete :). I will keep the extension, though, as we may need it in the future.

...

Now trying to make it build successfully...

@Jolanrensen Jolanrensen force-pushed the kodex-convention-plugin branch 3 times, most recently from 1f6957d to c3c371d Compare March 24, 2026 19:39
@Jolanrensen Jolanrensen force-pushed the kodex-convention-plugin branch from c3c371d to d09e37b Compare March 24, 2026 19:43
@Jolanrensen Jolanrensen marked this pull request as ready for review March 24, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure GitHub actions, Gradle Scripts, Writerside, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants