Is there a small and concise example of creating a Gradle plugin that handles certain types of source files as a SourceSet?

(Christopher Molozian) #1

I’ve been looking through the Gradle source code for some of the internally distributed plugins (particularly the scala and cpp plugins) as well as the jslib gradle plugin to try and understand how to create a plugin that builds a source set for a specific type of source file.

I’ve been having mixed success as the internal plugins seem to use different layers of functionality such as using Convention rather than Extension objects for configuration as well as using ProjectInternal rather than the Project interface.

Could one of the Gradle developers create a really small example of creating a SourceSet for a markdown (’.md’ files) processing plugin?


             |-- *.md
             |-- *.markdown
             |-- *.md
             |-- *.markdown
    |-- apply plugin: 'marky'

(Luke Daley) #2

The source set mechanism is not really extensible in this way atm, which is why those other plugins need to avoid it. Fixing this problem is on our list.

What exactly do you need from SourceSet for the markdown functionality?

Take a look at FileTree (‘project.fileTree()’) as it likely does all of what you will need here.

(Christopher Molozian) #3

Thanks for the prompt response as always Luke :slight_smile:

I’d really like the plugin to offer the customisation available in the Java plugin like what’s available here:

What’s a good example of a Gradle internal plugin that’s using FileTree’s to gather sources rather than a SourceSet?