-
Notifications
You must be signed in to change notification settings - Fork 1
Create first gradle-plugin prototype #1
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
Comments
Things left TODO:
|
…ferently In #1 I noted that this plugin likely needs the publishing outlined in https://github.com/davidweber411/how-to-publish-to-maven-central-with-gradle/. The main reason is that maven plugins are getting published to maven central. However I now believe that especially gradle plugins may not to be configured published to maven.central. After reading https://docs.gradle.org/current/userguide/java_gradle_plugin.html#maven_publish_plugin https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html it became clear that gradle plugins should use 'com.gradle.plugin-publish' for publications, instead of a 'maven-publish'. Furthermore the GradlePluginDevelopmentExtension has a configuration to automatedPublishing. When set to true gradle will create the relevant publication tasks. With the extra publication added from https://github.com/davidweber411/how-to-publish-to-maven-central-with-gradle/ it made suddenly perfectly sense that gradle was giving me a warning messages that the mainJava publication was overwritten. there is one publication for the main java component of the plugin, but there are also pom publications for each of the apply '...' things that then reference the plugin. That way a plugin can provide multiple plugins that can be applied, but internally gradle will 'just' reference the same jar. From the gradle docs: ``` When the Java Gradle Plugin (java-gradle-plugin) detects that the Maven Publish Plugin (maven-publish) is also applied by the build, it will automatically configure the following MavenPublications: - a single "main" publication, named pluginMaven, based on the main Java component - multiple "marker" publications (one for each plugin defined in the gradlePlugin {} block), named <pluginName>PluginMarkerMaven (for example in the above example it would be simplePluginPluginMarkerMaven) ```
This plugin will support any version from gradle 5.1 and onwards. At least the test work with every released gradle version today: https://github.com/git-commit-id/git-commit-id-gradle-plugin/actions/runs/4900878729 Quite impressive and for me it feels reasonable "good enough" if this plugin supports any version that was released after Jan 02, 2019. |
Mhh after a bit back and forth it seems quite tricky in gradle to expose the properties to the project, while having an optional output-file generation including proper UP-TO-DATE checks. Here are the options I have tested so far: Inside the Tried to expose the generated properties using a task-extension so something along the lines of
The task extension is however only available when the task was executed. So when the task is deemed up-to-date no extension and thus no properties for any project are available. Fiddeling around with Closures. On the gradle documentation and code I have seen usage of Closures for properties.
the usage of such closure wasn't such a big deal:
but here again I had no access to the already generated properties. The only option I see left now is to make the generation of the properties file mandatory. The task that generates that file can certainly be seen as expensive and thus should be cached. To make the properties available to the projects and potentially to the reactor would be a second task that reads the properties file that had been generated by the generation task. That task is certainly very leightweight and thus we don't care if it's executed everytime (no caching, no up-to-date checks). |
Create a gradle plugin similar to the git-commit-id-maven-plugin.
Inspiration could be potentially drawn from the initial draft created years ago:
git-commit-id/git-commit-id-maven-plugin#92
Requirement:
The text was updated successfully, but these errors were encountered: