Coder Social home page Coder Social logo

wiremock / gradle-wiremock-extension-plugins Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 147 KB

Gradle plugins that bundles common packaging and release logic for WireMock extensions

License: Apache License 2.0

Kotlin 100.00%
gradle gradle-plugin wiremock kotlin

gradle-wiremock-extension-plugins's Introduction

Gradle Convention plugin for WireMock Extensions

This convention plugin helps to Build WireMock extensions so that they can be hosted on Maven Central and released automatically from GitHub actions. See the Maven Central Publishing documentation to learn more.

Features:

  • Code signing and POM generation for Maven Central publishing
  • Proper shading of artifacts (work in progress)

Requirements

  • Gradle 8.x
  • Java 11 or 17

Wiremock dependency

This extension has a bundled wiremock dependency. Depending on the wiremock features you're using in your plugin, this plugin needs to be updated accordingly:

Gradle Convention plugin version Wiremock version
0.3.0+ 3.6.0
0.1.0+ 3.3.1

Usage

Basic use

Set the following gradle.properties:

baseArtifact = my-test-wiremock-extension
version = 1.0.0-SNAPSHOT
description = My Test WireMock Extension
githubRepo = wiremock-my-test-extension
developer.id=todo
developer.name=TODO WireMock Developer
developer.email[email protected]

Use the plugin in your build.gradle.kts file:

buildscript {
    repositories {
        mavenCentral()
    }
}
        
plugins {
    kotlin("jvm") version "$embeddedKotlinVersion"
    id("org.wiremock.tools.gradle.wiremock-extension-convention")
}

Or in Gradle:

buildscript {
    repositories {
        mavenCentral()
    }
}

plugins {
    id 'org.wiremock.tools.gradle.wiremock-extension-convention' version '0.1.2'
}

Shading of dependencies

When you need to include additional dependencies, they should be shaded in the shadedJar task:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
                
dependencies {
    implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
}

tasks {
    named<ShadowJar>("shadowJar") {
        relocate("com.github.ben-manes.caffeine", "wiremock.com.github.ben-manes.caffeine")
        relocate("com.github.jknack", "wiremock.com.github.jknack")
    }
}

Release Automation

To automate releases with this extension, add the following GitHub action in .github/workflows/:

name: Release
on:
  release:
    types: [published]

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v3
      - name: Set up Java
        uses: actions/setup-java@v3
        with:
          java-version: '11'
          distribution: 'adopt'
      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@v1

      - name: Determine new version
        id: new_version
        run: |
          NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
          echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT

      - name: Publish package
        id: publish_package
        uses: gradle/[email protected]
        with:
          arguments: -Pversion=${{ steps.new_version.outputs.new_version }} publish closeAndReleaseStagingRepository
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
          OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
          OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
          OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}

Once the request for Maven Central Publishing authorization is completed, you can trigger the release Pipeline by just publishing a GitHub Release. Consider also configuring Release Drafter to automate chaangelogs.

Usage Examples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.