grv87 / gradle-base-plugins

Base plugins for Gradle projects and plugins developed by FIDATA
GNU Lesser General Public License v3.0
2 stars 0 forks source link
conventions defaults gradle internal opinionated opinions

gradle-base-plugins

Build Status

Plugins to configure Gradle to build projects (including other Gradle pluging) developed by FIDATA. They provide reasonable defaults and sane environment for all our projects.

These plugins are highly opinionated and for internal use only. They are not to be published to Maven Central or Gradle Plugins portal. However, you are free to fork, modify or use it as an example according to LGPL v3.0+ license.

If you are contributing to other FIDATA plugins the best choice is to join FIDATA organization and use all available infrastructure including our Artifactory repository where these plugins live.

org.fidata.project plugin

General, language-agnostic project.

Lifecycle

Basic build lifecycle is assemblecheckrelease.

assemble, check and, also, clean tasks are provided by applied lifecycle-base plugin.

release task is provided by applied de.gliderpilot.semantic-release plugin.

Prerequisites Lifecycle

Dependency Resolution

Documentation

Code Quality

Artifacts Publishing

Reports

Build Diagnostics and Troubleshooting

All these tasks are put into Diagnostics group.

Other features

Git Workflow

Earlier in the history we tried to use GitFlow. But it didn't work out well. GitHub doesn't support fast-forward merges. So, there was a big mess each time we merged from develop to master. Also, this led to unnecessary rebuilds on Jenkins.

Our current workflow resembles GitHub workflow and OneFlow.

buildSrc projects

Plugin can be applied to buildSrc projects. However, buildSrc projects can't have releases and documentation, so all related features are turned off. They also don't publish build info to Artifactory.

They could have code quality and diagnostic tasks, but usage of them is discouraged. Note that all buildSrc's Gradle and Groovy scripts are already covered by codenarcBuildSrc task.

Project gets isBuildSrc read-only property which will be set to true when buildSrc project is detected.

Supported tools versions:

org.fidata.base.jvm plugin

Project which uses JVM-based language. This plugin should not be applied manually.

Applies org.fidata.project plugin, and also:

Testing

Artifact Publishing

Code Quality

Other features

org.fidata.project.java plugin

Java language project.

Applies org.fidata.base.jvm plugin, and also:

org.fidata.base.groovy plugin

Project which uses Groovy language. This plugin should not be applied manually.

Applies org.fidata.base.jvm plugin, and also:

org.fidata.project.groovy plugin

Groovy language project.

Applies org.fidata.base.groovy plugin, and also:

org.fidata.plugin plugin

Gradle plugin project.

This plugin depends on at least one of JVM-based project plugins:

or others developed later.

They have to be applied manually depending on the language(s) used in the project.

Properties

Should be provided in standard Gradle ways .

PropertyRequiring PluginUsageNotes
artifactoryUser org.fidata.projectGetting build tools and dependencies from Artifactory; use Gradle cache 
artifactoryPassword It is actually API key
gitUsername Git push during release 
gitPassword  
ghToken Create release on GitHub 
gpgKeyId Sign artifacts, git commits and git tags 
gpgKeyPassphrase Not required. Assumes no passphrase if not provided
mavenCentralUsernameorg.fidata.base.jvm for public releasesRelease to Bintray 
mavenCentralPassword  
bintrayUser org.fidata.base.jvm for public releasesRelease to Bintray 
bintrayAPIKey  
gradlePluginsKey org.fidata.plugin for public releasesRelease to Gradle Plugins portal 
gradlePluginsSecret  

All properties except gpgKeyPassphrase are required. The plugin won't work if they are not set.

Multi-project Builds (a.k.a Monorepo)

These plugins supports multi-project builds in the following configuration:

  1. All child projects have the same version as the root one. This is the limitation imposed by de.gliderpilot.semantic-release plugin.

  2. org.fidata.project should be applied to root. It applies itself to each subproject

  3. de.gliderpilot.semantic-release and org.ajoberstar.git-publish plugins are applied to root only.

  4. The following properties are available for root project only:

    • isBuildSrc
    • isRelease
    • changeLog
    • changeLogTxt
    • issuesUrl
    • vcsUrl

    Except these, all other is configurable per project.

    Note that subprojects can have different licenses, and license file(s) (being included in JARs) are per project.

  5. Reports for all subprojects are redirected to build/reports/<format>/<subproject> directory. This is made for convenient usage under CI (Jenkins)

Development

This is self-applying plugin. That means that build script requires the plugin itself (just compiled, not released to the repository). So, if there are any errors during compilation or plugin applying, Gradle build script just doesn't work. If it is a compilation error, you can run ../gradlew build in buildSrc directory to figure out what's going on.

Upgrading Gradle Version

Whenever new Gradle version is released, the way to upgrade is this:

  1. Read Release Notes and make necessary changes to the code
  2. Run ./gradlew stutterWriteLock
  3. Run ./gradlew compatTest<new Gradle version>
  4. Change Gradle version for wrapper task in plugin code
  5. Run ./gradlew wrapper && ./gradlew wrapper

If a new version of a plugin won't be compatible with previous Gradle versions:

  1. Update ProjectPlugin.GRADLE_MINIMUM_SUPPORTED_VERSION value
  2. Run ./gradlew stutterWriteLock
  3. Update required Gradle version in this README file

Copyright © Basil Peace

This file is part of gradle-base-plugins.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.