Creating Gradle Plugins

build.gradle
ysfProject {
  gradleProject {
    ccCompatible = true (1)
    isolatedProjectCompatible = (2)
    addGradleApiAttribute() (3)
    addGradleApiAttribute('8.8') (4)
    tags 'foo', 'bar' (5)
  }
}

gradlePlugin {
    plugins {
        aPlugin {
            id ='org.ysb33r.example'
            displayName = 'Example plugin'
            description = 'Description of example plugin'
            tags.addAll('example1', 'example2')
            implementationClass = 'org.ysb33r.example.ExamplePlugin'
        }
    }
}
1 Set to true if all plugins in this (sub)project are Configuration Cache-compatible.
2 Set to true if all plugins in this (sub)project are Isolated Project-compatible.
3 Adds the Gradle API attribute and uses the minGradleVersion Gradle property as the value.
4 Sets the Gradle API attribute to the given value.
5 Tags that will be applied to all plugins in the (sub)project.

Testing Gradle 9

When org.ysb33r.ysf-project.gradle-plugin is applied, a second Gradle test set named gradle9 is added. This uses JDK17 and is meant for Gradle 9 testing. It also adds adjusts the attribute as to only load Gradle 9 compatible APIs.

To run this in CI, a component needs to be added

gitlab-ci.yml
  - component: $CI_SERVER_FQDN/ysb33rOrg/org/gitlab-pipeline-recipes/gradleTest@VERSION_TAG (1)
    inputs:
      gradleTestTaskName: gradle9GradleTest
      versions: 9.7.1 (2)
1 Replace VERSION_TAG with the appropriate pipeline recipe tag.
2 Use only 9.x versions.